2021—2022學年第一學期寒假學習記錄2
2022.01.01,今天是服務外包競賽:隨便拿個獎隊的專案進行的第二天,今天根據專案要求開始學習matlab數字影象處理
實驗一 MATLAB數字影象處理初步
一、實驗目的與要求
1.熟悉及掌握在MATLAB中能夠處理哪些格式影象。
2.熟練掌握在MATLAB中如何讀取影象。
3.掌握如何利用MATLAB來獲取影象的大小、顏色、高度、寬度等等相關資訊。
4.掌握如何在MATLAB中按照指定要求儲存一幅影象的方法。
5.影象間如何轉化。
二、實驗內容及步驟
1.利用imread( )函式讀取一幅影象,假設其名為flower.tif,存入一個數組中;
2.利用whos 命令提取該讀入影象flower.tif的基本資訊;
3.利用imshow()函式來顯示這幅影象;
4.利用imfinfo函式來獲取影象檔案的壓縮,顏色等等其他的詳細資訊;
5.利用imwrite()函式來壓縮這幅圖象,將其儲存為一幅壓縮了畫素的jpg檔案,設為flower.jpg;語法:imwrite(原影象,新影象,‘quality’,q), q取0-100。
6.同樣利用imwrite()函式將最初讀入的tif圖象另存為一幅bmp影象,設為flower.bmp。
7.用imread()讀入影象:Lenna.jpg 和camema.jpg;
8.用imfinfo()獲取影象Lenna.jpg和camema.jpg 的大小;
9.用figure,imshow()分別將Lenna.jpg和camema.jpg顯示出來,觀察兩幅影象的質量。
10.用im2bw將一幅灰度影象轉化為二值影象,並且用imshow顯示出來觀察影象的特徵。
11.將每一步的函式執行語句拷貝下來,寫入實驗報告,並且將得到第3、9、10步得到的影象效果拷貝下來
三、考核要點
1、熟悉在MATLAB中如何讀入影象、如何獲取影象檔案的相關資訊、如何顯示影象及儲存影象等,熟悉相關的處理函式。
2、明確不同的影象檔案格式,由於其具體的影象儲存方式不同,所以檔案的大小不同,因此當對同一幅影象來說,有相同的檔案大小時,質量不同。
五、實驗儀器與軟體
(1) PC計算機
(2) MatLab軟體/語言包括影象處理工具箱(Image Processing Toolbox)
(3) 實驗所需要的圖片
四、實驗內容
f=imread('C:\Users\Gateway\Desktop\ͼƬ\flower.tif');
whos f;
imshow(f);
imfinfo C:\Users\Gateway\Desktop\ͼƬ\flower.tif
ans =
Filename: 'C:\Users\Gateway\Desktop\圖片\flower.tif'
FileModDate: '24-六月-2012 18:46:53'
FileSize: 392018
Format: 'jpg'
FormatVersion: ''
Width: 1600
Height: 1200
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
ans = %imfinfo壓縮後的資訊
Filename: 'flower.jpg'
FileModDate: '25-六月-2012 16:07:40'
FileSize: 81013
Format: 'jpg'
FormatVersion: ''
Width: 1600
Height: 1200
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
f=imread('C:\Users\Gateway\Desktop\ͼƬ\lenna.jpg');
g=imread('C:\Users\Gateway\Desktop\ͼƬ\camera.jpg');
figure;imshow(f);
figure,imshow(g);
imfinfo C:\Users\Gateway\Desktop\ͼƬ\lenna.jpg
imfinfo C:\Users\Gateway\Desktop\ͼƬ\camera.jpg
ans =
Filename: 'C:\Users\Gateway\Desktop\圖片\lenna.jpg'
FileModDate: '24-六月-2012 18:44:09'
FileSize: 21307
Format: 'jpg'
FormatVersion: ''
Width: 300
Height: 300
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
ans =
Filename: 'C:\Users\Gateway\Desktop\圖片\camera.jpg'
FileModDate: '24-六月-2012 18:44:32'
FileSize: 18653
Format: 'jpg'
FormatVersion: ''
Width: 256
Height: 256
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
f=imread('C:\Users\Gateway\Desktop\ͼƬ\lenna.jpg');
g=im2bw(f);
figure,imshow(g);
五、思考題
(1) 簡述MatLab軟體的特點。
(2) MatLab軟體可以支援哪些影象檔案格式?
doc imread
(3) 說明函式imread 的用途格式以及各種格式所得到影象的性質。
(4) 為什麼用I = imread(‘lena.bmp’) 命令得到的影象I 不可以進行算術運算?
TRANSLATE with x English TRANSLATE with EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back