Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Matlab and OpenCV4Android - different Mat dimensions

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 (R = im(:,:,1) for the red channel, etc.): image description

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 map (using Core.BitmapToMat()). The channel split was done by Core.split(): image description

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.

Matlab and OpenCV4Android - different Mat dimensions

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 (R = im(:,:,1) for the red channel, etc.): etc.):

image description

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 map (using Core.BitmapToMat()). The channel split was done by Core.split(): image description

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. app.

Matlab and OpenCV4Android - different Mat dimensions

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 (R = im(:,:,1) for the red channel, etc.):

operations:

input_im = imread('Field.png');
R = input_im(:,:,1);
G = input_im(:,:,2);
B = input_im(:,:,3);

image description

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 map (using Core.BitmapToMat()). The channel split was done by Core.split(): :

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);

image description

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.

Matlab and OpenCV4Android - different Mat dimensions

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);

image description

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 map (using Core.BitmapToMat()). The channel split was done by Core.split()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);

image description

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.