필터 지우기
필터 지우기

how to join points at the edges of a face on an image using a curve?

조회 수: 1 (최근 30일)
Manoj Murali
Manoj Murali 2012년 2월 16일
편집: Jesus 2013년 10월 15일
Hi.Suppose i have a face image with 3 selected points at the edges.One point is at the chin edge,another is the right cheek edge and another is at the left cheek edge.Now i wanted to join these three points along the edges of the face using a curve.So that it appears like a 'U' shape on the edges of the face.How cud i do this...Any one plz help..??

답변 (3개)

Manoj Murali
Manoj Murali 2012년 2월 16일
Any answer wud b appreciated.Thank u..

Manoj Murali
Manoj Murali 2012년 2월 17일
What am gonna do is to first i ll use ginput to get the (x,y) coordinates of those three points.Then i ll mark those points as a dot using the plot fun on the image at those three points for our reference to see the selected points on the image.Now i wanted to join these three dots which are at the edges using a cure..I donno how to do this last part..can anyone suggest me something..??

Image Analyst
Image Analyst 2012년 2월 17일
You might try my spline demo:
% function SmoothSplineCurve()
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen.
set(gcf,'name','Spline Demo by ImageAnalyst','numbertitle','off')
axis([0 10 0 10])
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
title('Spline Demo', 'FontSize', fontSize);
hold on
% Initially, the list of points is empty.
knots = [];
numberOfPointsClicked = 0;
% Prompt the user
message = sprintf('Left click to draw some vertex points.\nRight click the final point to finish drawing.');
uiwait(msgbox(message));
buttonThatWasClicked = 1;
% Enter a loop asking user to click on the knot vertexes.
while buttonThatWasClicked == 1
[xKnot, yKnot, buttonThatWasClicked] = ginput(1);
plot(xKnot, yKnot, 'ro', 'LineWidth', 2)
numberOfPointsClicked = numberOfPointsClicked+1;
% Make this coordinate a new column.
knots(:, numberOfPointsClicked) = [xKnot; yKnot];
end
% Calculate the area within the blue spline curve.
% You do not need to connect the last point back to the first point.
x = knots(1, :);
y = knots(2, :);
areaOfPolygon = polyarea(x,y);
% Interpolate with a spline curve and finer spacing.
originalSpacing = 1 : numberOfPointsClicked;
% Make 9 points in between our original points that the user clicked on.
finerSpacing = 1 : 0.1 : numberOfPointsClicked;
% Do the spline interpolation.
splineXY = spline(originalSpacing, knots, finerSpacing);
% Plot the interpolated curve.
hold off;
plot(knots(1, :), knots(2, :), 'ro',...
splineXY(1, :), splineXY(2, :), 'b+-', 'LineWidth', 2, 'MarkerSize', 16);
title('Blue Spline Between Red Knots', 'FontSize', fontSize);
legend('Knots', 'Spline');
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
grid on;
hold off;
% Calculate the area within the blue spline curve.
% You do not need to connect the last point back to the first point.
x = splineXY(1, :);
y = splineXY(2, :);
areaInsideSplineCurve = polyarea(x,y);
% Give the area calculations.
message = sprintf('The area inside the polygon you drew is %.2f.\nThe area inside the blue spline curve is %.2f', ...
areaOfPolygon, areaInsideSplineCurve);
fprintf(1, '%s', message); % Print to command window.
msgbox(message); % Show user via a popup message box.
  댓글 수: 5
Image Analyst
Image Analyst 2013년 1월 15일
Yes. You'd have to call imline to burn lines between the knots into the image. Search for imline - I've posted demos on that before. If no luck, then paste this code, or your code, and ask in a new thread.
Eric Franck
Eric Franck 2013년 1월 15일
Thanks man, imline, how could i possibly hv missed that ! you are truly an Image Analyst genius! thanks again for your quick reply.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by