how to convert output to integer?
4 ビュー (過去 30 日間)
古いコメントを表示
hi i wrote the following code for converting image to textfile but the arrays of output are hexadecimal in the textfile.how could I convert them to integer??? tnx
a= imread('D:\IP1\12.jpg');
I=rgb2gray(a);
% iD conversion
b = I(:);
% New txt file creation
fid = fopen('D:\IP1\in2.txt');
% Hex value write to the txt file
fprintf(fid, '%x\n', b);
% Close the txt file
fclose(fid)
0 件のコメント
回答 (1 件)
James Tursa
2015 年 10 月 4 日
Use %d instead of %x for the output format.
2 件のコメント
Walter Roberson
2015 年 10 月 4 日
[fid, message] = fopen('D:\IP1\in2.txt', 'wt');
if fid < 0
error('Failed to open because: %s', message);
end
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!