Dear list members,
I was wondering if there's a specific option/way to do measurements in an image with sub-pixel resolution? I paste below macro code to illustrate what I mean. The following creates a 10x10 pixels image, half of which is back and the other half white. If I draw a triangle that is half in the black and half in the white area, with a total area of 1pixel, I get a mean value of 255, but I would have expected 127.5 newImage("Untitled", "8-bit black", 10, 10, 1); makeRectangle(5, 0, 5, 10); setBackgroundColor(255, 255, 255); run("Clear", "slice"); makePolygon(4,5,6,5,5,6); run("Measure"); Does anyone know if it's possible to get 127.5? Thanks for your help, Best wishes, Emmanuel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Emmanuel,
selections (=ROIs, regions of interest) in ImageJ cannot contain something like half a pixel. A pixel is considered either inside or outside a selection, nothing in between. If you need better resolution for measurements, you have to increase the image size, Image>Adjust>Size, and use interpolation. Michael ___________________________________________________________________ On Sun, May 8, 2016 18:15, Emmanuel Levy wrote: > Dear list members, > > I was wondering if there's a specific option/way to do measurements in an > image with sub-pixel resolution? > > I paste below macro code to illustrate what I mean. The following creates > a > 10x10 pixels image, half of which is back and the other half white. If I > draw a triangle that is half in the black and half in the white area, with > a total area of 1pixel, I get a mean value of 255, but I would have > expected 127.5 > > newImage("Untitled", "8-bit black", 10, 10, 1); > > makeRectangle(5, 0, 5, 10); > > setBackgroundColor(255, 255, 255); > > run("Clear", "slice"); > > makePolygon(4,5,6,5,5,6); > > run("Measure"); > > > Does anyone know if it's possible to get 127.5? > > Thanks for your help, > > Best wishes, > > Emmanuel > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
Thank you for replying. selections (=ROIs, regions of interest) in ImageJ cannot contain something > like half a pixel. That is a pity - from the perspective of the GUI it appears possible to define sub-pixel selections, which made me hopeful ( https://imagej.nih.gov/ij/docs/guide/146-10.html). In principle, I could have imagined that the value of a pixel covered by a selection could be weighted by the fraction of its area covered. But it's good to know it's not a possibility, I won't look any further. If this becomes critical we will use the size-adjustment trick you suggested. Thanks again, Emmanuel A pixel is considered either inside or outside a > selection, nothing in between. > > If you need better resolution for measurements, you have to increase the > image size, Image>Adjust>Size, and use interpolation. > > Michael > ___________________________________________________________________ > > On Sun, May 8, 2016 18:15, Emmanuel Levy wrote: > > Dear list members, > > > > I was wondering if there's a specific option/way to do measurements in an > > image with sub-pixel resolution? > > > > I paste below macro code to illustrate what I mean. The following creates > > a > > 10x10 pixels image, half of which is back and the other half white. If I > > draw a triangle that is half in the black and half in the white area, > with > > a total area of 1pixel, I get a mean value of 255, but I would have > > expected 127.5 > > > > newImage("Untitled", "8-bit black", 10, 10, 1); > > > > makeRectangle(5, 0, 5, 10); > > > > setBackgroundColor(255, 255, 255); > > > > run("Clear", "slice"); > > > > makePolygon(4,5,6,5,5,6); > > > > run("Measure"); > > > > > > Does anyone know if it's possible to get 127.5? > > > > Thanks for your help, > > > > Best wishes, > > > > Emmanuel > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Emmanuel Levy
Dear Emmanuel,
To obtain subpixel resolution apply first deconvolution. 2016-05-08 18:15 GMT+02:00 Emmanuel Levy <[hidden email]>: > Dear list members, > > I was wondering if there's a specific option/way to do measurements in an > image with sub-pixel resolution? > > I paste below macro code to illustrate what I mean. The following creates a > 10x10 pixels image, half of which is back and the other half white. If I > draw a triangle that is half in the black and half in the white area, with > a total area of 1pixel, I get a mean value of 255, but I would have > expected 127.5 > > newImage("Untitled", "8-bit black", 10, 10, 1); > > makeRectangle(5, 0, 5, 10); > > setBackgroundColor(255, 255, 255); > > run("Clear", "slice"); > > makePolygon(4,5,6,5,5,6); > > run("Measure"); > > > Does anyone know if it's possible to get 127.5? > > Thanks for your help, > > Best wishes, > > Emmanuel > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |