How Matlab coder converts image to unsigned char
3 ビュー (過去 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
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!