2

I have this Ir image that has captured the veins under the skin. I want to process this image so as to retain just the veins as black colour and get everything else as white. Then I want to generate the coordinate pixels as these black pixels which will be the veins.

This is what I have done till now :

a=imread('11.jpg');
figure(1),imshow(a);
title('original image');
cform = makecform('srgb2lab');
for ii = 1:3
    a(:,:,ii) = medfilt2(a(:,:,ii),[5 5]);
end
lab = applycform(a,cform); 
figure(2),imshow(lab);
title('ímage in color space after filtering');
b=lab(:,:,1);
c=im2bw(b,0.2);
figure(3),imshow(c);
title('b&white boundry of fist');
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;
% Concatenate in the "3rd dimension" to re-constitute an RGB image.
color = cat(3,r,g,b);
figure(5),
imshow(color);
title('reconstructed fist with black bg');
gray=rgb2gray(color);
figure(6);
imshow(gray);
title('grayscale of fist');

i1=imresize(gray,[256 256],'bilinear');
figure(7);
imshow(i1);
title('Resized Image of grayscale');

figure(8),imhist(i1);
title('histogram of resized grayscale');
i2=histeq(i1,256);
figure(9),imshow(i2);
title('histogram equalisatio');
figure(10),imhist(i2);
title('équalised histogram');
e=medfilt2(i2,[5 5]);
figure(7),imshow(e);
f=medfilt2(e,[5 5]);
figure(8),imshow(f);
g=medfilt2(f,[5 5]);
figure(9),imshow(g);
s=g;
figure(10),imshow(s);
l=imresize(s,[200 200]);
figure(11);
imshow(l);

[h,u]=size(l);
smth=double(l);
wl=1.5;
we=3;
wt=15;
eline=smth;;
[grady,gradx]=gradient(smth);
eedge=-1*sqrt((gradx.*gradx+grady.*grady));
figure(12);
imshow(uint8(-eedge));
m1=[-1 1];
m2=[-1;1];
m3=[1 -2 1];
m4=[1;-2;1];
m5=[1 -1;-1 1];
cx=conv2(smth,m1,'same');
cy=conv2(smth,m2,'same');
cxx=conv2(smth,m3,'same');
cyy=conv2(smth,m4,'same');
cxy=conv2(smth,m5,'same');
for i=1:h
    for j=1:u
        eterm(i,j)=(cyy(i,j)*cx(i,j)*cx(i,j)-2*cxy(i,j)*cx(i,j)*cy(i,j)+cxx(i,j)*cy(i,j)*cy(i,j))/((1+cx(i,j)*cx(i,j)+cy(i,j)*cy(i,j))^1.5);
    end
end
figure(13);
imshow(uint8(-eterm));
eext=(wl*eline+we*eedge+wt*eterm);
figure(14);
imshow(uint8(eext));
eext=(wl*eline+we*eedge);
figure(15);
imshow(uint8(eext));
whos eext;

and this is the image:

enter image description here

So how do I proceed after this so that I retain the veins as black and eveything else as white?

after median filtering

So this is the image after median filtering, as you can see the veins are quite dark. So how do I proceed from here so that the veins are retained as black and everything else as white?

HebeleHododo
  • 3,620
  • 1
  • 29
  • 38
khadeejah
  • 45
  • 1
  • 7
  • I dunno why my code is coming this way. I have posted each of it in different lines but it just appears as a continuous thing here :( – khadeejah Apr 24 '11 at 16:22
  • @khadeejah: Welcome to StackOverflow. To correctly indent your code, you need to either insert 4 spaces at the beginning, or block-select your text and click on the curly braces `{}` in the edit window. That will indent the code correctly. In future, please do not link images to personal blogs, as we'd like to keep it documented here. Otherwise, the post will have no context if you delete your blogpost. I know you don't have the rep to upload images using the site, so I've done it for you. But please do remember this in future. – abcd Apr 24 '11 at 16:39
  • Secondly, that is a _huge_ wall of code that you have posted. This is not rent-a-coder. While we are most willing to help you and point you in the right direction, we certainly don't have the time to dissect your code. So, I'd suggest trimming your code (for starters, you can remove all the titles, labels, etc) and reduce its bulk to a small set that describes the problem that you have. – abcd Apr 24 '11 at 16:46
  • Thirdly, you have given us the code to what you have done. But you don't tell us how far it has taken you... Do you manage to separate the veins at all? Does it come out red instead of black or are you getting more veins than there are? We don't know. So, telling us how far you've gotten in a more descriptive way (perhaps with images) and asking a pointed question will help you get better and faster replies. Also, since you mentioned in your other question that this was for a project, I've tagged it homework. – abcd Apr 24 '11 at 16:49
  • ans thank you @yoda for making my code alright and also adding the image.No i will not delete that blog post ever ...dont worry :D! – khadeejah Apr 24 '11 at 17:10
  • @khadeejah: No, I certainly am not pissed. I was just trying to point a new user in the right direction. I'm sorry if my tone sounded otherwise :) – abcd Apr 24 '11 at 17:10
  • he he @yoda ..homework it defnitely is :D ! – khadeejah Apr 24 '11 at 17:11
  • @ALL : edit : So with whatever I have done till now....after I have done median filtering and resizing the image; the veins are much darker than the rest of the palm.And then i tried using graythresh and converting it to black and white what happened is that the veins as well as the surrounding ended up black ! So how do i go about making just the veins black ? thank yoou ...! – khadeejah Apr 24 '11 at 17:15
  • @khadeejah: I hope you enjoy your experience here. You might not get _immediate_ answers, but the community is good here and you certainly will get _helpful_ answers if you're patient. Also, since this is homework, you'll most likely only get hints that point you to the solution and not the exact code. This, in my opinion (and the community's) is a good way to learn programming. So do not get disheartened if you don't find a complete code that does what you want among the answers. Feel free to comment on the answers, and ask for clarifications and upvote answers that were helpful to you. – abcd Apr 24 '11 at 17:16
  • hey @yoda .thnks fr helping me out!..can u please post the above comment in my question as edit ..? it says i cant as am not allowed 2 post imagess ???? – khadeejah Apr 24 '11 at 17:17
  • @ yoda yup i really like this site :D ! I have been working on this project for months now and just recenty ( read 2 days bak) discover this site ..its geat ..! Yup even simple pointers would defnitely ...:D ! I will try to code myself but I am just able to proceed after this point so need every and any sort of help :D ! – khadeejah Apr 24 '11 at 17:19
  • @khadeejah: You just need 10 reputation to add an image. I've upvoted your question so you now have 13 :) Please try now. – abcd Apr 24 '11 at 17:43
  • @ yoda ...Done ! i edited it :) hey are you personally good at image processing in matlab ? – khadeejah Apr 24 '11 at 17:49
  • @khadeejah: while I've used MATLAB extensively, I've only played around with image processing a little, and I'll leave it to others more knowledgeable to answer the question. BTW, when you reply to people, do not include a space between the `@` and the name, because if you do so, they won't receive the message. So, `@yoda` instead of `@ yoda`. [Here's](http://meta.stackexchange.com/questions/43019/how-do-comment-replies-work) more on that. – abcd Apr 24 '11 at 19:05
  • @yoda ..opps sorry ..i hoe this time I have done it correctly ..! :D – khadeejah Apr 24 '11 at 19:23

1 Answers1

-2

Once you have the second image, you will need to do image thresholding on it to get what you are asking for. You can implement it yourself or use graythresh from matlab (requires image processing toolbox).

Pavan Yalamanchili
  • 12,021
  • 2
  • 35
  • 55