Normalize image based on length of a line
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to normalize an image of a face based on the length between the top of the left ear and the inner point of the left eye. I use points collected from ginput(2) to create a line between the aforementioned points. But now I'm unsure of how to resize the full image to give the line specific dimensions.
I = imread(imgetfile);
%normalise: ear to inner eye point
image(I),title('Click on top of inner ear then inner eye')
[x,y] = ginput(2);
X1 = ceil(x(1,1)); Y1 = ceil(y(1,1));
X2 = floor(x(2,1)); Y2 = floor(y(2,1));
line = [X1:X2,Y1:Y2];
0 个评论
回答(1 个)
Image Analyst
2016-2-18
You know the length of the line you drew
lineLength = sqrt((x(1)-x(2))^2 + (y(1)-y(2)^2);
and you know the desired line length, in pixels. So just compute the ratio and pass in to imresize
scaledImage = imresize(originalImage, desiredLength/lineLength);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!