hi .i'm new in matlab,plz how can i rotate all face images to be aligned vertically with same angle?
1 回表示 (過去 30 日間)
古いコメントを表示
i followed this procedure: detecting the eyes then computing both eye centers and getting the image center,lastly get the angle between three points ,plz,could you tell me the wrong with this code as it doesn't give the appropirate angle
if true
% code
%%To detect the Eyes
EyeDetect = vision.CascadeObjectDetector('EyePairBig');
%Read the input Image
I = imread('a7.jpg');
A=rgb2gray(imread('a7.jpg'));
center=size(A)/2+.5;
x0 = center(1:2:end);
y0= center(2:2:end);
BB=step(EyeDetect,I);
figure,imshow(I);
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
title('Eyes Detection');
Eyes=imcrop(I,BB);
figure,imshow(Eyes)
[a b c]=size(Eyes);
I1=Eyes(:,1:b/2);
figure,imshow(I1)
[Label,Total]=bwlabel(I1,8);
num=1;
Sdata=regionprops(Label,'centroid');
[x]= Sdata(num).Centroid;
centroids = [Sdata.Centroid];
x1= centroids(1:2:end);
y1 = centroids(2:2:end);
I2=Eyes(:,b/2:b);
[Label2,Total2]=bwlabel(I2,8);
num=1;
Sdata=regionprops(Label2,'centroid');
[y]=Sdata(num).Centroid;
centroids = [Sdata.Centroid];
x2= centroids(1:2:end);
y2 = centroids(2:2:end);
z=[x;y];
P0 = [x0, y0];
P1 = [x1, y1];
P2 = [x2, y2];
n1 = (P2 - P0) / norm(P2 -P0); % Normalized vectors
n2 = (P1 - P0) / norm(P1 - P0);
theta = atan2(norm(det([n2; n1])), dot(n1, n2));
D = rad2deg(theta );
I=imrotate(Eyes,theta);
figure,imshow(I)
0 件のコメント
回答 (1 件)
Image Analyst
2017 年 12 月 15 日
Use one of the two code chunks in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Then, inside the loop, you might want to call imwrite() if you want to save the rotated images to disk.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!