auto crop length of hand
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Segmentation and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!