How Matlab coder converts image to unsigned char

5 次查看(过去 30 天)
Hi,
I am working on the code converted by Matlab coder, the coder converts the image to a single array of unsigned Char[....] according to the image size. I would like to use this converted unsigned array and split it into img[c][y][x] using python for another application. For this purpose. I would like to know how the Matlab coder combines the images. It would be great if someone could explain me regarding this.
Thanks and regards, Venkatesh

采纳的回答

Ryan Livingston
Ryan Livingston 2014-5-28
The generated code stores the array in column-major order just like MATLAB:
So, as you iterate over the char[...] array you will access the elements of the first column in order, then the second column and so on until you reach the last column in the sub array A(:,:,1). Then you will continue on to iterate over the columns of A(:,:,2) in the same fashion and finally over A(:,:,3).
You can see the order by executing the loop:
for k = 1:numel(A)
disp(A(k));
end
in MATLAB where A is your 3 dimensional array. This goes through the elements of A in the same order that they are stored in the generated code.
If you are using NumPy, note that the array types can be configured to be stored in row-major or column-major order by passing the order argument. You should be able to use order='F' to tell it to consider the array stored in Fortran or column-major order. For example:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by