Can anyone tell me what does this code do and how does it work?
Show older comments
function segment = skin_seg2(I1)
% Convert image to double precision
I=double(I1);
[hue,~,~]=rgb2hsv(I);
% Ycbcr = rgb2ycbcr(I);
% % cb=Ycbcr(:,:,2)+128;
% % cr=Ycbcr(:,:,3)+128;
cb = 0.148* I(:,:,1) - 0.291* I(:,:,2) + 0.439 * I(:,:,3) + 128;
cr = 0.439 * I(:,:,1) - 0.368 * I(:,:,2) -0.071 * I(:,:,3) + 128;
[~ , ~]=size(I(:,:,1));
segment = 140<=cr & cr<=165 & 140<=cb & cb<=195 & 0.01<=hue & hue<=0.1;
segment=imfill(segment,'holes');
segment=bwmorph(segment,'dilate');
segment=bwmorph(segment,'majority');
Accepted Answer
More Answers (0)
Categories
Find more on Color Segmentation 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!