Image Histograms Cumulative histogram

Slides:



Advertisements
Similar presentations
Types of Image Enhancements in spatial domain
Advertisements

Point Processing Histograms. Histogram Equalization Histogram equalization is a powerful point processing enhancement technique that seeks to optimize.
Digital Image Processing
Grey Level Enhancement Contrast stretching Linear mapping Non-linear mapping Efficient implementation of mapping algorithms Design of classes to support.
Image Processing Lecture 4
Chapter 3 Image Enhancement in the Spatial Domain.
Chapter - 2 IMAGE ENHANCEMENT
Histogram Specification
Digital Image Processing Lecture11: Histogram Processing.
Topic 4 - Image Mapping - I DIGITAL IMAGING Course 3624 Department of Physics and Astronomy Professor Bob Warwick.
Intensity Transformations (Chapter 3)
HISTOGRAM TRANSFORMATION IN IMAGE PROCESSING AND ITS APPLICATIONS Attila Kuba University of Szeged.
EE663 Image Processing Histogram Equalization Dr. Samir H. Abdul-Jauwad Electrical Engineering Department King Fahd University of Petroleum & Minerals.
Digital Image Processing
Histogram Processing The histogram of a digital image with gray levels from 0 to L-1 is a discrete function h(rk)=nk, where: rk is the kth gray level nk.
Image Enhancement in the Spatial Domain
Image (and Video) Coding and Processing Lecture 5: Point Operations Wade Trappe.
Intensity Transformations
Image Processing IB Paper 8 – Part A Ognjen Arandjelović Ognjen Arandjelović
Digital Image Processing
Image Processing1 Statistical Operations Gray-level transformation Histogram equalization Multi-image operations.
Chapter 4: Image Enhancement
BYST Eh-1 DIP - WS2002: Enhancement in the Spatial Domain Digital Image Processing Bundit Thipakorn, Ph.D. Computer Engineering Department Image Enhancement.
Image Enhancement by Modifying Gray Scale of Individual Pixels
Lecture 4 Digital Image Enhancement
Digital Image Processing In The Name Of God Digital Image Processing Lecture3: Image enhancement M. Ghelich Oghli By: M. Ghelich Oghli
DREAM PLAN IDEA IMPLEMENTATION Introduction to Image Processing Dr. Kourosh Kiani
Image Enhancement To process an image so that the result is more suitable than the original image for a specific application. Spatial domain methods and.
EEE 498/591- Real-Time DSP1 What is image processing? x(t 1,t 2 ) : ANALOG SIGNAL x : real value (t 1,t 2 ) : pair of real continuous space (time) variables.
6/9/2015Digital Image Processing1. 2 Example Histogram.
CS443: Digital Imaging and Multimedia Point Operations on Digital Images Spring 2008 Ahmed Elgammal Dept. of Computer Science Rutgers University Spring.
Digital Image Processing
CS 376b Introduction to Computer Vision 02 / 25 / 2008 Instructor: Michael Eckmann.
Image Enhancement.
Statistics for Managers Using Microsoft Excel, 4e © 2004 Prentice-Hall, Inc. Chap 6-1 Chapter 6 The Normal Distribution and Other Continuous Distributions.
Lecture 2. Intensity Transformation and Spatial Filtering
Digital Image Characteristic
Spectral contrast enhancement
Lecture 4 Digital Image Enhancement
CS 376b Introduction to Computer Vision 02 / 26 / 2008 Instructor: Michael Eckmann.
Chapter 10: Image Segmentation
University of Ioannina - Department of Computer Science Intensity Transformations (Point Processing) Christophoros Nikou Digital Image.
CS6825: Point Processing Contents – not complete What is point processing? What is point processing? Altering/TRANSFORMING the image at a pixel only.
Image Processing Image Histogram Lecture
Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We.
September 5, 2013Computer Vision Lecture 2: Digital Images 1 Computer Vision A simple two-stage model of computer vision: Image processing Scene analysis.
Digital Image Processing Lecture 4: Image Enhancement: Point Processing Prof. Charlene Tsai.
CIS 601 Image ENHANCEMENT in the SPATIAL DOMAIN Dr. Rolf Lakaemper.
EE663 Image Processing Dr. Samir H. Abdul-Jauwad Electrical Engineering Department King Fahd University of Petroleum & Minerals.
Intensity Transformations or Translation in Spatial Domain.
AdeptSight Image Processing Tools Lee Haney January 21, 2010.
: Chapter 4: Statistical Operations 1 Montri Karnjanadecha ac.th/~montri Image Processing.
Lecture 3 The Digital Image – Part I - Single Channel Data 12 September
CS654: Digital Image Analysis Lecture 18: Image Enhancement in Spatial Domain (Histogram)
Intensity Transformations (Histogram Processing)
Image Segmentation by Histogram Thresholding Venugopal Rajagopal CIS 581 Instructor: Longin Jan Latecki.
Digital Image Processing
1 Mathematic Morphology used to extract image components that are useful in the representation and description of region shape, such as boundaries extraction.
Image Enhancement in Spatial Domain Presented by : - Mr. Trushar Shah. ME/MC Department, U.V.Patel College of Engineering, Kherva.
Lecture 02 Point Based Image Processing Lecture 02 Point Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010.
Digital Image Processing Lecture 4: Image Enhancement: Point Processing January 13, 2004 Prof. Charlene Tsai.
Digital Image Processing Image Enhancement in Spatial Domain
1-Introduction (Computing the image histogram).
Digital Image Processing
Image Enhancement in the Spatial Domain
Digital Image Processing
Histogram Equalization
Digital Image Procesing Introduction to Image Enhancement Histogram Processing DR TANIA STATHAKI READER (ASSOCIATE PROFFESOR) IN SIGNAL PROCESSING IMPERIAL.
Grey Level Enhancement
Histogram The histogram of an image is a plot of the gray _levels values versus the number of pixels at that value. A histogram appears as a graph with.
Presentation transcript:

