Note that there are some explanatory texts on larger screens.

plurals
  1. POAffine transformation between contours in OpenCV
    primarykey
    data
    text
    <p>I have a historical time sequence of seafloor images scanned from film that need registration. </p> <pre><code>from pylab import * import cv2 import urllib urllib.urlretrieve('http://geoport.whoi.edu/images/frame014.png','frame014.png'); urllib.urlretrieve('http://geoport.whoi.edu/images/frame015.png','frame015.png'); gray1=cv2.imread('frame014.png',0) gray2=cv2.imread('frame015.png',0) figure(figsize=(14,6)) subplot(121);imshow(gray1,cmap=cm.gray); subplot(122);imshow(gray2,cmap=cm.gray); </code></pre> <p><img src="https://i.stack.imgur.com/XP2F3.png" alt="enter image description here"></p> <p>I want to use the black region on the left of each image to do the registration, since that region was inside the camera and should be fixed in time. So I just need to compute the affine transformation between the black regions.</p> <p>I determined these regions by thresholding and finding the largest contour:</p> <pre><code>def find_biggest_contour(gray,threshold=40): # threshold a grayscale image ret,thresh = cv2.threshold(gray,threshold,255,1) # find the contours contours,h = cv2.findContours(thresh,mode=cv2.RETR_LIST,method=cv2.CHAIN_APPROX_NONE) # measure the perimeter perim = [cv2.arcLength(cnt,True) for cnt in contours] # find contour with largest perimeter i=perim.index(max(perim)) return contours[i] c1=find_biggest_contour(gray1) c2=find_biggest_contour(gray2) x1=c1[:,0,0];y1=c1[:,0,1] x2=c2[:,0,0];y2=c2[:,0,1] figure(figsize=(8,8)) imshow(gray1,cmap=cm.gray, alpha=0.5);plot(x1,y1,'b-') imshow(gray2,cmap=cm.gray, alpha=0.5);plot(x2,y2,'g-') axis([0,1500,1000,0]); </code></pre> <p><img src="https://i.stack.imgur.com/yU88w.png" alt="enter image description here"></p> <p>The blue is the longest contour from the 1st frame, the green is the longest contour from the 2nd frame.</p> <p><strong>What is the best way to determine the rotation and offset between the blue and green contours?</strong></p> <p>I only want to use the right side of the contours in some region surrounding the step, something like the region between the arrows. </p> <p>Of course, if there is a better way to register these images, I'd love to hear it. I already tried a standard feature matching approach on the raw images, and it didn't work well enough.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload