Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-10, 20:30   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 自适应阈值-最小错误阈值方法的实现

我正在尝试在MATLAB中实现以下最小错误阈值 (由J. Kittler和J. Illingworth提出)方法。

您可以看一下PDF:
我的代码是:

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;

更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 05:14


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.