I know that you can get the max and min of a selection with the getMinAndMax function (or getStatistics). Is there a way to get e.g. the 3 maximum or minimum values. I was searching for a function to list all the values in a selection, and then sorting those and getting X maximal or minimal values. However, I cannot find a way of listing all the values in my selection. Also, I don't know if it possible to then easily sort them to get the highest values.
Can anyone help me? Thanks! |
>I know that you can get the max and min of a selection with the
>getMinAndMax function (or getStatistics). Is there a way to get e.g. >the 3 maximum or minimum values. I was searching for a function to >list all the values in a selection, and then sorting those and >getting X maximal or minimal values. However, I cannot find a way of >listing all the values in my selection. Also, I don't know if it >possible to then easily sort them to get the highest values. > >Can anyone help me? > >Thanks! >-- >View this message in context: >http://n2.nabble.com/get-3-max-and-min-values-tp2640330p2640330.html >Sent from the ImageJ mailing list archive at Nabble.com. With 8 bit images you may use getHistogram(values, counts, nBins[, histMin, histMax]) HTH -- Herbie ------------------------ <http://www.gluender.de> |
yes, but this doesnt really work well for 16 bit images. and i don't want to compress the data to 8bit.
any other suggestions?
|
In reply to this post by danibodor
Hi Dani,
There are two ways: (1) Get the histogram and analyze it. For float images, the accuracy will be limited, however. (2) The "destructive way", with higher accuracy for float images: First make a copy of your image to work with. Use getStatistics to get the maximum. Then use the new process>Math>Macro command to eliminate the pixel(s) with value=maximum: run("Macro...", " code=[if(v>="+myMax+") v="+minValue+";]"); where myMax is the maximum from the statistics (beware of rounding error in float numbers converted to a string, so set it to a slightly lower value). minValue=0 for integer images, and -1.79E308 for float images. Again, repeat for 2nd-highest values (now the previous maximum is not a highest value any more), etc. Michael ________________________________________________________________ On 15 Apr 2009, at 19:48, danibodor wrote: > I know that you can get the max and min of a selection with the > getMinAndMax function (or getStatistics). Is there a way to get > e.g. the 3 maximum or minimum values. I was searching for a > function to list all the values in a selection, and then sorting > those and getting X maximal or minimal values. However, I cannot > find a way of listing all the values in my selection. Also, I don't > know if it possible to then easily sort them to get the highest > values. > > Can anyone help me? > > Thanks! |
In reply to this post by danibodor
> I know that you can get the max and min of a selection with the getMinAndMax
> function (or getStatistics). Is there a way to get e.g. the 3 maximum or > minimum values. I was searching for a function to list all the values in a > selection, and then sorting those and getting X maximal or minimal values. > However, I cannot find a way of listing all the values in my selection. Also, > I don't know if it possible to then easily sort them to get the highest > values. > I finally got a bit of time to write a demonstration macro to illustrate how this can be done. It is a bit crude, but it works. :-) Chris run("HeLa Cells (1.3M, 48-bit RGB)"); w = getWidth; h = getHeight; maxPix1 = 0; maxPix2 = 0; maxPix3 = 0; maxPix = 0; minPix = 0; minPix1 = 100000000.00; minPix2 = 100000000.00; minPix3 = 100000000.00; for (slice = 1; slice <= 3; slice ++) { setSlice(slice); for (x = 0; x < w; x++) { for (y = 0; y < h; y++) { pix = getPixel(x, y); if (pix > maxPix1) { maxPix = maxPix1; maxPix1 = pix; } if (pix > maxPix2 && pix < maxPix1 || maxPix2 < maxPix && maxPix < maxPix1) { if (pix > maxPix) { if (pix < maxPix1) { maxPix = maxPix2; maxPix2 = pix; } else maxPix2 = maxPix; } else maxPix2 = maxPix; } if (pix > maxPix3 && pix < maxPix2 || maxPix3 < maxPix && maxPix < maxPix2) { if (pix > maxPix) { if (pix < maxPix2) { maxPix = maxPix3; maxPix3 = pix; } else maxPix3 = maxPix; } else maxPix3 = maxPix; } if (pix < minPix1) { minPix = minPix1; minPix1 = pix; } if (pix < minPix2 && pix > minPix1 || minPix2 > minPix && minPix > minPix1) { if (pix < minPix) { if (pix > minPix1) { minPix2 = pix; } else minPix2 = minPix; } else minPix2 = pix; } if (pix < minPix3 && pix > minPix2 || minPix3 > minPix && minPix > minPix2) { if (pix < minPix) { if (pix > minPix2) { minPix = minPix3; minPix3 = pix; } else minPix3 = minPix; } else minPix3 = pix; } } } } print("max 1 = " + maxPix1 + " min 1 = " + minPix1); print("max 2 = " + maxPix2 + " min 2 = " + minPix2); print("max 3 = " + maxPix3 + " min 3 = " + minPix3); The GAIA Group Global Automated Image Analysis We help Researchers help themselves! Find out about Online Tutoring for ImageJ Christopher Coulon, Ph.D., Founder http://gaiag.net [hidden email] |
Free forum by Nabble | Edit this page |