... 3.. 5.. 7.. 9 and Its Processing 3rd Lecture on Image Processing Martina Mudrová Definition What a histogram is? = vector of absolute numbers occurrence of every colour in the picture [H(),H(), H(c)] c m.n c c number of colours H ( i) = m. n m,n image size i= vector H is used for intensity images 3 vectors H,H,H 3 are used in case of colour pictures (for R,G,B components, each of them is processed separatelly according to the same scheme) M. Mudrová, Properties histogram is a statistical value describing the probability of occurency each colour it says nothing about colour layout in the picture Two different pictures: M. Mudrová, both of them bimodal 3
7 5 3 5 5 5.5.5 5 5 5 Another Ways to Expression normalizing the range of x-axis to the <,> displaying a cumulative sum of histogram values M. Mudrová, Use I histogram provides basic information about brightness level in the picture further histogram processing can improve picture quality this picture is too bright -histogram bars are almost in the upper part M. Mudrová, Use II.5 x this picture is too dark -histogram bars are almost in the low part enables threshold level T selection for picture colour reduction - especially in case of bimodal histogram - application in the shape recognition, granulometry, M. Mudrová, L pro x< T y= H pro x T 5 x input intensity y new intensity T threshold level 5 5 5 this picture has very low level of contrast - histogram bars are only in the middle part 5
5 3...3..5..7..9 x k u m u l a c e c a r 5 5 5 3 5 3...3..5..7..9 histogram 5 5 5 3 Use III serves for cameras calibration there are taken the pictures with known histogram, the comparison of given and obtained histogram serves for settings of camera parameters Example of testing picture used for cameras calibrations and tests 7 M. Mudrová, Equalization What do I mean by this? Make a histogram as flat as is possible 5 3 Real picture histogram Ideal histogram M. Mudrová,...3..5..7..9 The algorithm of equalization is based on statistical methods: n. m D = MAX D the optimal intensity value n,m... Image size (in pixels) MAX... Maximal intensity value Example of Equalization Original Image original Image after histogram equalization po ekvalizaci. x 9 M. Mudrová,
Adjustment What happens if I change the histogram bars position? M. Mudrová, x input histogram l h y = x γ b t y output histogram A. Linear correction: g =. Shifting the histogram. Stretching the histogram B. Non-Linear correction: g <> output value y.... Gamma correction.... input value x g=.5 g= Shifting Bars to the Right Increasing the brightness shifts the histogram to the right (towards white). 5 5 5 5 5 5 35 35 35 3 3 3 5 5 5 5 5 5 5 5 5...3..5..7..9...3..5..7..9...3..5..7..9 M. Mudrová, Shifting the Bars to the Left Decreasing the brightness shifts the histogram to the left (towards black). 5 5 5 5 5 5 35 35 35 3 3 3 5 5 5 5 5 5 5 5 5...3..5..7..9...3..5..7..9...3..5..7..9 M. Mudrová,
7 5 3 7 5 3 histogram originalu...3..5..7..9...3..5..7..9 9 7 5 3 5 3 histogram po uprave...3..5..7..9...3..5..7..9 7 5 3...3..5..7..9 5 5 35 3 5 5 5...3..5..7..9 Another Possibility of Brightness Control? Can I simple add any constant to every pixel s value? original original+.3! This way can lead to the destroying of highlight details without possibility of their recovering by means of following histogram operations 3 M. Mudrová, Loosing Shadow Details Can I simple subtract any constant to every pixel s value? 7 9 9 7 5 7 5 5 3 3 3...3..5..7..9...3..5..7..9...3..5..7..9! This way can lead to the destroying of shadow details without possibility of their recovering by means of following histogram operations M. Mudrová, Dilatation and Stretching - Contrast dilatation causes contrast increasing stretching causes contrast decreasing! Be careful about loosing shadow and highlight details during the histogram dilatation, any following histogram stretching can not recover them information can be beyond redemption M. Mudrová, 5
Gamma Correction x input histogram y = x γ l h y = x γ <γ < a picture becomes lighter γ > a picture becomes darker γ = linear correction b t y output histogram output value y.... Gamma correction g=.5 g=! Some digital cameras work according to another equation:.... input value x y = x γ M. Mudrová, Gamma Correction Use Adjustment Parameters original image Image shifting histogram bars from <.5,> to <,.75>, γ = shifting histogram bars form <.5,> to <,.75>, γ =5 5. 5 5. 5 shifting histogram bars from <.5,> to <,.75>, γ =. M. Mudrová, 5 7 Advanced Operations - Operations with a LUT (Look-up table) - new color bar is assigned to, or more original colors - non-inversible operation - is used for interesting artificial (artistic) effects (substitution of water colour paintingf from realistic photos ) - New histogram with another shape can be imposed to the original picture - M. Mudrová,
M. Mudrová, Matlab Commands for Operation imhist histeq imadjust (brighten) (contrast) stretchlim 9 Example Equalization % Image Adjustment () % Equalization clear delete(get(,'children')); [x,map]=imread('busek.bmp'); i=indgray(x,map); subplot(3), imshow(i) title('original') subplot(33),imhist(i) title('histogram originalu'), j=histeq(i,3); subplot(3), subimage(j ) axis off,title('po ekvalizaci.') subplot(3),imhist(j) title('histogram '), subplot(35),plot(cumsum(imhist(i))) title('kumulace car'), subplot(3),plot(cumsum(imhist(j))) 5 original histogram originalu x kumulace car 3 5 po ekvalizaci. histogram x 3 M. Mudrová, Example Linear Adjustment % adjustment () clear delete(get(,'children')) figure() [x,map]=imread('../busek.bmp'); i=indgray(x,map); j=imadjust(i,[ ],[.],); subplot(),imshow(i) title('original') subplot(),imhist(i,) title('histogram originalu') subplot(3),imshow(j) title(' po uprave') subplot(),imhist(j) title('histogram po uprave') Original Image Modified Image of Original Image of Modified Image M. Mudrová,