From: Kenneth Galea on
"Kenneth Galea" <k.galea(a)hotmail.com> wrote in message <hkhlvr$s4q$1(a)fred.mathworks.com>...
> ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <e898f069-d53a-4348-a178-77e37c88c21e(a)z26g2000yqm.googlegroups.com>...
> > Kenneth:
> > You could do it that way, bit if you do then you'd be thresholding for
> > the background. That's fine, but then you have to invert it to get
> > the mask for the objects. But that's easy, just do
> > binaryImage = ~binaryImage;
>
> Hi. Finally I got it right using subtraction and ensuring that illumination is the same!! Yes I used equals instead of binaryImage = ~binaryImage. Does it make a difference?
> i.e. for example:
> binaryImageRed = (subtractedImageRed <= -redThresholdHigh) |(subtractedImageRed >= redThresholdLow);
> Both of them gave the same result except the inversion of colour (i.e. objects are black and background is white when not using =~) . Thanks a lot for your help since without your help I surely wouldn't have managed :) Just one last thing. I can't understand the meanings behind these values in your demo code (which I had to use and I really need to understand) :
>
> redThresholdLow = graythresh(subtractedImageRed);
> redThresholdHigh = 255;
> greenThresholdLow = 0;
> greenThresholdHigh = graythresh(subtractedImageGreen);
> blueThresholdLow = 0;
> blueThresholdHigh = graythresh(subtractedImageGreen);
>
> Thanks again
> Kenneth

I'm asking just because I didn't include the other part of your demo code after it and it still worked:
i.e. I didn't include the following:
redThresholdLow = uint8(redThresholdLow * 255);
greenThresholdHigh = uint8(greenThresholdHigh * 255);
blueThresholdHigh = uint8(blueThresholdHigh * 255);

Since when adding the latter part of code to the other part where graythresh was used it didn't work... strange !!
>thanks
Kenneth
>
From: ImageAnalyst on
graythresh() computes the Otsu threshold automatically from the
image. Unfortunately, it returns a value in the range of 0-1. I
didn't want this - I wanted the actual gray level so that's why I
multipliled it by 255.

From: Kenneth Galea on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <25d4fe97-a899-4902-ac8d-62caebb220fa(a)m16g2000yqc.googlegroups.com>...
> graythresh() computes the Otsu threshold automatically from the
> image. Unfortunately, it returns a value in the range of 0-1. I
> didn't want this - I wanted the actual gray level so that's why I
> multipliled it by 255.

Yes ok I understand that.... But why do you use graythresh for low red threshold but graythresh for high blue and green thresholds ?? ...as shown:

redThresholdLow = graythresh(subtractedImageRed);
redThresholdHigh = 1;
greenThresholdLow = 0;
greenThresholdHigh = graythresh(subtractedImageGreen);
blueThresholdLow = 0;
blueThresholdHigh = graythresh(subtractedImageBlue);

Thanks
Kenneth
From: ImageAnalyst on
Because I wanted to select objects that had high red values but low
green and low blue values. Objects that have high red and low green
and blue signal will appear as red in the image. Make sense?

As a counter example if I wanted greenish things, I'd take reds in the
range 0-redThresh, greens in range greenThresh-255, and blues in the
range 0-blueThresh.

If I wanted blue things I'd take pixels having higher blue values and
lower red and green values.
Does that make more sense now?

From: Kenneth Galea on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <43b5892c-04fa-4b61-b1cc-328deeb03719(a)t1g2000vbq.googlegroups.com>...
> Because I wanted to select objects that had high red values but low
> green and low blue values. Objects that have high red and low green
> and blue signal will appear as red in the image. Make sense?
>
> As a counter example if I wanted greenish things, I'd take reds in the
> range 0-redThresh, greens in range greenThresh-255, and blues in the
> range 0-blueThresh.
>
> If I wanted blue things I'd take pixels having higher blue values and
> lower red and green values.
> Does that make more sense now?

Yes thanks a lot. Now I my problem is that when I subtract a white image from another white image some "salt and pepper nosie is seen". I used medfilt2 but its still not enough. After I used bwareaopen which didn't make any diffenerce even if I consider an area of 50 pixels...don't know why its not working!! Is there another method for this noise removal??

Thanks
Kenneth