how to convert output to integer?
조회 수: 2 (최근 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 Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!