From: Sean on
"Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <ht3i18$31b$1(a)fred.mathworks.com>...
> "Ibtesam Saleh" <bossy_4me(a)yahoo.com> wrote in message <ht3h5k$53e$1(a)fred.mathworks.com>...
> > > -"Gray" it (rgb2gray)
> > > -Pick a threshold
> > > -Ibw = Igray > threshold;
> >
> > thanks sean for quick response, are you mean like this:
> > gray= rgb2gray(image);
> > bw= im2bw(gray);
> >
> > I don't know what is the second and third steps mean?
> >
>
> Once you have a gray image you must chose a threshold.
> A value which above it all pixels will be assigned to 1 and beneath to 0.
> You may do that in various ways.
>
> In my example, I is a gray scale image:
>


> Threshold = 128;
> I(I < 128) = 0;
> I(I >= 128) = 1; % Pay attention to the order
> I = logical(I); % Casting

That is 2 more steps than necessary. Just using the logical operator on the whole image will convert everything below to logical 0 and above to true 1.
>>Ibw = Igray > threshold;

Original Poster's question; one way to pick a threshold:
>>imtool(Igray);
Then click on the black and white circle which will pull up the histogram. You can adjust the lines to see what various thresholds will do. Pick the one that well suits you.

Good Luck!
From: Ibtesam Saleh on
> That is 2 more steps than necessary. Just using the logical operator on the whole image will convert everything below to logical 0 and above to true 1.
> >>Ibw = Igray > threshold;
>
> Original Poster's question; one way to pick a threshold:
> >>imtool(Igray);
> Then click on the black and white circle which will pull up the histogram. You can adjust the lines to see what various thresholds will do. Pick the one that well suits you.
>
> Good Luck!

I face error when try imtool(Igray);
??? Undefined command/function 'imtool'.

I try "help imtool" and I get
imtool.m not found.
Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.

I am using Matlab7,