フィルターのクリア

How to convert image to array and save it in a text file?

15 ビュー (過去 30 日間)
Ali Purse
Ali Purse 2018 年 10 月 18 日
回答済み: Image Analyst 2018 年 10 月 18 日
I want to save an image's array to a text file in order to show it again.
But I don't know how to store it in right conditions.
I'm using the following code:
I = imread('image.jpg');
image=mat2gray(I);
imshow(image);
FID = fopen('FileName.txt', 'w');
if FID == -1, error('Cannot create file.'); end
fprintf(FID, '%f \n', image);
fclose(FID);

採用された回答

madhan ravi
madhan ravi 2018 年 10 月 18 日
dlmwrite('FileName.txt',image)

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 10 月 18 日
Do not use image as the name of your variable because it's the name of a built in function.
See attached demo that will take a color image and write a text file in the form
r, g, b, x, y
One row for every pixel.

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by