Download Histogram Processing-Digital Image Processing-Lecture 06 Slides Slides-Electrical and Computer Engineering and more Slides Digital Image Processing in PDF only on Docsity!
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 6-
Computer Vision &
Digital Image Processing
Histogram Processing I
Histogram Processing
- The histogram of a digital image, f, (with intensities [0, L -1]) is a discrete function h ( r (^) k ) = nk
- Where r (^) k is the k th^ intensity value and nk is the number of pixels in f with intensity r (^) k
- Normalizing the histogram is common practice
- Divide the components by the total number of pixels in the image
- Assuming an MxN image, this yields p ( r (^) k ) = n (^) k/MN for k =0,1,2,…., L -
- p ( r (^) k ) is, basically, an estimate of the probability of occurrence of intensity level r (^) k in an image Σ p ( r (^) k ) = 1
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 6-
Uses for Histogram Processing
- Image enhancements
- Image statistics
- Image compression
- Image segmentation
- Simple to calculate in software
- Economic hardware implementations
- Popular tool in real-time image processing
- A plot of this function for all values of k provides a global description of the appearance of the image (gives useful information for contrast enhancement)
Histogram Examples
- Four basic image types and their corresponding histograms - Dark - Light - Low contrast - High contrast
- Histograms commonly viewed in plots as h ( r (^) k ) = n (^) k versus r (^) k p ( r (^) k ) = n (^) k / MN versus r (^) k
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 6-
Histogram Equalization (assumptions)
- The intensity transformation function we are constructing is of the form
- An output intensity level s is produced for every pixel in the input image having intensity r
- We assume
- T ( r ) is monotonically increasing in the interval 0≤ r ≤ L -
- 0≤Τ( r ) ≤ L -1 for 0≤ r ≤ L -
- If we define the inverse
- Then T ( r ) should be strictly monotonically increasing
s = T ( r ) 0 ≤ r ≤ L − 1
r = T −^1 ( s ) 0 ≤ s ≤ L − 1
Histogram Equalization (assumptions)
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 6-
Histogram Equalization (continued)
- Histogram equalization requires construction of a transformation function sk
- where r (^) k is the k th gray level, nk is the number of pixels with that gray level, M x N is the number of pixels in the image, and k =0,1,…, L -
- This yields an s with as many elements as the original image’s histogram (normally 256 for our test images)
- The values of s will be in the range [0,1]. For constructing a new image, s would be scaled to the range [1,256]
= = ∑= ×
k j k k j M N
n s Tr 0
( ) = = ×− ∑=
k k k j j s Tr ML N n 0 ( ) (^1 )
Histogram Equalization (continued)
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 6-
An Interactive MATLAB Histogram Function
%==================================== % The LOAD IMAGE button btnNumber=1; yPos=top-(btnNumber-1)*(btnHt+spacing); labelStr='Load Image'; callbackStr='winhist(''load'')'; % Generic button information btnPos=[left yPos-btnHt btnWid btnHt]; uicontrol( ... 'Style','pushbutton', ... 'Units','normalized', ... 'Position',btnPos, ... 'String',labelStr, ... 'Callback',callbackStr);
An Interactive MATLAB Histogram Function
%==================================== % The Histogram button btnNumber=2; yPos=top-(btnNumber-1)*(btnHt+spacing); labelStr='Histogram'; callbackStr='winhist(''histogram'')'; % Generic button information btnPos=[left yPos-btnHt btnWid btnHt]; uicontrol( ... 'Style','pushbutton', ... 'Units','normalized', ... 'Position',btnPos, ... 'String',labelStr, ... 'Callback',callbackStr); % Now uncover the figure set(figNumber,'Visible','on');
Electrical & Computer Engineering Dr. D. J. Jackson Lecture 6-
An Interactive MATLAB Histogram Function
elseif strcmp(action,'histogram'), axes(p2); h=histogram(FIG); bar(h,'w'), axis([1 256 0 max(h)1.10]); elseif strcmp(action,'load'), axes(p1); cd('L:\ece582\matlab'); [file,path]=uigetfile('.bmp','Open'); [f,fmap]=bmpread(fullfile(path,file)); FIG=f; image(f);colormap(gray(256)); end;
An Interactive MATLAB Histogram Function