[問題] 請問關於中值濾波去除雜訊的問題已回收

看板MATLAB作者 (提姆王)時間15年前 (2010/05/27 00:02), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
小弟是一個剛使用matlab一星期的新手,用matlab寫了一段程式如下: 輸入圖形 clear all; close all; A=imread('wafer1.bmp'); 把影像分成R、G、B AR=A(:,:,1); AG=A(:,:,2); AB=A(:,:,3); subplot(2,2,1),imshow(A),title('原始影像'); subplot(2,2,2),imshow(A(:,:,1)), title('R影像'); subplot(2,2,3),imshow(A(:,:,2)),title('G影像'); subplot(2,2,4),imshow(A(:,:,3)),title('B影像'); 分析彩色晶圓之直方圖 subplot(2,2,1),imshow(A),title('原始影像'); subplot(2,2,2),imhist(AR),title('R影像直方圖'); subplot(2,2,3),imhist(AG),title('G影像直方圖'); subplot(2,2,4),imhist(AB),title('B影像直方圖'); Gamma修正法進行影像強化 BR=imadjust(AR); BG=imadjust(AG); BB=imadjust(AB); subplot(2,2,1),imshow(A),title('原始影像'); subplot(2,2,2),imshow(BR),title('R影像Gamma修正'); subplot(2,2,3),imshow(BG),title('G影像Gamma修正'); subplot(2,2,4),imshow(BB),title('B影像Gamma修正'); Otsu影像分割 CR =graythresh(BR); CG=graythresh(BG); CB =graythresh(BB); WR= im2bw(BR,CR); WG= im2bw(BG,CG); WB= im2bw(BB,CB); subplot(2,2,1),imshow(A),title('原始影像'); subplot(2,2,2),imshow(WR) ,title('R影像Otsu分割'); subplot(2,2,3),imshow(WG) ,title('G影像Otsu分割'); subplot(2,2,4),imshow(WB) ,title('B影像Otsu分割'); 利用Median Filter去除雜訊 IR=imnoise(WR,'salt & pepper',0.02); IG=imnoise(WG,'salt & pepper',0.02); IB=imnoise(WB,'salt & pepper',0.02); MR=medfilt2(WR); MG=medfilt2(WG); MB=medfilt2(WB); subplot(2,2,1),imshow(A),title('原始影像'); subplot(2,2,2),imshow(MR),title('R影像中值率波去除雜訊'); subplot(2,2,3),imshow(MG),title('G影像中值率波去除雜訊'); subplot(2,2,4),imshow(MB),title('B影像中值率波去除雜訊'); 前面都還順利。 但是在執行Median Filter去除雜訊這邊遇到問題,錯誤訊息如下: ??? Function IMNOISE expected its first input, I, to be one of these types: uint8, uint16, double, int16, single Instead its type was logical. Error in ==> imnoise>ParseInputs at 201 iptcheckinput(a, {'uint8','uint16','double','int16','single'}, {}, mfilename, ... Error in ==> imnoise at 85 [a, code, classIn, classChanged, p3, p4] = ParseInputs(varargin{:}); 想請問一下各問大大,應該要如何修改,謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.136.178.10

05/27 00:28, , 1F
因為他不吃二元影像...轉double就好了
05/27 00:28, 1F

05/27 00:30, , 2F
中位濾波可以考慮放在二值化前
05/27 00:30, 2F
文章代碼(AID): #1B_KOOQW (MATLAB)