How to convert an image file to text file & display the text file ?

tried using this code but didnt work ..plz help !!
a= imread('C:\Users\Public\Pictures\Sample Pictures\Koala.jpg');
I=rgb2gray(a);
imgTrans = I';
% iD conversion
img1D = I(:);
% Decimal to Hex value conversion
imgHex = dec2hex(img1D);
% New txt file creation
fid = fopen('im16_1.txt', 'wt');
% Hex value write to the txt file
fprintf(fid, '%x\n', imgHex);
% Close the txt file
fclose(fid)

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 31일
imgHex=cellstr(imgHex)
fid = fopen('im16_1.txt', 'wt');
fprintf(fid, '%s\r\n', imgHex{:});
fclose(fid)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

태그

질문:

2015년 7월 31일

답변:

2015년 7월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by