3

I took about 220 images of the partial solar eclipse today and plan to put together a timelapse animation of the event. As expected the image of the partially eclipsed Sun jumps around a bit and I need to register the shots before making the animation.

Here are sample photos:

http://www.trivalleystargazers.org/gert/sofi_141023/sofi.htm

I would like to center the images on the Sun which is obviously a segment of a circle during the eclipse. I guess the Moon would be a distraction for the algorithm (I don't want to center on the Moon). I have some knowledge on Python and none on opencv.

Is there an easy way to find the Sun in the images and center it to approx. 1pixel accuracy? Is opencv + python the proper approach at all? Are there particular tricks to work out to get to the best result?

Thanks & Clear Skies, Gert

Gert Gottschalk
  • 1,658
  • 3
  • 25
  • 37
  • 1
    Similar question here: http://stackoverflow.com/questions/20698613/detect-semi-circle-in-opencv – Andrey Smorodov Oct 24 '14 at 08:05
  • Can you try to detect the circles with HoughCircle method? Maybe you can choose the biggest/most-centered circle as a heuristic instead of addressing the "semi circle" part explicitly. – Micka Oct 24 '14 at 08:28
  • I guess that doing this manually will save your time in this case. – jb. Oct 24 '14 at 10:13

1 Answers1

1

You can try this:

  • threshold the image
  • get the largest contour
  • find the minimum area circle that encloses this contour

Once you find the center and radius, it'll be easier to register. If the radii are different between snapshots, you'll have to resize all circles to a predefined size and adjust the center accordingly in the registration phase.

I tried this in OpenCV and C++.

    Mat im = imread(INPUT_FOLDER_PATH + string("SoFi_400_20141023_163450.jpg"));

    Mat gray;
    cvtColor(im, gray, CV_BGR2GRAY);

    Mat bw;
    threshold(gray, bw, 0, 255, CV_THRESH_BINARY|CV_THRESH_OTSU);

    vector<vector<Point>> contours;
    vector<Vec4i> hierarchy;
    findContours(bw, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
    /* in actual implementation you'll have to find the largest contour. 
    here i'm just assuming i get one and it's the largest*/
    for(int idx = 0; idx >= 0; idx = hierarchy[idx][0])
    {
        Point2f center;
        float radius;
        minEnclosingCircle(contours[idx], center, radius);
        cout << idx << " (" << center.x << ", " << center.y << ") : " << radius << endl;

        circle(im, Point(center.x, center.y), radius, Scalar(0, 255, 255), 2);
    }

    imshow("", im);
    waitKey();

Some results:

enter image description here enter image description here

dhanushka
  • 10,492
  • 2
  • 37
  • 47