Ask Your Question
0

copy small image in big image

asked 2014-08-15 13:08:11 -0500

Miro gravatar image

updated 2014-08-16 05:35:10 -0500

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)));
edit retag flag offensive close merge delete

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 ( 2014-08-16 04:35:40 -0500 )edit

i added how i load the images

Miro gravatar imageMiro ( 2014-08-16 05:38:08 -0500 )edit

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

Miro gravatar imageMiro ( 2014-08-16 11:32:58 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-08-20 07:02:29 -0500

Miro gravatar image

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

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-08-15 13:08:11 -0500

Seen: 3,575 times

Last updated: Aug 20 '14