Login  Register

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

Posted by ctrueden on Oct 23, 2013; 3:36pm
URL: http://imagej.273.s1.nabble.com/Python-iteration-through-Pixel-ROI-to-slow-tp5005274p5005287.html

Hi Andreas,

> I try to lable the ROIs with a grey color (1-65536 in a 16bit picture)

If you use Fiji and add the LOCI update site [1], the Plugins > LOCI > Roi
Map plugin will do this for you. If you have 255 or fewer ROIs it creates
an 8-bit labeling with discontinuous LUT (similar to Glasbey [2]). If you
have more than 255 ROIs it creates a 16-bit labeling with grayscale LUT.

Source at:
https://github.com/uw-loci/misc-plugins/blob/master/src/main/java/loci/plugins/RoiMap.java

Regards,
Curtis

[1] http://fiji.sc/Update_Sites
[2] http://fiji.sc/Glasbey



On Wed, Oct 23, 2013 at 6:32 AM, Andreas Rzepecki
<[hidden email]>wrote:

> Thx for the help so far. I try to lable the ROIs with a grey color
> (1-65536 in a 16bit picture) first, which will most probably speed up my
> procedure.
>
> Therefore I tried this code:
>
> import math
> from ij import IJ
> from ij.gui import GenericDialog
> imp = IJ.getImage()
> ip = imp.getProcessor().convertToFloat()
>
> imp = IJ.getImage()
> ip = imp.getProcessor().convertToFloat()
> grey_value = 1
>
> IJ.run("Set Measurements...", "area centroid perimeter shape feret's
> area_fraction redirect=None decimal=6")
> IJ.run("Set Scale...")
> IJ.run("Analyze Particles...")
> IJ.run("16-bit")
>
> for roi in RoiManager.getInstance().getRoisAsArray():
>   roi.setFillColor(grey_value)
>   grey_value = grey_value + 1
>
> imp.show()
>
>
> This leads to:
>
> TypeError: setFillColor(): 1st arg can't be coerced to java.awt.Color
>
> Unfortunatly it looks like setFillColor() needs the color determing value
> in another form? Would it be possible to use 32bit picture too, because I
> maybe need more then 65536 lable classes?
>
> Best regards
>
> Andreas
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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