I have a dataset of images with bounding boxes. I also have another dataset of images with different backgrounds.

  1. I want to copy the images from one dataset (with their ground truth boxes) and paste them on the images of the other dataset with different backgrounds in order to increase my dataset size.
    Is this possible?

    So far I have come across algorithms which copy objects (using segmentation masks) from one algorithm to another but since I still don't have the segmentation mask information for my dataset, I can't use these.

  2. Is there any method from which we can obtain segmentation masks from bounding boxes?

  • $\begingroup$ I think this is better for SE post, not here. $\endgroup$ Jun 18, 2022 at 10:32
  • $\begingroup$ Asking for code written to your specification is explicitly off-topic here, and on StackOverflow, it would also lead to a closure for asking for a reference to existing software, libraries or products. So, I'll go ahead and remove that subquestion. $\endgroup$ Jun 18, 2022 at 11:16

1 Answer 1


You need a mask. That's literally what you want to do, only copy the object, not the whole rectangle containing it.

So, you need the info where the object is, and where it's not. That is the mask.

So, exactly, you'll need to find that. It's an image segmentation problem. Once you found a mask from the image data, you can use it to selectively copy parts of the original bounding box.

Is there any method from which we can obtain segmentation masks from bounding boxes?

No. I mean, a bounding box is a rectangle. The same rectangle could contain a witch or a duck, and the rectangle contains zero information on the shape of the object (aside from its maximum extent in two dimensions).

  • $\begingroup$ Thank you. What i get from your answer is that i cannot implement copy-paste with bounding box only and there is no way we can get masks from bounding boxes. Answers my search. $\endgroup$
    – Jav
    Jun 19, 2022 at 6:57
  • $\begingroup$ although if i still want to cut my bounding box(with an object) and paste it on another image, is it possible without generating masks? $\endgroup$
    – Jav
    Jun 19, 2022 at 8:58
  • $\begingroup$ well, if you just want to copy rectangle, do it! $\endgroup$ Jun 19, 2022 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.