Login  Register

Python iteration through Pixel/ROI to slow ... ?

Posted by Andreas Rzepecki on Oct 22, 2013; 12:06pm
URL: http://imagej.273.s1.nabble.com/Python-iteration-through-Pixel-ROI-to-slow-tp5005274.html

Hello together,

I wrote a more or less complex plugin in python for Fiji, which helps me to analyse every pixel of an image (row by row) in combination with some ROI calculation. The iteration I use is:

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):
        pix_sap = rt.getValue("Sapflow per Pixel", sap_row)
        sumpix_sap = sumpix_sap + pix_sap
        break
      else:
      sap_row = sap_row + 1
  table.incrementCounter()
  table.addValue("Sapflow sum", sumpix_sap * 1000000)
IJ.showProgress(1)


For a test picture (620x90 pixel, 197 ROIs) it needs some seconds to calculate my result values.

For another test picture (592x301, 1172 ROIs) it needs around 6 minutes.

Unfortunatly I need to analyse pictures with 6000x1000+ pixel and 100000+ ROIs. I tried it but stopped it after around 30 minutes with the progress bar not moving once.

Is this a problem with python iterations or did I something wrong with my code, which slows down the progress unnecessarily?

I would appreciate any hint/help. Thank you very much in advance.

Andreas

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html