How do i convert a bmp or jpeg image to a hexadecimal

조회 수: 49 (최근 30일)
Gayathri Aiswarya
Gayathri Aiswarya 2019년 4월 20일
답변: Image Analyst 2019년 4월 20일
b=imread('frog in the rain.bmp'); % 24-bit BMP image RGB888
k=1;
for i=721:-1:1 % image is written from the last row to the first row
for j=1:481
a(k)=b(i,j,1);
a(k+1)=b(i,j,2);
a(k+2)=b(i,j,3);
k=k+3;
end
end
fid = fopen('frog in the rain.hex', 'wt');
fprintf(fid, '%x\n', a);
disp('Text file write done');disp(' ');
fclose(fid);
Error using imread>get_full_filename (line 568)
File "frog in the rain.bmp" does not exist.
Error in imread (line 377)
fullname = get_full_filename(filename);
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 20일
The problem is on the first line. You do not have a file named 'frog in the rain.bmp' in the current directory or anywhere on the MATLAB path. Consider adding the full path including the directory name.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2019년 4월 20일
See my attached demo. Change %d to %x and it should write out the location and values to a list in a text file.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by