-3

I have two images

one: is cropped image with dimension

another: is black image with different dimension

now i need to put the first image in center of the second image

any one can help me

thanks

HMA
  • 9
  • 4
  • Check for duplicates before posting questions: http://stackoverflow.com/questions/10481411/opencv-copy-an-cvmat-inside-a-roi-of-another – a-Jays Nov 05 '14 at 07:00

1 Answers1

1

Assuming black image is larger then cropped image and both images are same type and same channels:

cropped_image.copyTo(my_black_image(cv::Rect((my_black_image.cols - cropped_image.cols)/2, (my_black_image.rows - cropped_image.rows)/2, cropped_image.cols, cropped_image.rows)));
Pervez Alam
  • 1,246
  • 10
  • 20
  • but when i use this copyTo function i have an opencv error:assertion failed <!fixed size<>::<obj->size size core\src\matrix line 1392 – HMA Nov 05 '14 at 11:52
  • Is you black image larger than cropped image? Which version of OpenCV are you using? – Pervez Alam Nov 05 '14 at 11:56
  • i have fixed size for black image and a different size for cropped image, i need to make these cropped images in center and all with the same size without using resize function – HMA Nov 05 '14 at 11:59
  • Please see little update, I have checked the code and it is working fine. – Pervez Alam Nov 05 '14 at 13:46