AB comparison wipe between two images

I want to do an A-B comparison between two image by wiping from image A to image B controlled by mouse motion.

A-B comparison between two image by wiping

what is that ? comparing what, exactly ? wiping ?
please explain !

it’s nice that you have goals but perhaps you meant to ask a question as well.

1 Like

I thought it was obvious. I’m looking for sample code to do an A-B comparison between two images by moving the mouse back and forth across the image. Mouse on the left edge, full right image displayed . Mouse on the right edge, full left image displayed. As the mouse moves between the left and right edges, the opposite image is displayed proportionally as a function of the mouse position.

We see this all the time, even in web browsers.

There has to be some reference code lurking in the OpenCV GUI code base to do this.

That’s my question. Is GUI code available to do this?

what you’re asking is usually not done with OpenCV, or people just implement that right quick and don’t think to “display” it like it’s anything special.

all you need is a setMouseCallback, the blending logic, and imshow, in the event handler. and waitKey of course, in the main loop.

there is documentation and example code on all the GUI stuff on https://docs.opencv.org and there are examples for blending images.

Thanks for getting back to me.

I’ll roll up my sleeves and write some code. I’ll post it.

sounds more like blending 2 images with a gradient, not comparison at all.

this Comparing two images using a wiper

and since that doesn’t even do any blending, just composing, that’s even simpler. take a subregion of one image and copyTo it into the same subregion of the “canvas”/composited image

That sounds like a better idea that a per scan line pair of for loop copies.

Here is a website with a wipe AB image compare:


I’m embarrassed to say it was just a few lines and quite simple.