How Matlab coder converts image to unsigned char

조회 수: 3 (최근 30일)
Venkatesh
Venkatesh 2014년 5월 26일
답변: Ryan Livingston 2014년 5월 28일
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