How to do a binarization of this image?

Dear all,
Please, can anybody tell me, how to do a binarization of this image?
Step by step please, I´m new in this section.
Thank you for your answers.

 Risposta accettata

You can threshold, like
grayImage = rgb2gray(yourRGBImage);
binaryImage = grayImage > someThresholdValue;
imshow(binaryImage);

3 Commenti

Still I have this error:
Error using rgb2gray>parse_inputs (line 81)
MAP must be a m x 3 array.
Error in rgb2gray (line 35)
X = parse_inputs(varargin{:});
Error in binarizaceopetazase (line 3)
grayImage = rgb2gray('thorax-mdl.jpg');
You need to pass it a numerical array, not a character array (the filename string). imshow() can work like that but not rgb2gray. Try
grayImage = imread('thorax-mdl.jpg');
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Convert it to gray scale by taking only the green channel.
grayImage = grayImage(:, :, 2); % Take green channel.
end
Finally, it´s working.
Thank you.

Accedi per commentare.

Più risposte (1)

George
George il 8 Set 2016
Take a look at this example and im2bw.

3 Commenti

Thanky you for link.
I tried this, but this part of code doesn´t work.
I3 = imadjust(I2);
imshow(I3);
It always appears this type of error.
Error using imadjust>parseInputs (line 207)
Specified syntax IMADJUST(I) is only supported for 2-D grayscale images. Additional input arguments are required for use
with RGB images.
Error in imadjust (line 97)
parseInputs(varargin{:});
Error in binarizace_image_dalsi_pokus (line 14)
I3 = imadjust(I2);
What is wrong? Thank you for your answer.
It's saying that your image isn't grayscale. Take a look at this example.
Then why did you accept the answer if it's not working?

Accedi per commentare.

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by