
34 A Computational Introduction to Digital Image Processing, Second Edition
MATLAB/Octave
>> hexdump(’backyard.bmp’,64)
000000 424d 8235 0e00 0000 0000 8a00 0000 7c00 BM.5..........|.
000010 0000 e201 0000 8302 0000 0100 1800 0000 ................
000020 0000 f834 0e00 120b 0000 120b 0000 0000 ...4............
000030 0000 0000 0000 0000 ff00 00ff 0000 ff00 ................
The image width is given by bytes 18–21; they are in the second row:
e201 0000
To find the actual width; we re-order these bytes back to front:
0000 01e2
Now we can convert to decimal:
(1 ×16
2
) + (14 × 16
1
) + (2 × 16
0
) = 482
which is the image width in pixels. We can do the same thing