From: David Bennett on
Hi,
I am opening vendor specific MRI images (not dicom) whose elements are unsigned 16-bit integers. I tried thresholding the "images" using graythresh but always received back a "level" of 0.0. Then I tried saving the MR image data as a TIFF file and applying graythresh() to the TIFF file - same result, i.e., the result of the code:

I = imread('MRI.tiff'); % or imread('MRI.bin')
level = graythresh(I);
BW = im2bw(I,level);
imview(BW)

is all logical 1s.

I can manually insert a “level” (say 0.0035) into the im2bw(I,level) to give a meaningful result from im2bw but I want to remove the manual threshholding step (obviously).

any suggestions are greatly appreciated!

thank you
From: ImageAnalyst on
Well that's where the "art" comes in. You have to look at a bunch of
histograms and think up a custom threshold selection algorithm that
works for the type of histograms that you encounter. Most likely it
won't be the Otsu method like graythresh uses if you pass in no
parameter. You have to look at where .0035 falls on the histogram and
figure out how to chop the histogram at that same location even if the
location needs to be adjusted slightly because the shape of the
histogram is slightly different.
From: David Bennett on
Hi ImageAnalyst,
thank you for your advice.
I don't know anything about Otsu's method, but I would assume that the algorithm would always pick some threshold (or "level") for a grayscale image (even if the image is noisy). Also, when graythresh returns "level" = 0.0, I don't know what that means, i.e. is the image too noisy to find a level, or, because my image elements are 16-bit, was there information lost in the conversion to 8-bit (although the author of graythresh says that the function can take uint16 data....I just don't see in the graythresh code how uint16 data is handled differently) ?

cheers
-Dave

ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <b5311ba1-f020-4b79-bf60-c4f5b912a08a(a)b7g2000yqd.googlegroups.com>...
> Well that's where the "art" comes in. You have to look at a bunch of
> histograms and think up a custom threshold selection algorithm that
> works for the type of histograms that you encounter. Most likely it
> won't be the Otsu method like graythresh uses if you pass in no
> parameter. You have to look at where .0035 falls on the histogram and
> figure out how to chop the histogram at that same location even if the
> location needs to be adjusted slightly because the shape of the
> histogram is slightly different.
From: ImageAnalyst on
Don't worry about what it does - you're not going to use it. Like I
said, chances are it won't pick the right threshold for you anyway.
You can look up the Otsu method if you want (basically it chooses a
threshold such that the RMS difference between the binary image and
the original image is minimized I believe), but you're most likely
going to need to develop your own algorithm for thresholding.
From: ImageAnalyst on
David:
I just stumbled across a kmeans segmentation routine in the File
Exchange.
http://www.mathworks.com/matlabcentral/fileexchange/8379-kmeans-image-segmentation
I didn't download it or run it - I just looked at the screenshot - but
it does classification of an MRI image. Check it out if you want.