MATLAB: Matlab and Aptina ApBaseCOM Integration

apbaseaptina softwareimage preocessingmicron

Hello,
I have a Micron Camera and I tried to take some images from it and processing them. I am using the ApBase interface from Aptina Software but, when I try to get the image, I received a raw matrix and rgb and I cannot draw the image again.
I based on the guide https://aptina.atlassian.net/wiki/display/DEVS/ApBase+COM+Development+Guide I executed:
apbase = actxserver('apbaseCom.ApBase');
camera = apbase.Create(0);
camera.LoadIniPreset('', '');
raw = camera.GrabFrame;
rgb = camera.ColorPipe(raw);
i = reshape(rgb,2592,1944);
I attached a capture about the workspace. I do not know how interpret the values of the matrix i and when I use imshow(i) on it I am not getting the image.
The guide said that the output is normally 32 bits per pixel with B – G – R – X byte order. What is mean the "X"?
Regards, Matías.

Best Answer

It's a 32 bit (4 byte) image with the red, green, and blue values packed into the lower 3 bytes and the 4th byte unused and probably zero. You're going to have to mask and shift the value to extract the individual color channels. To mask, use the & operator to "AND" the array with 000000ff, 0000ff00, and 00ff0000. Then divide the upper byte images by 256 and 65536 to bring then down into the 0-255 range of uint8. But they may still be int32 or double at that point so you need to explicitly cast them to uint8 with the uint8() function.