Re: Python iteration through Pixel/ROI to slow ... ?
Posted by
Andreas Rzepecki on
Oct 22, 2013; 4:00pm
URL: http://imagej.273.s1.nabble.com/Python-iteration-through-Pixel-ROI-to-slow-tp5005274p5005267.html
Dear Mr. Street,
thank you very much for the mask-hint. I tried to change my code to avoid roi.contains() and instead use mask.get:
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():
mask = roi.getMask()
if mask.get(j, i)!= 0:
pix_sap = rt.getValue("Sapflow per Pixel", sap_row)
sumpix_sap = sumpix_sap + pix_sap
else:
sap_row = sap_row + 1
table.incrementCounter()
table.addValue("Sapflow sum", sumpix_sap * 1000000)
IJ.showProgress(1)
table.show("IASF-Results")
This unfortunately leads to the following Java-error:
Traceback (most recent call last):
File "<iostream>", line 44, in <module>
at ij.process.ByteProcessor.get(ByteProcessor.java:262)
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: 30
So I'm at this point not sure if I have completely misunderstood the mask command.
Best regards
Andreas Rzepecki
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html