Reputation: 159
I am new in image processing and opencv. I have two images. I want to find correspond values in the image 2 with the image 1. and then show it. is there any function in opencv to find correspond values between images?
thanks in advance.
Upvotes: 1
Views: 299
Reputation: 4428
Mat corrVals;
bitwise_and(image2, image1>0, corrVals);
image1>0 will create temporary binary image with values 0 and 255. Than the only thing you need is to perform AND operation between pixels of your images, and store result somewhere. This is done by bitwise_and.
This is similar to approach suggested by @Mailerdaimon but uses much cheaper operations.
Upvotes: 4
Reputation: 12132
It is hard to say without looking at your images. This is a well studied problem in computer vision and OpenCV contains several algorithms for this. The problem you're looking at can be very easy or very hard, depending on:
You can start by looking at stereo matching and optical flow inside OpenCV.
Upvotes: 1
Reputation: 6080
You can threshold you image1 such that all Values you want are 1
and all other are 0
.
Than you multiply image1
with image2
.
cv::multiply(image1, image2, result, scale, dtype)
This will return an image with all values greater than zero from image2
that are marked in image1
.
Upvotes: 1