read a .bmp image using od command

南楼画角 提交于 2019-12-11 14:53:03

问题


I have an image (grayscale image .bmp) . that I am trying to read.So, I used the imread() function using matlab and python and I get the same results. the image

/* with Matlab */
109  107  104  101   96   91   87   84   76   75   75   77   78   80   80   80
 81   78   77   75   74   72   68   68   69   71   72   73   75   76   77   78
 73   73   72   70   69   68   67   67   67   68   69   71   72   74   75   76
 ...

/* with python in an rgb form */
[[[109 109 109]
  [107 107 107]
  [104 104 104]
   ....

you can see that it is the same interpretation.

But when I use the following command of od

$ od -t u1 cat.bmp

0000000   255 216 255 224   0  16  74  70  73  70   0   1   1   0   0   1

which is obviously soo different ... how can i fix this problem?


回答1:


A BMP file has a header which tells you the width, height, palette, transparency and so on. The bytes representing the pixels of the image do not occur at the beginning of the file.

See Wikipedia description of BMP file.



来源:https://stackoverflow.com/questions/50333239/read-a-bmp-image-using-od-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!