Restrict regionprops to only fit ellipses within binary objects?

I am using regionprops to extract image properties of a binary image. I have a lot of uniquely shaped regions, which is why regionprops is struggling to fit ellipses to the white regions. How do I restrict regionprops to only fit ellipses within the white regions (1s) and not include any of the blue region (0s)? I have attached a picture of the results I get from regionprops for my binary image.

8 comentarios

Guillaume
Guillaume el 23 de Jul. de 2018
Editada: Guillaume el 23 de Jul. de 2018
This question, "How do I restrict regionprops to only fit ellipses within the white regions (1s) and not include any of the blue region (0s)" makes no sense. regionprops only uses the (foreground) white pixels when fitting ellipses, specifically, it uses the position of the pixels. What other fit would you expect in your example image?
In any case, regionprops does what it does, if you're not happy with that, you'll have to implement your own fit.
I was hoping to modify the fitting of the ellipses to either shrink them or change centroid location such that no background pixels are within any of the fitted ellipses. Right now I get a lot of background pixels within the fitted ellipses. I was just not sure where to start with that.
So, you want the largest inscribed ellipse within a likely non-convex polygon? As far as I know, even for a circle inscribed in a convex polygon, it's not trivial so what you're asking is probably very difficult. On the other hand, it's really not my area of expertise.
Whats your plan once you fittet the ellipses in a better way? If you want to extract the objects you could use the convex hull and set the area to the pixel edges. With that you might get less background into your shape, but background within a object would still be there.
I am trying to find a way to conservatively determine the sizes and centroids of the blobs I have without getting background pixels. I may try to generate multiple smaller ellipses within the objects.
Well, regionprops gives you the centroids and the size of objects, so why not simply use the features from regionprops to get those? You dont need the ellipses for that
From what I have seen, regionprops is including some background pixels in its sizing of the foreground objects, which is not what I want.
The 'Area' property returned by regionprop never includes background pixels. It is just the count of foreground pixels. Similarly, the 'Centroid' is the exact centroid of the foreground pixels according to the mathematical definition of the centroid. For a non-convex shape, the centroid may fall outside the shape.
The documentation of regionprops explains clearly how each property is calculated and if in doubt you can always look at the implementation since it's just a standard m file.

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 23 de Jul. de 2018

Comentada:

el 25 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by