Balanced Histogram Thresholding
   HOME

TheInfoList



OR:

In
image processing An image is a visual representation of something. It can be two-dimensional, three-dimensional, or somehow otherwise feed into the visual system to convey information. An image can be an artifact, such as a photograph or other two-dimensiona ...
, the balanced histogram thresholding method (BHT), is a very simple method used for automatic image thresholding. Like
Otsu's Method In computer vision and image processing, Otsu's method, named after , is used to perform automatic image thresholding. In the simplest form, the algorithm returns a single intensity threshold that separate pixels into two classes, foreground and ...
and the Iterative Selection Thresholding Method,Ridler TW, Calvard S. (1978) Picture thresholding using an iterative selection method, IEEE Trans. System, Man and Cybernetics, SMC-8: 630-632. this is a
histogram A histogram is an approximate representation of the distribution of numerical data. The term was first introduced by Karl Pearson. To construct a histogram, the first step is to " bin" (or "bucket") the range of values—that is, divide the ent ...
based thresholding method. This approach assumes that the image is divided in two main classes: The background and the foreground. The BHT method tries to find the optimum threshold level that divides the histogram in two classes. This method ''weighs'' the histogram, checks which of the two sides is heavier, and removes weight from the heavier side until it becomes the lighter. It repeats the same operation until the edges of the weighing scale meet. Given its simplicity, this method is a good choice as a first approach when presenting the subject of ''automatic image thresholding''.


Algorithm

The following listing, in C notation, is a simplified version of the Balanced Histogram Thresholding method: int BHThreshold(int[] histogram) The following, is a possible implementation in the Python (programming language), Python language: def bht(hist, min_count: int = 5) -> int: """Balanced histogram thresholding.""" n_bins = len(hist) # assumes 1D histogram h_s = 0 while hist _s< min_count: h_s += 1 # ignore small counts at start h_e = n_bins - 1 while hist _e< min_count: h_e -= 1 # ignore small counts at end # use mean intensity of histogram as center; alternatively: (h_s + h_e) / 2) h_c = int(round(np.average(np.linspace(0, 2 ** 8 - 1, n_bins), weights=hist))) w_l = np.sum(hist _s:h_c # weight in the left part w_r = np.sum(hist _c : h_e + 1 # weight in the right part while h_s < h_e: if w_l > w_r: # left part became heavier w_l -= hist _s h_s += 1 else: # right part became heavier w_r -= hist _e h_e -= 1 new_c = int(round((h_e + h_s) / 2)) # re-center the weighing scale if new_c < h_c: # move bin to the other side w_l -= hist _c w_r += hist _c elif new_c > h_c: w_l += hist _c w_r -= hist _c h_c = new_c return h_c


References


External links


ImageJ Plugin

Otsu ''vs''. BHT
{{DEFAULTSORT:Balanced Histogram Thresholding Image segmentation Articles with example Python (programming language) code