Converting CIE Lab image to binary
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Konstantinos Georgoulas
el 9 de Feb. de 2018
Respondida: Image Analyst
el 10 de Feb. de 2018
Hello,
I am trying to convert an image to binary. Initially, the image is in RBG and I convert it into CIE Lab and then I want to convert it into binary.
The reason for this is that I want to do visibility correction and determine the the area of visible seabed in images that were taken in different heights.
In CIE Lab the visible seabed falls along the red-green axis and as the distance from the seabed increases the amount of red in the image diminishes.
So I would be able to quantify this by converting the image to binary. The problem is that although I succesfully convert it from RGB to CIE Lab, I'm not sure that the function that I use to convert it to binary gives me what I want.
The script I'm using is:
clear
clc
%reading the RBG image
I = imread('image1.jpg');
figure; imshow(I);
%converting the RBG image to CIE L*a*b
colorTransform = makecform('srgb2lab');
lab = applycform(I, colorTransform);
figure; imshow(lab);
%converting the CIE L*a*b image to binary
BW = im2bw(lab, 0.4);
figure; imshow(BW);
%number of white pixels in the image
numWhite = sum(BW(:)) ;
%total number of pixels in the image
numberOfPixels = numel(BW);
%percentage of white pixels in the image
percentage = 100 * numWhite / numberOfPixels
Any help would be appreciated.
2 comentarios
Rik
el 9 de Feb. de 2018
Why aren't you using rgb2lab? Also, im2bw doesn't really support L*a*b, so it treats it as an RGB. There is nothing inherently wrong with your method, but you need to think about what it is you want to threshold.
Respuestas (1)
Image Analyst
el 10 de Feb. de 2018
It depends on how you define red. If any pixel has a non-zero red value, or a non-zero "a" value, then you can say there is some amount of red in that pixel. If you want to threshold to pick only pixels that have some minimum amount of red, then you can do that too, like
binaryImageOfRed = rgbImage(:,:,1) > someThreshold;
0 comentarios
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

