Overlay two images
I am trying to compare two images to assess their registration. I would like to overlay the two images using a checkerboard type pattern, where (say) the top left 20 x 20 pixel patch displays the first image, and then alternates between image one and two.
I have written a similar script in Matlab which involved displaying one image on top of the ot开发者_JAVA技巧her, and then applying a checkerboard transparency to the top image. Is this possible in OpenCV?
The fastest way for you:
- Create checkers board on matlab.
- Save it as png/bmp image (no compression)
- Load this image in opencv and use it as mask
- Use cvAdd on the images using the loaded mask
P.S. You can write the chessboard mask creator in openCV but if you need it only for debug then save yourself this task and use matlab
You can certainly mess with the alpha channel manually in a double for loop over the images.
I'd actually like to propose an alternative for testing registration which may be even more sensitive. You can take gray scale representations of each image (convert to gray if they are originally color) and put them into different color channels of a new image. Say img1 in R and G while img2 goes into B. Then, you can display the new image. Any mis-registered region would show up in color while correctly registered parts are gray.
精彩评论