Oct-27-2019, 11:30 PM
Hello, I have the following code in MATLAB which I am trying to convert to python, using numpy.
I'm unfamiliar with how to load a 3D matrix in python. Any help would be greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
M = zeros( 100 , 100 ); imageFiles = dir ( '*.bmp' ); nFiles = length(imageFiles); for i = 1 :nFiles currentFilename = imageFiles(i).name; f1 = fopen(num2str(currentFilename), 'rb' ); fread(f1, 13 , 'char' ); im = fread(f1, 100 * 100 , 'uint8' ); % currentImage = imread(currentFilename); % im = currentImage; for k = 1 : 100 for m = 1 : 100 NIM(i,k,m) = im((k - 1 ) * 100 + m); end end fclose(f1); end |