Converting CIE Lab image to binary

3 visualizzazioni (ultimi 30 giorni)
Konstantinos Georgoulas
Konstantinos Georgoulas il 9 Feb 2018
Risposto: Image Analyst il 10 Feb 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 Commenti
Rik
Rik il 9 Feb 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.
Konstantinos Georgoulas
Konstantinos Georgoulas il 10 Feb 2018
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.

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 10 Feb 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;

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by