Posted by
Andreas Rzepecki on
Oct 22, 2013; 8:14pm
URL: http://imagej.273.s1.nabble.com/Python-iteration-through-Pixel-ROI-to-slow-tp5005274p5005271.html
Hi Michael,
thanks for your answer, after reading it several times I changed the rt.getValue command. The new iterating part of the plugin is now:
for j in range(x):
IJ.showProgress(j, x)
sumpix_sap = 0
for i in range(y):
sap_row = 0
for roi in RoiManager.getInstance().getRoisAsArray():
if roi.contains(j, i):
f = roi.getFeretValues()
ip.setRoi(roi)
stats = ImageStatistics.getStatistics(ip, Measurements.AREA, None)
pix_sap = ((math.pi/4) * (1/(nu*L)) * math.pow(f[0], 3) * math.pow(f[2], 3) / (math.pow(f[0], 2) + math.pow(f[2], 2))*p)/stats.pixelCount
sumpix_sap = sumpix_sap + pix_sap
break
table.incrementCounter()
table.addValue("Sapflow sum", sumpix_sap * 1000000)
IJ.showProgress(1)
table.show("IASF-Results")
but it still needs too much time, so here is what I want to do with this code:
1. Iterating through every pixel of the picture (row by row)
2. If the pixel is inside a certain ROI calculate a value for this pixel determined by the ROI and divided by the amount of pixel of this ROI (= pix_sap; nu ,L, p are constant))
3. Calculating the sum of pix_sap per pixel row
4. Print the sum of pix_sap per pixel row
Maybe using a function for the calculation will speed up the plugin, but in my oppinion the main problem seems to be that I potentially have to iterate through every pixel * ROI.
Thanking you in advance.
Andreas
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html