![]() |
自适应阈值-最小错误阈值方法的实现
我正在尝试在MATLAB中实现以下[URL="https://www.sciencedirect.com/science/article/abs/pii/0031320386900300"]最小错误阈值[/URL] (由J. Kittler和J. Illingworth提出)方法。
您可以看一下PDF: [LIST][*] [URL="https://www.scribd.com/document/412119940"]最小误差阈值[/URL] 。[*] [URL="https://www.docdroid.net/"]DocDroid-最小错误阈值[/URL] 。[/LIST]我的代码是: function [ Level ] = MET( IMG ) %Maximum Error Thresholding By Kittler % Finding the Min of a cost function J in any possible thresholding. The % function output is the Optimal Thresholding. for t = 0:255 % Assuming 8 bit image I1 = IMG; I1 = I1(I1 t); q2 = sum(hist(I2, 256)); % J is proportional to the Overlapping Area of the 2 assumed Gaussians J(t + 1) = 1 + 2 * (q1 * log(std(I1, 1)) + q2 * log(std(I2, 1)))... -2 * (q1 * log(q1) + q2 * log(q2)); end [~, Level] = min(J); %Level = (IMG 0) && (P2 > 0) %Compute the standard deviations of the classes. mean1 = sum(histogram1 .* (1:T)') / P1; mean2 = sum(histogram2 .* (1:(256-T))') / P2; sigma1 = sqrt(sum(histogram1 .* (((1:T)' - mean1) .^2) ) / P1); sigma2 = sqrt(sum(histogram2 .* (((1:(256-T))' - mean2) .^2) ) / P2); %Only compute the criterion function if both classes contain at %least two intensity values. if (sigma1 > 0) && (sigma2 > 0) %Compute the criterion function. J(T) = 1 + 2 * (P1 * log(sigma1) + P2 * log(sigma2)) ... - 2 * (P1 * log(P1) + P2 * log(P2)); end end end %Find the minimum of J. [~, optimalThreshold] = min(J); optimalThreshold = optimalThreshold - 0.5; [url=https://stackoverflow.com/questions/2055774]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 04:55。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.