0

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 ?

Zero
  • 74,117
  • 18
  • 147
  • 154
ADK
  • 259
  • 2
  • 17

1 Answers1

2

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)
Zero
  • 74,117
  • 18
  • 147
  • 154
  • I have already found the same solution. It works perfectly. I should have posted it here. Anyways, thanks for the useful posting. – ADK Jul 09 '13 at 09:59