天津行業(yè)網(wǎng)站建設(shè)百度認(rèn)證營銷顧問
簡介
MATLAB中的圖像處理工具箱體統(tǒng)了一套全方位的標(biāo)準(zhǔn)算法和圖形工具,用于進行圖像處理、分析、可視化和算法開發(fā)。這里僅僅對常用的基礎(chǔ)函數(shù)做個使用介紹。
查詢圖像文件的信息
使用如下函數(shù)
imfinfo(filename,fmt)
函數(shù)imfinfo返回一個結(jié)構(gòu)體的info,其中包括了圖像文件的信息,filename是指定圖像文件的字符串,fmt是指定圖像文件格式的字符串。通過此函數(shù)獲得的信息與圖像文件格式的字符串。通過此函數(shù)獲得的信息與圖像文件的類型有關(guān),但至少包含以下一些內(nèi)容。
imfinfo
>> info = imfinfo('測試圖片.jpg')info = Filename: 'C:\Users\Dell\Desktop\atongbu\text\測試圖片.jpg'FileModDate: '08-Sep-2023 14:37:07'FileSize: 226226Format: 'jpg'FormatVersion: ''Width: 1488Height: 878BitDepth: 24ColorType: 'truecolor'FormatSignature: ''NumberOfSamples: 3CodingMethod: 'Huffman'CodingProcess: 'Sequential'Comment: {}
圖像文件的讀寫
MATLAB提供了imread函數(shù)來讀取圖像文件到工作區(qū)中。通過imread函數(shù),用戶可以導(dǎo)入多種格式的圖像數(shù)據(jù),如TIFF/HDF/BMP/JPEG/GIF/PCX/XWD/Cursor/Icon和PNG等格式。
>> RGB = imread('測試圖片.jpg');
>> whosName Size Bytes Class AttributesRGB 878x1488x3 3919392 uint8 >>
?
為了把MATLAB工作中的圖像數(shù)據(jù)用一種標(biāo)準(zhǔn)格式輸出到圖像文件中,需要使用imwrite函數(shù)來完成這個工作。Imwrite函數(shù)用于將數(shù)據(jù)輸出為多種標(biāo)準(zhǔn)的圖像文件。
圖像文件的顯示
在MATLAB中,使用函數(shù)imshow來顯示圖像文件。
imshow(I) displays image I in a Handle Graphics? figure, where I is a grayscale, RGB (truecolor), or binary image. For binary images, imshow displays pixels with the value 0 (zero) as black and 1 as white. imshow optimizes figure, axes, and image object properties for image display.
example
imshow(X,map) displays the indexed image X with the colormap map. A colormap matrix can have any number of rows, but it must have exactly 3 columns. Each row is interpreted as a color, with the first element specifying the intensity of red light, the second green, and the third blue. Color intensity can be specified on the interval 0.0 to 1.0.
example
imshow(filename) displays the image stored in the graphics file specified by filename.
imshow(I,[low high]) displays grayscale image I, specifying the display range as a two-element vector, [low high]. For more information, see the DisplayRange parameter.
imshow(___,Name,Value) displays an image, using name-value pairs to control aspects of the operation.
himage = imshow(___) returns the handle to the image object created by imshow.
imshow(I) 顯示灰度圖像I
imshow(I,[low high]) 顯示灰度圖像I,[low, high]為圖像數(shù)據(jù)的值域
imshow(RGB)顯示真彩圖像RGB
imshow(X,map)顯示索引圖像,X為索引圖像的數(shù)據(jù)矩陣,map為顏色表
imshow(filename)顯示filename文件的圖像
himage = imshow(___)返回船艦圖像對象的句柄
>> imshow('測試圖片.jpg')
>>
?
圖像的格式轉(zhuǎn)換
rgb2gray
I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I. The rgb2gray function converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance. If you have Parallel Computing Toolbox? installed, rgb2gray can perform this conversion on a GPU.
example
newmap = rgb2gray(map) returns a grayscale colormap equivalent to map.
?