convert images to binary with different gray level backgroung
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all !
I have the following code:
clc;
OriginalImage = imread('te3.jpg');
subplot(2,2,1);
imshow(OriginalImage);
g = rgb2gray(OriginalImage);
subplot(2,2,2);
imshow(g);
BW = imbinarize(g);
subplot(2,2,3);
imshow(BW);
% level = multithresh(g);
% I = imquantize(g,level);
% subplot(2,2,4);
% imshow(I);
I used two images, see the RESULT below:

the second image:

..
I wonder why this worked in images with dark gray background and didn't work with light gray background !
Can you please explain to me why ! And how can I make it works in the second image ..
Thank you !
0 comentarios
Respuestas (1)
Image Analyst
el 17 de Feb. de 2018
It may not know what you consider to be the background. For your computer graphics images, you can just take the upper left pixel and then threshold.
backgroundGrayLevel = OriginalImage (1,1);
brightStuff = OriginalImage > backgroundGrayLevel;
darkStuff = OriginalImage < backgroundGrayLevel;
nonBackgroundStuff = OriginalImage ~= backgroundGrayLevel;
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!