matlab中如何填入黑色,如何使用MATLAB将静脉保留为黑色?

我拥有捕获皮肤下静脉的Ir图像。我想要处理这个图像,以保持静脉为黑色,并将所有其他部分保留为白色。然后我想生成坐标像素作为这些黑色像素,这将是静脉。

这是我迄今为止所做的:

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;这是图像:

UtcwZ.jpg

那么在这之后我该如何继续下去,这样我就可以保持静脉为黑色,并且还有其他的东西像白色一样?

720d9e5ed53252842afb61600ad93c4b.png

因此,这是中值滤波后的图像,因为您可以看到静脉非常黑暗。那么,我应该如何从这里继续下去,以便将血管保留为黑色,其他一切都是白色的?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值