MATLAB Answers

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

101 views (last 30 days)
Gayathri Aiswarya
Gayathri Aiswarya on 20 Apr 2019
Answered: Image Analyst on 20 Apr 2019
b=imread('frog in the rain.bmp'); % 24-bit BMP image RGB888
for i=721:-1:1 % image is written from the last row to the first row
for j=1:481
fid = fopen('frog in the rain.hex', 'wt');
fprintf(fid, '%x\n', a);
disp('Text file write done');disp(' ');
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 Comment

Walter Roberson
Walter Roberson on 20 Apr 2019
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.

Sign in to comment.

Answers (1)

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


Sign in to comment.

Sign in to answer this question.