Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bitmap pixels from MATLAB to C

1 view
Skip to first unread message

coder two four four

unread,
Sep 2, 2010, 3:45:23 PM9/2/10
to
Hi

I would like to know the difference between and how to transfer pixel data of a 24 bit bmp from imread and to a shared C library function that expects pixel data. I have tried reshaping the array returned from imread and flattening out the 3 dimensions using typecast to int32 but I still do not get an image in the C function, just coloured lines.

Walter Roberson

unread,
Sep 2, 2010, 3:54:39 PM9/2/10
to

Is that "24 bit" 3 channels of 8 bits each, or is it 24 bits for each of 3
channels?

The information for each of the three channels for 1 pixel is not located near
the information for the other channels in memory: all of the information for
one channel appears, then all for the next channel, and so on. reshape() thus
does not put the three channels for a single pixel adjacent to each other. You
need to use permute() for that.

permute(ImageArray,[3 1 2])

This would put the channel information for each pixel adjacent to the other
channels in memory, taking the N x M x 3 array into a 3 x N x M array.
You could uint8() the result of permute and pass the resulting array in to the
C library.

0 new messages