複製鏈接
請複製以下鏈接發送給好友

imshow

鎖定
imshow是matlab顯示圖像的函數,在matlab的命令窗口中輸入doc imshow或者help imshow即可得到關於該函數的幫助信息。
中文名
顯示圖像的函數
外文名
imshow
調用方式
imshow(I,n)
相關函數
imreadimwrite

imshow調用方式

imshow(I,n)
imshow(I,[low high])
用指定的灰度範圍 [low high]顯示灰度圖像I。顯示結果,圖像中灰度值等於或低於low的都將用黑色顯示,而灰度值大於等於high的都顯示為白色,介於low和high之間的用其灰度級默認值中間色調顯示。如果你用了一個空矩陣([ ]) 來代替 [low high], imshow 函數將使用 [min(I(:))max(I(:))]作為第二個參數。
imshow(BW)
顯示一張二值圖像BW
imshow(X,map)
用指定的調色板來顯示圖像
imshow(RGB)
顯示一張真彩色圖像RGB
imshow(...,display_option)
imshow(x,y,A,...)
imshow filename
h = imshow(...)

imshow相關函數

imread、imwriteimfinfofread、image

imshow程序示例

imshow示例一

下面這段代碼讀取一張圖片並顯示出來
filename = 'e.bmp';
imgRgb = imread(filename); % 讀入一幅彩色圖像
imshow(imgRgb); % 顯示彩色圖像

imshow示例二

下面這段代碼把24位真彩色位圖轉為灰度圖像
filename = 'e.bmp';
imfinfo(filename) % 查看圖像文件信息
imgRgb = imread(filename); % 讀入一幅彩色圖像
imshow(imgRgb); % 顯示彩色圖像
imgGray = rgb2gray(imgRgb); % 轉為灰度圖像
figure % 打開一個新的窗口顯示灰度圖像
imshow(imgGray); % 顯示轉化後的灰度圖像
imwrite(imgGray, 'gray.jpg'); % 將灰度圖像保存到圖像文件