# Color-based segmentation demo on the File Exchange3

Posted by Steve Eddins,

I have posted a few times about using L*a*b* space to do color segmentation. (See, for example, my 04-Feb-2011 post.)

For a different take on the idea, including a GUI tool for selecting a desired color region and for visualizing the segmentation results, see Image Analyst's new MATLAB Central File Exchange contribution, "Color segmentation by Delta E color difference."

### Note

khadeejah replied on : 1 of 3

hai steve . Am sorry am commenting here. I do not know hw else to ask you my question. I have this image which is an Ir image capturing veins. I want to retain just the veins as black and get rid of eveything else. This is what I have done till now .
figure(1),imshow(a);
cform = makecform(‘srgb2lab’);
for ii = 1:3
a(:,:,ii) = medfilt2(a(:,:,ii),[5 5]);
end
lab = applycform(a,cform);
figure(2),imshow(lab);
b=lab(:,:,1);
c=im2bw(b,0.2);
figure(3),imshow(c);
neg=1-c;
figure(4),imshow(neg);
color=a;
r=color(:,:,1);
r(~c)= 0;
g = color(:,:,2);
g(~c)= 0;
b = color(:,:,3);
b(~c)= 0;

color = cat(3,r,g,b);
figure(5),
imshow(color);
gray=rgb2gray(color);
figure(6),imshow(gray);

I want to make the backgroung white. And then somehow eleiminate the other parts except the veins . So how do I go about this ?? Sorry agin to comment here about this :(

Thank you

Steve replied on : 2 of 3

Khadeejah—I experimented for a few minutes with your image but did not get a promising result. I don’t think a color-based segmentation technique is going to be promising. Possibly you could use grayscale morphology operations with linear structuring elements oriented at different angles to emphasize and then segment the veins.

khadeejah replied on : 3 of 3

hai steve …. thank u so much …! :D I will try what you have suggested :D !