Which variable stores contour image ?
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156324/image.png)
close all;
clear all;
clc;
%Read the image, and capture the dimensions
img_orig = imread('C:\Users\Explorer\Documents\MATLAB\ASL_signs\A.jpg');
% % Create axes control.
% handleToAxes = axes();
% % Get the handle to the image in the axes.
% hImage = image(zeros(480,640,'uint8'));
% % Reset image magnification. Required if you ever displayed an image
% % in the axes that was not the same size as your webcam image.
% hold off;
% axis auto;
% axis on;
% % Enlarge figure to full screen.
% set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% annotation('textbox', [.2 .7 .3 .1],...
% 'String', 'Press Space Bar after placing your Hand in Bounding Box');
% % Turn on the live video.
% videoObject = videoinput('winvideo');
% preview(videoObject, hImage);
% hold on
% thisBB = [150 150 350 400]
% rect= rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],
'EdgeColor','g','LineWidth',2 )
% pause
% snap=getsnapshot(videoObject);
%
% stoppreview(videoObject)
% close all;
%
% cropped=imcrop(snap, thisBB)
% imshow(cropped)
%
%
% img_orig=cropped;
height = size(img_orig,1);
width = size(img_orig,2);
%Initialize the output images
out = img_orig;
bin = zeros(height,width);
%Convert the image from RGB to YCbCr
img_ycbcr = rgb2ycbcr(img_orig);
Cb = img_ycbcr(:,:,2);
Cr = img_ycbcr(:,:,3);
%Detect Skin
[r,c,v] = find(Cb>=77 & Cb<=127 & Cr>=133 & Cr<=173);
numind = size(r,1);
%Mark Skin Pixels
for i=1:numind
out(r(i),c(i),:) = [0 0 255];
bin(r(i),c(i)) = 1;
end
imshow(img_orig);
figure; imshow(out);
figure; imshow(bin);
%%Erode noise%%
imerode = imerode(bin, strel('square', 3));
figure,imshow(imerode);
%%Fill in holes to get fully connected skin regions%%
I = imfill(imerode, 'holes');
figure,imshow(I);
% imfill=~imfill;
% figure,imshow(imfill);
%
% Active Contour by chan-vase
m = zeros(size(I,1),size(I,2));
m(50:200,50:200) = 1;
seg = chenvese(I,m,1000,0.2,'chan'); % ability on gray image
% Built-in Mask
seg = chenvese(I,'medium',3000,0.02,'chan'); % ability on gray image
%-- End
0 个评论
采纳的回答
Image Analyst
2014-2-9
First of all you can extract the biggest blob to get just the hand. I'm attaching a demo to help you with that.
Next, you can then use bwboundaries() if you want all the coordinates of the hand outer perimeter exactly, or you can use activecontour, a built-in function, instead of that file exchange submission. I have a demo for that (on my other computer), if you're interested.
If you want to build up an image from the coordinates given to you by bwboundaries you can easily do that with a for loop:
contourImage = false(size(bin));
for k = 1 : length(xCoordinates)
row = int32(yCoordinates(k));
column = int32(xCoordinates(k));
contourImage(row, column) = true;
end
0 个评论
更多回答(1 个)
Walter Roberson
2014-2-7
None of the code you show produces that plot. The plot is likely put up within the showphi() routine that you did not provide source for. The key inputs to that routine appear to be I and phi0 within the chenverse routine, provided that the 'chan' or 'vector' options are given to it (you provide 'chan'). The phi0 variable is then returned from chenvese, where it becomes your variable "seg"
3 个评论
Walter Roberson
2014-2-10
There is no variable in the code that stores the image you have circled. The image you have circled is made by displaying the image, then "hold on", then using contour() of the value returned as "seg" from chenverse, using [0 0] as the contour level set. The same contour is drawn twice with two different colors and two different line widths - red in linewidth 4, green in linewidth 1.3.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!