Normalize image based on length of a line
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 18 Feb 2016
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);
See Also
Categories
Find more on Image Processing Toolbox 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!