Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5996143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:03:40+00:00 2026-05-23T00:03:40+00:00

I’m trying to implement the following Minimum Error Thresholding (By J. Kittler and J.

  • 0

I’m trying to implement the following Minimum Error Thresholding (By J. Kittler and J. Illingworth) method in MATLAB.

You may have a look at the PDF:

  • Scribd – Minimum Error Thresholding.
  • DocDroid – Minimum Error Thresholding.

My code is:

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

I’ve tried it on the following image:
Letters

Original size image.

The target is to extract a binary image of the letters (Hebrew Letters).
I applied the code on sub blocks of the image (40 x 40).
Yet I got results which are inferior to K-Means Clustering method.

Did I miss something?
Anyone has a better idea?

Thanks.

P.S.
Would anyone add “Adaptive-Thresholding” to the subject tags (I can’t as I’m new).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:03:41+00:00Added an answer on May 23, 2026 at 12:03 am

    I think your code is not fully correct. You use the absolute histogram of the image instead of the relative histogram which is used in the paper. In addition, your code is rather inefficient as it computes two histograms per possible threshold. I implemented the algorithm myself. Maybe, someone can make use of it:

    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;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.