【文章內(nèi)容簡介】
A2, K) generates a twomode, % Gaussianlike function in the interval [0,1]. P is a 256element vector normalized % so that SUM(P) equals 1. The mean and standard deviation of the modes are % (M1, SIG1) and (M2, SIG2), respectively. A1 and A2 are the amplitude values of % the two modes. Since the output is normalized, only the relative % values of A1 and A2 are important. K is an offset value that raises the floor of % the function. A good set of values to try is M1=, S1=, M2=, S2=, % A1=1, A2=, and K=. c1 = A1 * (1 / ((2 * pi) ^ ) * sig1)。 k1 = 2 * (sig1 ^ 2)。 c2 = A2 * (1 / ((2 * pi) ^ ) * sig2)。 k2 = 2 * (sig2 ^ 2)。 z = linspace(0, 1, 256)。 p = k + c1 * exp(((z m1) .^ 2) ./ k1) +c2 * exp(((z m2) .^ 2) ./ k2)。 p = p ./ sum(p(:))。 Digital Image Processing 從鍵盤輸入交互式信息,繪制高斯函數(shù): function p = manualhist % A good set of starting values is: (, , , , 1, , ). % Initialize. repeats = true。 quitnow = 39。x39。 % Compute a default histogram in case the user quits before estimating at least one histogram. p = twomodegauss(, , , , 1, , )。 % Cycle until an x is input. while repeats s = input(39。Enter m1, sig1, m2, sig2, A1, A2, k OR x to quit:39。,39。s39。)。 if s == quitnow break end Digital Image Processing % Convert the input string to a vector of numerical values and % verify the number of inputs. v = str2num(s)。 if numel(v) ~= 7 disp(39。Incorrect number of inputs39。) continue end p = twomodegauss(v(1), v(2), v(3), v(4), v(5), v(6), v(7))。 % Start a new figure and scale the axes. Specifying only xlim % leaves ylim on auto. figure, plot(p) xlim([0 255]) end Digital Image Processing 調(diào)用函數(shù),實(shí)現(xiàn)直方圖歸定化(匹配) %% 例 直方圖匹配(交互方式) clc clear f = imread(39。Fig0310(a)(Moon Phobos).tif39。)。 p = manualhist。 plot(p) figure,subplot(121),imshow(f),subplot(122),imhist(f),ylim(39。auto39。) g = histeq(f,p)。 figure,subplot(121),imshow(g),subplot(122),imhist(g),ylim(39。auto39。) Digital Image Processing 輸入交互參數(shù): , , , , 1, , (此處為默認(rèn),直接輸入 x同),得到雙峰歸定化直方圖: Digital Image Processing 運(yùn)行后的歸定化均衡效果: Digital Image Processing 空間濾波 線性空間濾波 線性空間濾波也稱為空間卷積運(yùn)算,選取一適當(dāng)?shù)臑V波模板 M N,對圖像中的每個像素依次進(jìn)行卷積運(yùn)算,其濾