Reputation: 716
I have a array containing data. This array contains only image data/ or it can be just random data. No header information is available. So writing this to a file and making its extension as jpg is not going to work. Can someone please recommend a library that would do this for me.
Any language that isnt a scripting language is ok. Any environment. I would prefer if its in C/Java/Matlab.
Upvotes: 0
Views: 275
Reputation: 24127
If you have your array in MATLAB (let's say it's in a variable called im
), then you can just type
imwrite(im, 'myfilename.bmp', 'bmp')
and your array will be written to a .bmp file. You can choose from a number of other common formats too. See the documentation for imwrite
.
You can even write random data in this way:
a = rand(100,100);
imwrite(a,'testimg.jpg','.jpg')
Upvotes: 2