Reputation: 30684
How might I go about compositing:
image A (8x8 RGB) with top left corner at (0,0).
image B (4x4 RGB) with top left corner at (6,6).
By simply adding RGB values?
I guess I need to start by creating a (black) RGB canvas of size (10,10), and add each image at its respective location.
But how to accomplish that second step?
Now what if the offset is (6.3, 6.3)? Is there a technique that handles sub-pixel superposition?
EDIT: cvSetImageROI
maybe?
Upvotes: 1
Views: 1919
Reputation: 23012
Why not use addWeighted()
to blend the images? You can create an ROI in the larger image the same size as the smaller image, and just add the result there.
You cannot do sub-pixel accuracy with built-in functions that I know of. What would the result at pixel (6,6)
be if you added an image that was only partially covering it? Would you want it weighted by the amount of overlap there is? And what about the pixel (7,7)
? In this case there would be four pixels crossing over; should each addition be weighted by the amount of overlap?
If you do want those pixels weighted as such, it would not be too difficult to define your own method, but it would be a little tedious as you'd have many cases: the corners, the sides, and the insides would each have different weightings.
Upvotes: 3