Automatic ROI selection of edges in grey scale image of squares

2 vues (au cours des 30 derniers jours)
William
William le 9 Avr 2020
I am trying to programatically select regions of interest (ROIs) along each edge of the tilted squares in the attached image. I have tried using various functions in the image processing toolbox, and keep running into dead ends. For example, regionprops and thresholding will allow me to find the centroids or boundaries of the BW image, but the corners are difficult to detect (moreso after thresholding). I'd like to either reliably find the corners, which would allow me to set rectangular ROIs between corners, or find the straight edges, then directly set ROIs at the center of the edge. Any thoughts?
  2 commentaires
Image Analyst
Image Analyst le 10 Avr 2020
Why is the image out of focus in the first place? And why do you think you need perfect rectangles? Why can't you just deal with whatever shape it happens to be? To find vertices of rectangles, see my attached demo.
William
William le 10 Avr 2020
Modifié(e) : William le 10 Avr 2020
Thanks for the response. The image is representative of what I'm working with. I am trying to take images through focus to measure/calculate through focus MTF curves and batch process.
This particular image was taken with a lens system the exhibits some astigmatism. In practice, the ROIs will be need to be rectagular in order to specify an ROI that is along each slanted edge. I had looked through your demo previously, in the numVertices function, the vertices are enumerated by the greater of the number peaks or valleys, for some of the tilted squares in my image, the number of valleys are greater, so only 3 of 4 vertices are identified and the shape type is identified by the number of valleys instead. I think this is due to where in the shape the boundary cell array starts (where in the cyclic plot of peak or valley indexes) and the value set for MinPeakProminence. Is there a way to reliably find all of the corner vertices, rather than the greater of vertices vs flats (peaks or valleys in distance plot)?

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 10 Avr 2020
The number of peaks and valleys should be the same, but you have to take into account that the radii wrap[ around, so that if a peak is, say, close to index 1 and is rising from index 1 to wherever it is, then the other part of that peak (the left part) will also appear on the far right side of the plot and the last index in the signal may also be identified as a peak when it was actually part of the same peak as the one on the far left side.
One option is to threshold the blobs and then recognize that the max feret diameter is going to be at 45 degrees to the sides of the square. So you can then find the centroids from regionprops() and the feret diameter info from bwferet() and then take profiles along the edge perpendicular to the edge of the square using improfile(). Knowing the line spread function you can determine the MTF.

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by