Let your data be A.
A = 1:12;
B = reshape(A,4,[]);
B =
1 5 9
2 6 10
3 7 11
4 8 12
I = mat2gray(B); %converts the matrix A to the intensity image I
imwrite(I,filename,fmt)
题
I need to convert a data file into ppm/png/any other format using Matlab ? I have a data file having one column and 250000 rows of integer numbers, ranging from 0 to say 5. Data (say) in file are as follows:
2
1
0
5
2
1
3
.
.
.
0
5
1
4
I want to write these data into a image file say ppm, jpeg or any other format, how can I do it using Matlab ?
解决方案
Let your data be A.
A = 1:12;
B = reshape(A,4,[]);
B =
1 5 9
2 6 10
3 7 11
4 8 12
I = mat2gray(B); %converts the matrix A to the intensity image I
imwrite(I,filename,fmt)