Borrar filtros
Borrar filtros

Measure the lengths of a polygon

6 visualizaciones (últimos 30 días)
Avri
Avri el 28 de Jul. de 2013
How to measure the length of the sides in polygon at BW image? Obviously that the polygon is not ideal (it’s a picture) Note that the polygon is filled (background is "0" and polygon and its inside is "1")

Respuesta aceptada

Matt J
Matt J el 28 de Jul. de 2013
You can use bwboundaries() to find the bounary pixels and then maybe this FEX file to fit it to a polygon
I wonder, though, what created the binary image and whether geometric info about the polygon was used for that. If so, it would make sense to use that geometric info instead.
  1 comentario
Image Analyst
Image Analyst el 30 de Jul. de 2013
I didn't try it yet, but from the author's description, it sounds like what's usually called the "restricted convex hull" ( http://www.liacs.nl/~fverbeek/courses/iammv/scil_ref.pdf) or the "concave hull" ( http://ubicomp.algoritmi.uminho.pt/local/concavehull.html). I'm not sure this would answer the original poster's question though. Actually any irregular blob could be considered a polygon, even a circle since it's composed of discrete points, though a lot of them. So one way would be to simply call bwperim() and sum the image.
polygonOutline = bwperim(binaryImage);
polygonLength = sum(int32(polygonOutline(:)));
Of course the usual way is to call regionprops() and ask for the perimeter, or else you could calculate it yourself by walking along the coordinates returned from bwboundaries() summing up all the lengths (1 or sqrt(2)) going from one pixel to the next. (My answer below was assuming you wanted to decompose the blob into a few straight sides, like 4 or 6 sides or whatever.)

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 28 de Jul. de 2013
Use bwboundaries() to get the (x,y) coordinates of the outer perimeter. Then use the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_find_.22kinks.22_in_a_curve.3F, which points to an Answers posting where I gave demo code.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by