how to convert output to integer?
显示 更早的评论
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)
回答(1 个)
James Tursa
2015-10-4
0 个投票
Use %d instead of %x for the output format.
2 个评论
fahim GH
2015-10-4
Walter Roberson
2015-10-4
[fid, message] = fopen('D:\IP1\in2.txt', 'wt');
if fid < 0
error('Failed to open because: %s', message);
end
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!