How Matlab coder converts image to unsigned char
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Venkatesh
am 26 Mai 2014
Beantwortet: Ryan Livingston
am 28 Mai 2014
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 Kommentare
Akzeptierte Antwort
Ryan Livingston
am 28 Mai 2014
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!