適応ゆう度しきい値選定-実装の最小限のエラーゆう度しきい値選定法
-
20-09-2019 - |
質問
ようにしているため、次の事項を実施し 最小限のエラーゆう度しきい値選定 (J.Kittler J.Illingworth)メソッドMATLAB.
というのは、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);
q1 = sum(hist(I1, 256));
I2 = IMG;
I2 = I2(I2 > 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 <= Level);
end
対象者の抽出、バイナリイメージ(ヘブライ文字)です。私のコードをトランザクション-サービスのブロックのイメージ(40×40).なった結果である劣 K-Meansクラスタリングのための方法.
かったん?????誰も考えたんですか?
感謝。
P.S.いもの"を追加した適応-ゆう度しきい値選定"の対象タグ(できないとしています。
解決
私はあなたのコードが完全に正確ではないと思います。代わりに、紙に使用されている相対的なヒストグラムの画像の絶対的なヒストグラムを使用しています。それが可能な閾値ごとに2つのヒストグラムを計算して加えて、あなたのコードは、むしろ非効率的です。私はアルゴリズムを自分で実装しました。たぶん、誰かがそれを利用することができます:
function [ optimalThreshold, J ] = kittlerMinimimErrorThresholding( img )
%KITTLERMINIMIMERRORTHRESHOLDING Compute an optimal image threshold.
% Computes the Minimum Error Threshold as described in
%
% 'J. Kittler and J. Illingworth, "Minimum Error Thresholding," Pattern
% Recognition 19, 41-47 (1986)'.
%
% The image 'img' is expected to have integer values from 0 to 255.
% 'optimalThreshold' holds the found threshold. 'J' holds the values of
% the criterion function.
%Initialize the criterion function
J = Inf * ones(255, 1);
%Compute the relative histogram
histogram = double(histc(img(:), 0:255)) / size(img(:), 1);
%Walk through every possible threshold. However, T is interpreted
%differently than in the paper. It is interpreted as the lower boundary of
%the second class of pixels rather than the upper boundary of the first
%class. That is, an intensity of value T is treated as being in the same
%class as higher intensities rather than lower intensities.
for T = 1:255
%Split the hostogram at the threshold T.
histogram1 = histogram(1:T);
histogram2 = histogram((T+1):end);
%Compute the number of pixels in the two classes.
P1 = sum(histogram1);
P2 = sum(histogram2);
%Only continue if both classes contain at least one pixel.
if (P1 > 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;
他のヒント
閾値処理はかなりトリッキーなビジネスです。多くの年後に私はいつもうまく行って1つの技術を発見していない、と私はCSの雑誌に普遍的に優れた性能の主張を不信になってきている画像を閾値処理してきます。
最大エラーしきい値方法はうまく二峰性のヒストグラムを上の作品(それはそれらに適しています)。信号と背景が明確に動作するように、このしきい値設定方法のために十分に分離することはできませんようにあなたのイメージが見えます。
あなたは、コードが正常に動作することを確認するには、、あなたはこのようなテストプログラムを作成し、良好な初期セグメンテーションを得るかどうか、だけでなく、コードが故障した「二峰性」のどのレベルの両方でチェックすることができます。
所属していません StackOverflow