Re: Check for post-threshold binary image
Posted by
Michael Schmid on
URL: http://imagej.273.s1.nabble.com/Check-for-post-threshold-binary-image-tp3692956p3692957.html
Hi Mike,
if your 8-bit images use ONLY pixel values of -1 and 0 they are
indistinguishable from binary images obtained by 'apply threshold'.
(note that -1 is interpreted as 255 by ImageJ: it treats the image as
unsigned bytes).
If you have also other pixel values, Gabriel's histogram-based method
will work (the same code is in ij.plugin.filter.Binary).
Michael
________________________________________________________________
On 14 Apr 2009, at 16:13, Michael Doube wrote:
> Hi all,
>
> I'm looking for a short bit of Java that will check to see if an
> image is binary (result of Adjust->Threshold->Apply) or not. Just
> checking bit depth and making sure that pixel values are 0 or 255
> is not quite enough because
>
> ImageStack.getPixels(int n);
>
> returns an array of 0 (background) and -1 (foreground) elements,
> and I use raw 0 and -1 values in my logic.
>
> Cheers
>
> Mike