Normalize image based on length of a line

1 visualizzazione (ultimi 30 giorni)
Ryan Snowden
Ryan Snowden il 18 Feb 2016
Commentato: Ryan Snowden il 18 Feb 2016
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];

Risposte (1)

Image Analyst
Image Analyst il 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);

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by