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 日
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
Image Analyst
2014 年 6 月 2 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
