Assigning "variable names" to regions in a picture and replacing them with parts of other pictures

Hi there,

From the get-go, I would like to emphasise the fact that I am new to Python and Open CV.
I am therefore looking for hints, clues and best practices to achieve my present goal.

I would like to be able to replace some predefined regions in a picture with parts from another picture.
Say we have a series of 10 images.
I would like to be able to label (or tag, for lack of a better word) some regions, say regionA and region B in each of those images.
Now, consider two parts of some other images, say dest A and dest B.
I would like to be able to replace Region A and Region B in those 10 images, with dest A and dest B respectively.
It is a bit like assigning variable names to some regions in an image (Region A and Region B), and then assigning a different value to those variables ( dest A and dest B).

Thanks for any guidance, comments or constructive critics, and especially best practices, to achieve this.


in python, this is not even an opencv specific problem

Hi there,

Thanks for your suggestions with the numpy arrays.
I will definitely look into this.
I would like to insist though, with my question.
Say you have a page with 6 pictures.
In each picture, you want to be able to identify a specific face and replace it with another one.
That is probably more in line with what I mean.
Instead of a face, it could be a specific animal, say a cat, that you would like to replace with a specific dog, etc…
Would that be considered as an opencv-related question?

Many thanks

that wasn’t a “suggestion”, that was the answer to “how do I replace a part of a picture”.

finding the regions is a separate problem. and then you’d probably want to decide what image to overlay, and then you’d need to resize that to fit in the given area.

maybe you’d also like to do that with transparency because if you don’t, you’ll get rectangular areas only.

if you’d take a step or two towards implementation, that would be good. we aren’t ChatGPT, if I may be so blunt.

it’s called: Machine learning. you want to learn ALL about it !
(and btw, offers nice courses on this !)