Which variable stores contour image ?
Show older comments

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
Accepted Answer
More Answers (1)
Walter Roberson
on 7 Feb 2014
0 votes
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 Comments
Explorer
on 9 Feb 2014
Walter Roberson
on 10 Feb 2014
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.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!