how to apply vision function
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
i have a problem me want when face detect on the bases of skin color only face is in frame mee want to use vision function(Viola-Jones Algorithm). but am unable to do this i want to use vision function behaind the detetion buttion and only face is detected. see the image i hope understand my problem well

see in this image on detection part in 6th axes frame is on neck also ..me want only frame on face just using vision function ..can any one help me??? mee using matlab r2013a
채택된 답변
Image Analyst
2014년 6월 1일
0 개 추천
Try using imclose() to join small gaps. Then take the largest blob. If the neck is separated from the face, the face will be larger and you will extract only the face. bwconvhull() may also be of interest to you. See my attached demo for taking the N largest or smallest blobs.
댓글 수: 9
reema
2014년 6월 2일
my code behaind face detection button is:
function pushbutton2_Callback(hObject, eventdata, handles)
I=double(handles.I);
[hue,s,v] =rgb2hsv(I);
%a=rgb2hsv(I);
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;
[w h]=size(I(:,:,1));
for i=1:w
for j=1:h
if 140<=cr(i,j) && cr(i,j)<=165 && 140<=cb(i,j) && cb(i,j)<=195 && 0.01<=hue(i,j) && hue(i,j)<=0.1
segment(i,j)=1;
else
segment(i,j)=0;
end
end
end
im(:,:,1)=I(:,:,1).*segment;
im(:,:,2)=I(:,:,2).*segment;
im(:,:,3)=I(:,:,3).*segment;
binary=im2bw(im);
s=[0 0 0; 1 1 1 ; 0 0 0];
%s=[0 1 0; 1 1 1 ; 0 1 0];
dil=imerode(binary,s);
new12=im2bw(handles.I,0.15);
%Filling The Holes.
binaryImage = imfill(dil, 'holes');
%subplot(3,3,7); imshow(binaryImage);
binaryImage = bwareaopen(binaryImage,1890);
%subplot(3,3,8);imshow(binaryImage);
labeledImage = bwlabel(binaryImage, 8);
blobMeasurements = regionprops(labeledImage, 'all');
%******
numberOfPeople = size(blobMeasurements, 1);
axes(handles.axes4);
imshow(handles.I);
title('Face Detection','Color','black','FontSize',11,'FontWeight','bold');
%title('Outlines, from bwboundaries()');
%axis square;
hold on;
%boundaries = bwboundaries(binaryImage);
%for k = 1 : numberOfPeople
%thisBoundary = boundaries{k};
%plot(thisBoundary(:,2), thisBoundary(:,1), 'r', 'LineWidth', 2);
%end
% hold off;
axes(handles.axes4);
imshow(handles.I);
hold on;
%title('Original with bounding boxes');
%fprintf(1,'Blob # x1 x2 y1 y2\n');
for k = 1 : numberOfPeople % Loop through all blobs.
% Find the mean of each blob. (R2008a has a better way where you can pass the original image
% directly into regionprops. The way below works for all versionsincluding earlier versions.)
blobArea = blobMeasurements(k).Area;
if blobArea>2000
thisBlobsBox = blobMeasurements(k).BoundingBox; % Get list of pixels in current blob.
x1 = thisBlobsBox(1);
y1 = thisBlobsBox(2);
x2 = x1 + thisBlobsBox(3);
y2 = y1 + thisBlobsBox(4);
% fprintf(1,'#%d %.1f %.1f %.1f %.1f\n', k, x1, x2, y1, y2);
x = [x1 x2 x2 x1 x1];
y = [y1 y1 y2 y2 y1];
%subplot(3,4,2);
plot(x, y, 'LineWidth', 3);
end
end
guidata(hObject, handles);
axis equal;
axis tight;
axis off;
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
how can i embed this (extractbiggestblobe.m)code? how can i apply this
I'll show you how if you attach an image and make the above code into a script that opens the image and does the rest of your code. Then I'll add the code I gave you to extract the biggest blob. What I'll add is this code:
%--------------------------------------------------------
% Extract the largest area using our custom function ExtractNLargestBlobs().
% This is the meat of the demo!
biggestBlob = ExtractNLargestBlobs(binaryImage, 1);
%-------------------------------------------------
right after you got your binary image to make the binary image have only the largest blob and not any others.
sir i embed this code with my binary image code
%---------------------------------------------------------------------------
% Extract the largest area using our custom function ExtractNLargestBlobs().
% This is the meat of the demo!
biggestBlob = ExtractNLargestBlobs(binaryImage, 1);
%---------------------------------------------------------------------------
then this error show:
Undefined function 'ExtractNLargestBlobs' for input arguments of type 'double'.
me embed your recommended code like that check its right::
function pushbutton4_Callback(hObject, eventdata, handles)
I=double(handles.I);
[hue,s,v] =rgb2hsv(I);
%a=rgb2hsv(I);
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;
[w h]=size(I(:,:,1));
for i=1:w
for j=1:h
if 140<=cr(i,j) && cr(i,j)<=165 && 140<=cb(i,j) && cb(i,j)<=195 && 0.01<=hue(i,j) && hue(i,j)<=0.1
segment(i,j)=1;
else
segment(i,j)=0;
end
end
end
im(:,:,1)=I(:,:,1).*segment;
im(:,:,2)=I(:,:,2).*segment;
im(:,:,3)=I(:,:,3).*segment;
binary=im2bw(im);
%---------------------------------------------------------------------------
% Extract the largest area using our custom function ExtractNLargestBlobs().
% This is the meat of the demo!
biggestBlob = ExtractNLargestBlobs(binary, 1);
%---------------------------------------------------------------------------
axes(handles.axes3);
imshow(biggestBlob);
title('Binary Image','Color','black','FontSize',11,'FontWeight','bold');
guidata(hObject, handles);
axis equal;
axis tight;
axis off;
reema
2014년 6월 4일
sir tell me how to define the function ExtractNLargestBlobs()?????
reema
2014년 6월 4일
in the start of code of this button(binaryimage).me define:
function ExtractNLargestBlobs()
now no error show in command windaw but result not show..nothing done ..axes is empty .. tel me what the issue?
Image Analyst
2014년 6월 4일
Again, the same answer as your duplicate question. I wish I didn't have to answer in two places. You defined your own function and did not use mine. Your has no input or output arguments so of course it does nothing. Use the function I gave you.
sir tell me then how to define the function which me used..me used your recommended code
%---------------------------------------------------------------------------
% Extract the largest area using our custom function ExtractNLargestBlobs().
% This is the meat of the demo!
biggestBlob = ExtractNLargestBlobs(binary, 1);
%---------------------------------------------------------------------------
axes(handles.axes3);
imshow(biggestBlob);
thenthis error show :
Undefined function 'ExtractNLargestBlobs' for input arguments of type 'double' now tell me how to define it ..sorry sir i didn't get your point plz elabrate
Image Analyst
2014년 6월 5일
OK, let's end this thread . I don't want to keep answering the same thing in two different threads.
reema
2014년 6월 6일
okay sir me remove this one
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
