Converting CIE Lab image to binary

조회 수: 5 (최근 30일)
Konstantinos Georgoulas
Konstantinos Georgoulas 2018년 2월 9일
답변: Image Analyst 2018년 2월 10일
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
Rik
Rik 2018년 2월 9일
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.
Konstantinos Georgoulas
Konstantinos Georgoulas 2018년 2월 10일
I don't really have any experience in image processing. To make myself more clear on what I want to do, I'll post two images. The first one is the original image in RGB.
And this one is in CIE Lab, the red colour is the visible seabed and I want to know what percentage of the picture has this red colour. Thus I want to convert it in binary to quantify it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2018년 2월 10일
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;

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by