change pixel colour / intensity from black to white, white remains white, and from other colour to black
4 views (last 30 days)
Show older comments
hi there. I need to segment the stroke in the ct scan image of the brain below. what i need to do before the segmentation is change the stroke color to the only black intensity in the image. the command in written form is
if pixel value = 0, change to 1, if pixel value = 1, maintain to be 1, if pixel value not 0 and 1, change to 0.
the problem is, i do not know how to write the matlab code represents them. please anyone, help me.. thank you in advance.
note: the image is in RGB. do we need to change to gray..?
Accepted Answer
Walter Roberson
on 10 Jan 2013
Edited: Walter Roberson
on 10 Jan 2013
YourRGBImage = imread(....); %or dicomread() as appropriate
GrayImage = rgb2gray( im2double( YourRGBImage ) );
BWImage = (GrayImage == 0 || GrayImage == 1);
More Answers (1)
Image Analyst
on 10 Jan 2013
grayImage = rgb2gray(rgbImage);
binaryImage = grayImage <= 1
5 Comments
Image Analyst
on 10 Jan 2013
So the stroke is not 0 or 1 like you said. It's a thin white sliver of pixels in your image, with a gray level like 30 or 40 thousand. This is totally different than what you asked. But it looks like you've realized that and got it solved now since you accepted an answer. So that's all that counts. Best wishes.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!