auto crop length of hand

2 次查看(过去 30 天)
jue xi
jue xi 2018-4-13
评论: jue xi 2018-4-13
hi. im doing a project to build an automatic system to detect length of hand from elbow to fingertips. first i read the image>filter>subtract background using k cluster. now i need to crop the image to get the hand length . the problem is if i crop the hand, it is not automatic system. how can i get the length of hand automatically? below is the coding #handcrop | | |
clear all
clc
A=imread('img1.jpg');
h=ones(5,5)/25;
A2=imfilter(A,h);
imshow(A2), title('H&E image');
text(size(A2,2),size(A2,1)+15,...
'Image courtesy of Alan Partin, Johns Hopkins University', ...
'FontSize',7,'HorizontalAlignment','right');
lab_A2= rgb2lab(A2);
ab = lab_A2(:,:,2:3);
nrows = size(ab,1);
ncols = size(ab,2);
ab = reshape(ab,nrows*ncols,2);
nColors = 3;
% repeat the clustering 3 times to avoid local minima
[cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...
'Replicates',3);
pixel_labels = reshape(cluster_idx,nrows,ncols);
imshow(pixel_labels,[]), title('image labeled by cluster index');
segmented_images = cell(1,3);
rgb_label = repmat(pixel_labels,[1 1 3]);
for k = 1:nColors
color = A2;
color(rgb_label ~= k) = 0;
segmented_images{k} = color;
end
imshow(segmented_images{1}), title('objects in cluster 1');
imshow(segmented_images{2}), title('objects in cluster 2');
imshow(segmented_images{3}), title('objects in cluster 3');
mean_cluster_value = mean(cluster_center,2);
[tmp, idx] = sort(mean_cluster_value);
blue_cluster_num = idx(1);
L = lab_A2(:,:,1);
blue_idx = find(pixel_labels == blue_cluster_num);
L_blue = L(blue_idx);
is_light_blue = imbinarize(rescale(L_blue));
nuclei_labels = repmat(uint8(0),[nrows ncols]);
nuclei_labels(blue_idx(is_light_blue==false)) = 1;
nuclei_labels = repmat(nuclei_labels,[1 1 3]);
blue_nuclei = A2;
blue_nuclei(nuclei_labels ~= 0) = 1;
imshow(blue_nuclei), title('blue nuclei');|||
  2 个评论
jue xi
jue xi 2018-4-13
编辑:jue xi 2018-4-13
this is the result after run the coding
jue xi
jue xi 2018-4-13
i need to get at least like this to crop the hand,

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by