Image Histograms Cumulative histogram Effect of gray-level mapping on histogram Histogram equalization Histogram specification Local enhancement Color processing

Intensity Histogram The histogram of a digital image with gray levels in the range [0,L-1] is a discrete function h(rk) = nk, where rk is the kth gray level and nk is the number of pixels in the image having gray level rk. This histogram is a graph showing the number of pixels in an image at each different intensity value found in that image. For an 8-bit greyscale image there are 256 different possible intensities, and so the histogram will graphically display 256 numbers showing the distribution of pixels amongst those greyscale values.

Histogram Processing - How It Works The operation is very simple. The image is scanned in a single pass and a running count of the number of pixels found at each intensity value is kept. This is then used to construct a suitable histogram. The histogram of an 8-bit image, for example can be thought of as a table with 256 entries, or ‘bins’, indexed from 0 to 255. In bin 0 we record the number of times a gray level of 0 occurs; in bin 1 we record the number of times a grey level of 1 occurs, and so on, up to bin 255. See algorithm 6.3 1. Assign zero values to all element of the array hf ; 2. For all pixels (x,y) of the image f , increment hf [f(x,y)] by 1 .

Another way to get the histogram is to use the C code, as following: char image[rows][cols]; int histogram[256]; int row, col, i;  for (i = 0; i < 256; i++) histogram[j]=0; for (row = 0; row < rows; row++) for(col = 0; col < cols; col++) histogram[(int) image[row][col]++;

Intensity Histogram - Guidelines for Use Histograms have many uses. One of the more common is to decide what value of threshold to use when converting a greyscale image to a binary one by thresholding. If the image is suitable for thresholding then the histogram will be bi-modal --- i.e. the pixel intensities will be clustered around two well separated values. A suitable threshold for separating these two groups will be found somewhere in between the two peaks in the histogram. If the distribution is not like this then it is unlikely that a good segmentation can be produced by thresholding. The intensity histogram for the input image is

Intensity Histogram - Guidelines for Use The object being viewed is dark in color and it is placed on a light background, and so the histogram exhibits a good bi-modal distribution. One peak represents the object pixels, one represents the background.

Intensity Histogram - Guidelines for Use The histogram is the the same but with the y-axis expanded to show more detail. It is clear that a threshold value of around 120 should segment the picture nicely as can be seen in

Intensity Histogram - Guidelines for Use The histogram of image is This time there is a significant incident illumination gradient across the image, and this blurs out the histogram. The bi-modal distribution has been destroyed and it is no longer possible to select a single global threshold that will neatly segment the object from its background. Two failed thresholding segmentations are shown in

Intensity Histogram - Guidelines for Use The histogram is used and altered by many image enhancement operators. Two operators which are closely connected to the histogram are contrast stretching and histogram equalization They are based on the assumption that an image has to use the full intensity range to display the maximum contrast.

Intensity Histogram and Contrast stretching Contrast stretching takes an image in which the intensity values don't span the full intensity range and stretches its values linearly. The histogram shows that most of the pixels have rather high intensity values.

Intensity Histogram and Contrast stretching Contrast stretching the image yields which has a clearly improved contrast. The corresponding histogram is

Intensity Histogram and Contrast stretching Multiplication of gray levels by a constant gain will spread out the histogram evenly if a>1, increasing the spacing between occupied bins,or compress it if a<1, which can have the effect of merging bins

Intensity Histogram and Contrast stretching If we expand the y-axis, as was done in We can see that now the pixel values are distributed over the entire intensity range. Due to the discrete character of the pixel values, we can't increase the number of distinct intensity values. That is the reason why the stretched histogram shows the gaps between the single values.

Intensity Histogram and Contrast stretching The present image also has low contrast. However, if we look at its histogram, we see that the entire intensity range is used and we therefore cannot apply contrast stretching. On the other hand, the histogram also shows that most of the pixels values are clustered in a rather small area, whereas the top half of the intensity values is used by only a few pixels.

Intensity Histogram and histogram equalization The idea of histogram equalization is that the pixels should be distributed evenly over the whole intensity range, i.e. the aim is to transform the image so that the output image has a flat histogram. The image results from the histogram equalization

Intensity Histogram - Conclusions consider the image intensities as random variables with a probability density function (pdf). we can estimate the pdf from the empirical data given in the image itself . record the frequency distribution of gray levels in an image. for a b-bit image, you need an array of size 2b loop through every pixel, recording the number of times a particular gray level occurs.

Intensity Histogram - Conclusions 4. normalize the histogram by dividing each entry by the total number of pixels - gives an estimate for the pdf - each element of the array gives the probability of that gray level occurring at a randomly selected pixel . 5. contains global information about the image 6. discards all spatial information 7. an image has only one histogram, but many images may have the same histogram

Cumulative histogram - Conclusions - each array element gives the number of pixels with a gray-level less than or equal to the gray level corresponding to the array element - easily constructed from the histogram Cumulative frequencies , cj, are computed from histogram counts, hi using,

Cumulative histogram - Conclusions - cumulative histogram has a steep slope in densely populated parts of the histogram - cumulative histogram has a gradual slope in sparsely populated parts of the histogram

Effect of gray-level mapping on histogram - Conclusions 1. adding a bias shifts the histogram 2. gain > 1 stretches the histogram (increasing contrast) 3. gain < 1 compresses histogram (reducing contrast) 4. nonlinear mapping stretches some regions and compresses others

Histogram Equalization Histogram modeling techniques (e.g. histogram equalization) provide a sophisticated method for modifying the dynamic range and contrast of an image by altering that image such that its intensity histogram has a desired shape. Unlike contrast stretching , histogram modeling operators may employ non-linear and non-monotonic transfer functions to map between pixel intensity values in the input and output images. Histogram equalization employs a monotonic, non-linear mapping which re-assigns the intensity values of pixels in the input image such that the output image contains a uniform distribution of intensities (i.e. a flat histogram). This technique is used in image comparison processes (because it is effective in detail enhancement) and in the correction of non-linear effects introduced by, say, a digitizer or display system.

Histogram Equalization Histogram equalization involves finding a grey scale transformation function that creates an output image with a uniform histogram (or nearly so).

How do we determine this grey scale transformation function? Assume our grey levels are continuous and have been normalized to lie between 0 (black) and 1 (white). We must find a transformation T that maps grey values r in the input image F to grey values s = T(r) in the transformed image . It is assumed that T is single valued and monotonically increasing, and for The inverse transformation from s to r is given by : r = T-1(s).

An example of such a transfer function is illustrated in the Figure

Histogram Equalization - Discrete Formulation We first need to determine the probability distribution of grey levels in the input image. where nk is the number of pixels having grey level k, and N is the total number of pixels in the image. The transformation now becomes Note that ,the index k=0,1,2,…255, and The values of sk will have to be scaled up by 255 and rounded to the nearest integer so that the output values of this transformation will range from 0 to 255. Thus the discretization and rounding of sk to the nearest integer will mean that the transformed image will not have a perfectly uniform histogram.

Histogram Equalization - Discrete Formulation The mapping function we need is obtained simply by rescaling the cumulative histogram so that its values lie in the range 0-255. Thus, an image which is transformed using its cumulative histogram yields an output histogram which is flat . See Algorithm 6.4 p 125 Efford’s book

The original image and its histogram, and the equalized versions The original image and its histogram, and the equalized versions. Both images are quantized to 64 grey levels.

Histogram Equalization Guidelines for Use The histogram confirms what we can see by visual inspection: this image has poor dynamic range. (Note that we can view this histogram as a description of pixel probability densities by simply scaling the vertical axis by the total number of image pixels and normalizing the horizontal axis using the number of intensity density levels (i.e. 256). However, the shape of the distribution will be the same in either case.)

Histogram Equalization Guidelines for Use In order to improve the contrast of this image, without affecting the structure (i.e. geometry) of the information contained therein, we can apply the histogram equalization operator.

Histogram Equalization Guidelines for Use Note that the histogram is not flat (as in the examples from the continuous case) but that the dynamic range and contrast have been enhanced. Note also that when equalizing images with narrow histograms and relatively few gray levels, increasing the dynamic range has the adverse effect of increasing visual grainyness. Compare this result with that produced by the linear contrast stretching operator After contrast stretching After equalization operator

Histogram Equalization - Example Although the contrast on the building is acceptable, the sky region is represented almost entirely by light pixels. This causes most histogram pixels to be pushed into a narrow peak in the upper graylevel region.

Histogram Equalization - Example The histogram equalization operator defines a mapping based on the cumulative histogram

Histogram Equalization - Example After histogram equalization While histogram equalization has enhanced the contrast of the sky regions in the image, the picture now looks artificial because there is very little variety in the middle graylevel range. This occurs because the transfer function is based on the shallow slope of the cumulative histogram in the middle graylevel regions (i.e. intensity density levels 100 - 230) and causes many pixels from this region in the original image to be mapped to similar graylevels in the output image.

Histogram Equalization - Example We can improve on this if we define a mapping based on a sub-section of the image which contains a better distribution of intensity densities from the low and middle range graylevels. If we crop the image so as to isolate a region which contains more building than sky. We can then define a histogram equalization mapping for the whole image based on the cumulative histogram of this smaller region. Rather than saying that equalisation flattens a histogram, it is more accurate to say that it linearises the cumulative frequency distribution.

Histogram Equalization - Example Since the cropped image contains a more even distribution of dark and light pixels, the slope of the transfer function is steeper and smoother, and the contrast of the resulting image is more natural. This idea of defining mappings based upon particular sub-sections of the image is taken up by another class of operators which perform Local Enhancements

Histogram Equalization - Conclusions - use the cumulative histogram to generate a nonlinear gray-level mapping - cumulative histogram has a steep slope in densely populated parts of the histogram - cumulative histogram has a gradual slope in sparsely populated parts of the histogram - scale the entries based on bits per pixel and number of pixels - EqualizeOp.java - convenient because no user input is required - histogram equalization doesn't always get us the desired results - can enhance noise and other image artefacts

Histogram Specification Histogram equalization is limited in that it is capable of producing only one result: an image with a uniform intensity distribution. Sometimes it is desirable to be able to control the shape of the output histogram in order to highlight certain intensity levels in an image. This can be accomplished by the histogram specialization operator which maps a given intensity distribution into a desired distribution as an intermediate stage using a histogram equalized image The first step in histogram specialization, is to specify the desired output density function and write a transformation g(c). defines a mapping from the equalized levels of the original image, Then It is possible to combine these two transformations such that the image need not be histogram equalized explicitly:

Histogram Specification - Conclusions 1.We can specify the shape of the histogram we want our image to have 2. Specify (perhaps interactively) the histogram we would like 3. compute the cumulative histogram from the desired histogram 4. find the inverse of the desired cumulative histogram (may not be single-valued) 5. two-step process - perform histogram equalization on the image - perform a gray-level mapping using the inverse of the desired cumulative histogram

Local enhancement 1. histogram equalization and histogram specification techniques are based on gray-level distribution over the entire image 2. gray-levels containing important information in a small neighborhood (region of interest) may not be present in sufficient quantities to affect the computation of a mapping based on global information 3. at each pixel do the following - compute the cumulative histogram based on a small neighborhood around the pixel to be mapped - apply histogram equalization using this cumulative histogram

Color processing 1.can apply histogram equalization to color images 2. don't want to apply it using the RGB color model - equalizing R, G, and B bands independently causes color shifts 3. must convert to a color model that separates intensity information from color information (e.g. HSI) 4. can then apply histogram equalization on the intensity band

References http://www.netnam.vn/unescocourse/computervision/22.htm http://homepages.inf.ed.ac.uk/rbf/HIPR2/histeq.htm