1

I am trying to find the roughness of shapes in an image. I have found the contours and used simplification.cutil.simplify_coords_vwp(contour,1000) to calculate a polygon that I want to use as the "smooth" shape (this is similar to the more commonly used "Douglas-Peuker" algorithm). These shapes have ~13 points to them giving leeway to any bends. This is done for all of the shapes present in the full image.

The images below show the full image I want the roughness of and a zoomed in image showing what I am trying to calculate. I want to quantify the black inside of the lines and the white outside of the lines, giving a quantity to the amount of roughness. I didn't post the code because it would be a lot of extra information, I am only looking for help conceptualizing what modules could be useful here.

Full size image

Zoomed in

  • 2
    Please don't post pictures of images with axes and annotations; they are hard to load and analyse https://xkcd.com/2116/ – Mark Setchell Jan 22 '21 at 16:59
  • How do you post them without it? They were generated using matplotlib, is there a better module for displaying images? – Cameron Greenwalt Jan 22 '21 at 17:02
  • Sorry, I don't know. You haven't shown your code that produces them either, so I don't know what you have. – Mark Setchell Jan 22 '21 at 17:08
  • This plots the polygons: plt.plot(x,y). This plots the image: plt.imshow(polar_image). Then plt.show() is used without changing any parameters. – Cameron Greenwalt Jan 22 '21 at 17:09
  • The simplest thing that I can think of would be to crop out the contour and count the number of white pixels inside it. I'm not sure how good a measure of "roughness" this would be, but it'd be quick to implement and try out. If you want, you could also weight each white pixel by how far from the edge of the contour it is (i.e. white bumps that dip further into the image are penalized more). – Ian Chu Jan 22 '21 at 17:46
  • This might work, would there be a way to crop out the area around the contours? Then I could apply the same concept to quantify the black that's within the contour. – Cameron Greenwalt Jan 22 '21 at 19:17
  • 1
    So you’ve extracted boundaries, and then simplified them. Compare the boundary before and after simplifying, for example by computing the distance of each vertex in the original to the simplified boundary. – Cris Luengo Jan 23 '21 at 02:02
  • For anyone looking at this later, Cris' answer worked. – Cameron Greenwalt Jan 27 '21 at 15:51

0 Answers0