Error with bwtraceboundary function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ttopal
el 14 de Feb. de 2017
Comentada: ttopal
el 14 de Feb. de 2017
Hi all,
I have a function where I have a set of x,y coordinates for points to a contour as input. I calculate its derivatives using spline interpolation. When I take ellipse or circle, i can manually calculate 8 points on contour and use this. But When I draw an arbitrary shape like this:
i need to get a point set first. It seems to me that bwtraceboundary is the function that i need to use, here is the code that i write; i check the beginning points with pixelinfo
I = imread('example3.png');
figure(1)
imshow(I)
BW = im2bw(I);
figure(2)
imshow(BW)
impixelinfo
contour = bwtraceboundary(BW,[r c],'W',8,Inf,'counterclockwise');
figure(3)
imshow(I)
hold on;
plot(contour(:,2),contour(:,1),'g','LineWidth',3);
it gives me an empty contour.
Actually as I will always have a two color picture and one boundary there might be an easier way.
Any suggestion?
Respuesta aceptada
Walter Roberson
el 14 de Feb. de 2017
The [r, c] you supply needs to be a point that is on the boundary. You do not show how you set [r, c]
You can use find() to locate a pixel.
3 comentarios
Walter Roberson
el 14 de Feb. de 2017
Yes you need to reverse your mask so that the boundary is 1 and the background is 0
Más respuestas (0)
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!