Preprocessing - Histogram equalization, Thresholding Flashcards
What is the problem with low contrast signals?
Captured images often have a small dynamic range:
• Allpixelswithinasmallrangeofvalues
• Rangetypicallymuchsmallerthanthecapabilityofthesensor
What das the histogram of a picture show?
Histograms show the distribution of intensity values, grouped into bins. (counting)
How is histogram stretching applied?
Rescale image intensities fi such that intensities are in (0,255)
1. Problem:
- if f min/max are 0/255, no stretching
(e.g. pictures with very high contrasts in it can’t be stretched)
Solution:
- Use percentiles
What is the idea of Histogram Equalization?
- method to improve images with a limited range of values
- redistribution of intensities
- based on histograms
- effectively spreads out the most frequently used intensities
- goal: image with uniform distribution of intensities
Algorithm
- Compute the intensity histogram of a given image 2. Compute its cumulative distribution function
- Map the gray value of each pixel:
Resulting image:
• Approximately uniform distribution of the intensity values
• Pixels are spread evenly across the entire range of intensity values
• Highest possible contrast
What is the use for Histogram Equalization?
- Straightforward, easy to implement
- Computationally not expensive
- Works well for images where both the foreground and the background are dark (or both are bright)
- Facilitates further detection and analysis in cases where spatial correlation is more important than the intensity values themselves
- Often produces unrealistic looking images or undesirable effects
• Histogram equalization/stretching can also be applied on color images
• Each channel independently
• ConverttoHSV,applyonlyonVchannel
• When image contains regions that are significantly lighter/darker than most of the image
-> contrast in those regions will not be sufficiently enhanced
-> Adaptive histogram equalization (AHE)
• Transforming each pixel with a transformation function derived from a
neighbourhood region
• Noise might get amplified in near-constant regions
What is thresholding?
Process of converting a grayscale image of l1 gray levels into one of l2 levels, where l2 ≪ l1, based on threshold values
Binarization:
T(fij)= 0 if fij≤θ otherwise 1
What are Bimodal Histograms?
Simplest binarization algorithms:
• assume background: one intensity value & object(s) of interest another value
• bimodal histogram due to shading variations:
• histogramwithtwolocalmaxima
• onemaximumforforeground,oneforbackground
• idea: pick a value between two maxima for θ
Algorithm
1. compute the histogram
2. determine the values of p0, μ0, σ0, μ1, and σ1 that best fit the histogram 3. analytically compute θ
Drawbacks:
• computationally very expensive
• may not even fit the data very well
• often the pdfs for the background or the object(s) are not unimodal or not Gaussian
What is the Gaussian Mixture Model (GMM)?
- linear combination of Gaussians
- widely used in pattern recognition
- approximation of unknown pdfs with a convex combination of Gaussians
- convex combination: mixture weights sum up to 1
What is the alternative approach in Bimodal Histogram?
Alternative, though sub-optimal iterative solution:
- choose a threshold θ
- estimate μ0 and σ0 from the histogram values x ≤ θ and μ1 and σ1 from the histogram values x > θ
- estimate p0 from the number of pixels x ≤ θ
- compute an approximation error and adjust θ accordingly
- repeat steps 2–4 until the approximation error converges
Optimal threshold
• more general binarization
• quite common to set c0 =μ0 and c1 =μ1
• choose a threshold θ such that ε (loss of information) is minimal
What are difficulties with most pictures?
difficult to detect the valley bottom precisely due to:
• flat and broad valley bottom
• noise
• extreme differences between the heights of the two peaks
What is the idea of Otsu’s threshold?
Assumption of Otsu’s thresholding
• well-thresholded classes are separated in gray levels
• conversely: threshold giving the best separation of classes in gray levels is the best threshold
- maximizing the squared distance between the 2 mean values
- multiplied by the prior class probabilities (favoring equal priors);
- equivalent to minimizing the within-class variance
What is the Unimodal histogram heuristic?
• common form of gray-value distributions:
only one big dominant mode with smaller ones on one side
• for all practical purposes:
considered approximately a unimodal histogram
Threshold selection:
- find the gray value with the highest number of occurrences
- get farthest non-zero histogram value of previous peak
- connect these two points with a straight line
- The threshold θ is the intensity of that point on the histogram that has the maximum perpendicular distance to the line.
What is the Basic Global Thresholding Algorithm?
- initialize θ to the average gray value of the image:
θ= 1/m mSUMi=1 xi - partition the data around θ and compute the mean values μ0 and μ1 for each partition
- select the mean of these two means as the new threshold:
θ = 1/2(μ0 + μ1) - repeat steps 2 and 3 until the mean values μ0 and μ1 do not change in successive iterations
What is the problem with global threshold methods?
• Non-uniform illumination/contrast changes
-> Adaptive/local thresholding
What is local Thresholding doing?
Use global thresholding methods in a local window
- > Window size crucial
- > Possibly computational expensive