I have an image of a vein as shown below. I use the watershed algorithm to extract the skeleton of a vein.
My code: (K is the original image).
level = graythresh(K); BW = im2bw(K,level); D = bwdist(~BW); DL = watershed(D); bgm = DL == 0; imshow(bgm);
Result:
As you can see, a lot of information is lost. Can anybody help me? Thank.
, . . , , , ( ). , , , .
%# Load image and convert to [0,1]. A = im2double(imread('http://i.stack.imgur.com/TQp1i.png')); %# Any large (relative to objects) structuring element will do. %# Try sizes up to about half of the image size. se = strel('square',32); %# Removes uneven lighting and enhances contrast. B = imdivide(A,imclose(A,se)); %# Otsu method works well now. C = B > graythresh(B); D = bwdist(~C); DL = watershed(D); imshow(DL==0);
C (), DL==0 ( ) :
C
DL==0
, ( , Otsu). , , , . , , .
, -
w=gausswin(N,Alpha) % you'll have to play with N and alpha K = imfilter(K,w,'same','symmetric'); % something like these options
.
, , im2bw, uint8, intmin('uint8')==0 intmax('uint8')==255, ( logical). , , . BW, , K, level, , , , .
im2bw
uint8
intmin('uint8')==0
intmax('uint8')==255
logical
BW
K
level