當前位置:成語大全網 - 書法字典 - 如何用Matlab的fopen函數讀取壹個bmp圖像?

如何用Matlab的fopen函數讀取壹個bmp圖像?

fp = fopen(文件名,' Rb ');

if(FP & lt;0)錯誤(['無法打開' filename '。']),結束

ident = fread(fp,2,' uchar ')';%應該是' BM'。BMP文件類型

filesize = fread(fp,1,' long ');文件長度的百分比

dummy = fread(fp,1,' long ');%兩個‘短’保留字(未來?)

offset = fread(fp,1,' long ');位圖開始前的字節數百分比

unknown = fread(fp,1,' long ');該標題的% size(?)

width = fread(fp,1,' long ');列數百分比

height = fread(fp,1,' long ');行數百分比

one = fread(fp,1,' short ');飛機數量百分比

bits_pix = fread(fp,1,' short ');% 2、4或8

compress = fread(fp,1,' long ');% 0 =未壓縮,1 = RLE

SizeImage= fread(fp,1,' long ');圖像大小的百分比(字節)

horiz_res= fread(fp,1,' long ');%水平分辨率(像素/米)

vert_res = fread(fp,1,' long ');%垂直分辨率(像素/米)

num_color= fread(fp,1,' long ');顏色數量百分比

imp_color= fread(fp,1,' long ');%數量的重要顏色(!)