Better algorithm than MultiRANSAC for finding ellipses in powder diffraction images?

I am working on a project that accepts powder diffraction images and tries to find all the elliptical rings in the image.

I use the RANSAC algorithm, which is suitable for an ellipse for data, then subtracts these points (inserts) and changes to another ellipse until the coefficient of a lower value becomes sufficiently small.

My problem is that it is either suitable for more ellipses than it should be or not enough, based on how I set the threshold distance.

I am wondering anyway to improve RANSAC to be more accurate or is there a better algorithm I should use?

RAW IMAGE Raw image

THRESHOLD DISTANCE BY 5 Threshold set to 5

THRESHOLD DISTANCE TO 10 Threshold set to 10

+5
source share
1 answer

I don’t have a basic knowledge of the process you are dealing with, but it looks like all the ovals (it’s hard to say if they are really ellipses) are concentric, so I would try to increase the accuracy:

  • Find a center

    or approximate. Let us call it x0,y0 and allow the resolution of the image xs,ys . Either you already know your position (due to the knowledge of your image properties), or evaluate it (scan one oval and find two lines passing through the entire oval, their intersection is your center). If the center is not accurate, the result will be more like ovals and then ellipses, but it doesn’t matter that you can restore the original image taken from a non-show and / or recompose the center from the latest data ...

  • Cast beam from (x0,y0) to (xs-1,0)

    and copy the contents of the image along it into some cleared line buffer of size xs+ys , to be sure, to cover any central position with a reserve ...

  • Integration of the entire image with rays

    therefore cast rays are always from (x0,y0) to (xs-1,1),(xs-1,2)...(xs-1,ys-1) , then (xs-2,ys-1),...(0,ys-1) , etc., to cover the entire circumference of the image. Find out the ratio of the scale to the original saved line (most peaks should match) and add the scaled image content by rays to the buffer of the stored line.

    Remember the scale for each angle used.

    After covering the entire image, divide the line buffer by the number of rays used so that you average the slice through oval rings with a lot of noise for the lover. Now just find the peaks in it. Each peak is a separate oval, and its position gives you a radius at the initial angle of the beam.

    Scales give oval / elliptical properties. So, find the minimum and maximum scale that gives you the angles at which the major and minor axes are important ... The peak scale itself gives you the axis size ... Therefore, there is no need for RANSAC (but you can use it to calculate scale).

    rays

[Note]

To avoid appearing in the middle row, you can add a counter for each pixel in it, keeping the number of rays added to each pixel and use them for the final split.

Also, these QAs may help a little:

[Edit1] additional information

I was curious, so I made an attempt (proof of concept). I resized the image to 512x512 so that it fits into the window to simplify the visual inspection and manually set the center as (133,285) Then create an integration of all the rays (without scaling at the moment), and then partially restore the image:

partial

view of the sun as a reconstructed image from the integrated midline, and the rest is the original image. Since you can see that these two fixtures are almost perfect, so your ovals are almost circular (or circular, and I'm a little centered).

The aqua plot is the intensity (y axis) relative to the center of the distance shape of the integrated midline. Each peak represents one circle. This way you can find circles in 1D data, not in 2D. Here's a completely reconstructed image without any debugging drawings:

full

Be that as it may, scaling is not suitable for this, and instead use correction (+/- a few pixels from the previous previous ray offset). Let’s try to try if you get more time for this ...

[edit2] more precise center and more information

The closer you are to the center, the sharper and larger bursts are present in the midline. It can be used to precisely fit the center (I use this and found out that I am disabled by 1 pixel on the x axis, which is very good for manually selecting the center ...). After that, scaling or shifting is not required, since the ovals are circles. Then simply compare the moving average of the midline (Aqua chart) and determine only the positive bursts (blue chart):

detection

Each peak represents a circle (the radius is the distance from the center, which is also the address in a linear array in pixels), so just emit intensity pulses and output circles ...

circles

And after applying peak detection and full integration accuracy:

thin circles

+2
source

Source: https://habr.com/ru/post/1262257/


All Articles