Convert matrix number into png image
16 ビュー (過去 30 日間)
古いコメントを表示
Hello i'm new on package "Image Processing Toolbox". I have a matrix of number ( http://dl.dropbox.com/u/59868217/matlab.mat) obtained by this script ( http://dl.dropbox.com/u/59868217/show_im_GR.m) I would be able to convert an image to grayscale or black and white. Possibly in png format.
How can I do ?
0 件のコメント
採用された回答
Image Analyst
2012 年 4 月 15 日
I looked at your m-file. You get your data like this:
A = fread(fid,size,'*uint16');
img = reshape(A,width,height); %ok-->poi trasponi
Did you know you can get the 2D matrix directly like this:
img = fread(fid, [width, height], '*uint16');
% It will be a 2D array after this.
No reshaping will be necessary. Anyway, to get it into PNG format you have to save it out to disk as a PNG format image file because when it's in MATLAB it's simply an array of numbers and format doesn't really apply.
baseFileName = 'My matrix.png';
fullFileName = fullfile(folderName, baseFileName);
imwrite(img, fullFileName);
0 件のコメント
その他の回答 (1 件)
Geppo Batt
2012 年 4 月 15 日
5 件のコメント
Image Analyst
2012 年 4 月 17 日
I just called them to see if you had integer or floating point values and if they were in the range 0-255, 0-1, or something else. which might cause me to call mat2gray() or uint8().
参考
カテゴリ
Help Center および File Exchange で Image Processing and Computer Vision についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!