MATLAB Answers

Find the boundary of any edge in an image .

11 ビュー (過去 30 日間)
Atreyee Mondal
Atreyee Mondal 2019 年 11 月 3 日
Edited: Atreyee Mondal 2020 年 1 月 8 日 7:39
i need to find the edge of an image.

  3 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 3 日
Input?
Image Analyst
Image Analyst 2019 年 11 月 3 日
No it's not. You deleted everything. Please respect Thiago's time to answer you, and put back the question and data.
Rena Berman
Rena Berman 2019 年 12 月 12 日
(Answers Dev) Restored edit

サインイン to comment.

件の回答 (1)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2019 年 11 月 3 日
編集済み: Thiago Henrique Gomes Lobato 2019 年 11 月 3 日
Your input is just the image, so I can't check the solution in your exact data, but this should either way solve your problem or at least guide you to a solution, I tried to let the code as commented as possible for you to be able to follow it:
% Here I generate a contour data, which you already have
t = 0:0.001:1;
x = cos(2*pi*t);
y = 2*sin(2*pi*t);
Angle = 2*pi*t*180/pi;
DistanceFromCenter = sqrt(x.^2+y.^2);
% From here on is the reconstruction process
% Get back x and y contour coordinates
xValues = DistanceFromCenter.*cos(Angle/180*pi);
yValues = DistanceFromCenter.*sin(Angle/180*pi);
% Create Image Template
SizeImg = 400;
Img = zeros(SizeImg);
% Map numerical x-y Values to an index
xMapped = xValues-min(xValues)+1; %% Shift image to minimum 1 so index is never 0
yMapped = yValues-min(yValues)+1;
NormFactor = max(max(abs(xMapped),max(abs(yMapped))));
xMapped = round(xMapped/NormFactor*SizeImg); % Scale to maximum
yMapped = round(yMapped/NormFactor*SizeImg);
% Create Binary Contourn substituing the discrete boundary points for 1
for idx=1:length(xMapped)
Img(yMapped(idx),xMapped(idx)) = 1;
end
% If you want the image filled, fill the holes (This will only work if you
% have enough angle information, otherwise the contour will have too many holes for
% a reconstruction)
ImgFilled = imfill(Img==1,'holes'); % Img==1 is to transform the image in a binary
% Plots
figure
% Real Contour
subplot(1,4,1)
plot(xValues,yValues)
title('Real Contour')
axis square
% Discrete Contour
subplot(1,4,2)
plot(xMapped,yMapped)
title('Discrete Reconstructed Contour')
axis square
% Generate Image Contour
subplot(1,4,3)
imshow(Img)
title('Image Contour')
% Filled Image
subplot(1,4,4)
imshow(ImgFilled)
title('Filled Image Contour')

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by