Sorry, this content is no longer available

Ask Your Question
0

copy small image in big image

asked Aug 15 '14

Miro gravatar image

updated Aug 16 '14

i try to copy a small image stored in a Mat to a bigger image stored in a Mat. but i always end with a black big image. here is my code: JAVA

Mat no1 = Highgui.imread(Environment.getExternalStorageDirectory().getPath() + "/Pictures/no1.jpg");
Mat sudokuGrid = Highgui.imread(Environment.getExternalStorageDirectory().getPath() + "/Pictures/emptysudoku.jpg");
no1.copyTo(sudokuGrid.submat(new Rect(60 ,60 ,no1.width(), no1.height())));

Edit: When i use the code in C it works fine

small_image.copyTo(big_image(cv::Rect(x,y,small_image.cols, small_image.rows)));
Preview: (hide)

Comments

1

maybe you don't show enough code here. what is no1 ? a Mat has cols(), not width(). are you sure, both images have the same format/type() ?

berak gravatar imageberak (Aug 16 '14)edit

i added how i load the images

Miro gravatar imageMiro (Aug 16 '14)edit

i found a solution. will post it later :) ty berak!

Miro gravatar imageMiro (Aug 16 '14)edit

1 answer

Sort by » oldest newest most voted
1

answered Aug 20 '14

Miro gravatar image

no1.copyTo(sudokuGrid.submat(new Rect(x ,y ,no1.cols(), no1.rows()))); my fault was, not using cols() and rows()

Preview: (hide)

Question Tools

Stats

Asked: Aug 15 '14

Seen: 4,866 times

Last updated: Aug 20 '14