Display gray color only from grayscale image

8 views (last 30 days)
Demons
Demons on 17 Jan 2013
Hi all
Apology for my ignorance as this is quite new to me.
I'm currently working on MRI images and have tried numerous times using some thresholding methods to display gray area of MRI image/s but to no avail.
Any pixel with grayscale value (0-255) of less than 5 & more than 250 will be eliminated and thus only showing pixels within 6-249.
Any helps are much appreciated.
Regards Demon
  2 Comments
Demons
Demons on 17 Jan 2013
transparent or black if that matter.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 17 Jan 2013
You can alter the image to mask out (set to zero) those pixels with gray levels outside 5 and 250 inclusive:
darkPixels = grayImage <= 5;
lightPixels = grayImage >= 250;
pixelsToExclude = darkPixels | lightPixels;
grayImage(pixelsToExclude) = 0;
Is that what you want to do?
  10 Comments
Image Analyst
Image Analyst on 19 Jan 2013
You're welcome. The closest I get is Newcastle. But good luck with your project.

Sign in to comment.

More Answers (2)

Amith Kamath
Amith Kamath on 17 Jan 2013
For most tasks of analysing pixel values and thresholding, I've found http://www.mathworks.com/matlabcentral/fileexchange/6770 very useful.
You could use:
[levelLow bwLow] = thresh_tool(IM);
[levelHi bwHi] = thresh_tool(IM);
%to get the mask for each of the lower and upper level in bw.
depending on the datatype of your image, you can then just do an and operation between your image and the bw images.
  1 Comment
Demons
Demons on 17 Jan 2013
Hi buddy
Thanks for your response. Appreciate that.
But gosh that was huge! Have you any idea of a much simpler one?

Sign in to comment.


Jurgen
Jurgen on 17 Jan 2013
imshow(I,[6 249])
if it's a 2D image slice you want to visualize.
  1 Comment
Demons
Demons on 17 Jan 2013
hi bud
i've tried that before and nothing changed.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by