imbinarize not working on given image
9 Ansichten (letzte 30 Tage)
So I have attached the image of coins I am using. I need to make this image black and white but it's just showing an area whole filled with white. When I run on coins.tif file provided in MATLAB, my code works fine but not on this image. Please tell me where I am going wrong. TIA
Image = imread('Coin.jpg');
[rows, columns, numberOfColorBands] = size(Image);
if numberOfColorBands > 1
grayImage = rgb2gray(Image);
grayImage = Image;
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
binaryImage = imbinarize(grayImage);
subplot(3, 1, 1);
subplot(3, 1, 2);
subplot(3, 1, 3);
The best binary image I could get is by using this line
binaryImage = imbinarize(grayImage,'adaptive','ForegroundPolarity','bright','Sensitivity',0.13);
But still I am getting numerous white dots here and there in the black area like this.
drummer am 1 Nov. 2020
Bearbeitet: drummer am 1 Nov. 2020
by using size, you're obtaining the dimension information of the image. So your 3rd coordinate (numberOfColorBands) would be the position in the stack (of a volumetric image), and not the # channels of your image.
info = imfinfo('yourImage')
% Then, use info in your if condition.