How Matlab coder converts image to unsigned char
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Venkatesh
le 26 Mai 2014
Réponse apportée : Ryan Livingston
le 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 commentaires
Réponse acceptée
Ryan Livingston
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Coder dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!