Matlab and OpenCV4Android - different Mat dimensions [closed]
Ther's a piece of code I should translate from Matlab to OpenCV4Android. Part of this code takes and RGB image and splits it. When I run the Matlab app, I can see that each of the splitted channels is of type uint8 and the dimensions are 376x640. In that case, the image was loaded by imread , and split by simple matrix operations:
input_im = imread('Field.png');
R = input_im(:,:,1);
G = input_im(:,:,2);
B = input_im(:,:,3);
When I run the Android app, after splitting the image (to RGBa first, it doesn't matter), I get that each channel is of type CV_8UC1 (which should be equivalent to uint8, If I'm getting it right), but the dimensions are 1128x1920 (which is multiplying the original dimensions by a factor of 3). The original image was with the same dimensions, but the type was CV_8UC4. The image was preloaded to an ImageView
and was converted to Mat
:
private Bitmap mBitmap;
private Mat mImToProcess;
// ...
mBitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
Utils.bitmapToMat(mBitmap, mImToProcess);
// ...
List<Mat> chans = new ArrayList<>(mImToProcess.channels());
Core.split(mImToProcess, chans);
I would like to now what makes this difference? And is there to work in my Android app with similar dimensions to the Matlab app.
can we see your code, doing that ?
I added it in the original question
perfect, thanks !
which size has the bitmap ?
it says 1128x1920 (h x w) - https://ibb.co/mvbEhw
so, there's nothing wrong with opencv's conversion, the problem is already in your imageView / bitmap.
you'll have to inquire, what you uploaded there, and how.
but how come the dimensions are different in the bitmap? in the Android app, the image is uploaded from the drawable directory, and it is the exact same image I use in my Matlab app
sorry, i have no idea.
ok, thanks for your help anyway