Presentation is loading. Please wait.

Presentation is loading. Please wait.

DREAM PLAN IDEA IMPLEMENTATION 1. 2 3 Introduction to Image Processing Dr. Kourosh Kiani

Similar presentations


Presentation on theme: "DREAM PLAN IDEA IMPLEMENTATION 1. 2 3 Introduction to Image Processing Dr. Kourosh Kiani"— Presentation transcript:

1 DREAM PLAN IDEA IMPLEMENTATION 1

2 2

3 3 Introduction to Image Processing Dr. Kourosh Kiani Email: kkiani2004@yahoo.comkkiani2004@yahoo.com Email: Kourosh.kiani@aut.ac.irKourosh.kiani@aut.ac.ir Email: Kourosh.kiani@semnan.ac.irKourosh.kiani@semnan.ac.ir Web: www.kouroshkiani.comwww.kouroshkiani.com Present to: Amirkabir University of Technology (Tehran Polytechnic) & Semnan University

4 Lecture 02 Histogram 4

5 5

6 6

7 7

8 8

9 9

10 10

11 11

12  H(k) specifies the # of pixels with gray-value k  Let N be the number of pixels:  P(k) = H(k)/N defines the normalized histogram  defines the accumulated histogram Occurrence (# of pixels) Gray Level 12

13 Histogram Normalized Histogram Accumulated Histogram 13

14  The image histogram does not fully represent the image P(I) I I 1 1 0.5 H(I) I 0.1 H(I) I 0.1 Pixel permutation of the left image 14

15 2332 4243 3235 2424 4x4 image Gray scale = [0,9] histogram 01 1 2 2 3 3 4 4 5 5 6 6 789 No. of pixels Gray level 15

16 Gray Level(j) 0123456789 No. of pixels 0065410000 006111516 00 6 / 16 11 / 16 15 / 16 / 16 / 16 / 16 / 16 / 16 s x 9 00 3.3  3 6.1  6 8.4  8 99999 16

17 Grayscale Histogram 17

18 (3, 8, 5) 18

19 19

20 01124 21002 52004 11241 image histogram 20

21 117 83 59 59 68 77 84 94 82 67 62 70 83 86 85 81 71 65 77 89 86 82 76 67 72 90 97 86 66 54 68 104 121 107 85 46 58 89 138 165 137 91 38 80 147 200 211 187 138 40 80 149 197 202 187 146 56 76 114 159 181 160 113 valuecount 10 408 … … 10432 18145 2550 PARTIAL IMAGE INFO: 21

22 Plot of Pixel Count as a Function of Gray Level Value 22

23 The histogram of an image shows us the distribution of grey levels in the image Massively useful in image processing, especially in segmentation Grey Levels Frequencies 23

24 24

25 25

26 26

27 OriginalDark Light 27

28 28

29 An image has low contrast when the complete range of possible values is not used. Inspection of the histogram shows this lack of contrast. 29

30 30

31 rgbI = imread('kourosh.jpg'); grayI = rgb2gray(rgbI); %get image histogram [counts bins]=imhist(grayI); %show histogram bar(bins,counts); 31

32 rgbI = imread('kouroshdark.jpg'); grayI = rgb2gray(rgbI); %get image histogram [counts bins]=imhist(grayI); %show histogram bar(bins,counts); 32

33 rgbI = imread('kouroshbright.jpg'); grayI = rgb2gray(rgbI); %get image histogram [counts bins]=imhist(grayI); %show histogram bar(bins,counts); 33

34 I = imread('pic01.png'); %get image histogram [counts bins]=imhist(I); %show histogram bar(bins,counts); 34

35 I = imread('pic03.png'); %get image histogram [counts bins]=imhist(I); %show histogram bar(bins,counts); 35

36  The image shows the spatial distribution of gray values.  The image histogram discards the spatial information and shows the relative frequency of occurrence of the gray values. 36

37  The histogram typically plots the absolute pixel count as a function of gray value: For an image with dimensions M by N I max 37

38  The graph of relative frequency of occurrence as a function of gray value is also called a histogram:  Interpreting the relative frequency histogram as a probability distribution, then:  P(I(x,y) = i) = H(i)/(MxN) 38

39  Interpreting the relative frequency histogram as a probability distribution, then:  Curve is called the cumulative distribution function Gray Value P(I(x,y) = i) = H(i)/(MxN) 39

40  Image histograms consist of peaks, valleys, and low plains  Peaks = many pixels concentrated in a few grey levels  Plains = small number of pixels distributed over a wider range of grey levels 40

41  The goal is to modify the gray levels of an image so that the histogram of the modified image is flat.  Expand pixels in peaks over a wider range of gray-levels.  “Squeeze” low plains pixels into a narrower range of gray levels.  Utilizes all gray values equally  Example Histogram:  Note low utilization of small gray values 41

42  All gray levels are used equally.  Has a tendency to enhance contrast. 42

43 How are the gray levels in the original image changed to produce the enhanced image? Method 1. Choose points randomly. Method 2. Choice depends on the graylevels of their neighboring points. Computationally expensive. Approximations. 43

44  Mapping from one set of grey-levels, , to a new set, .  Ideally, the number of pixels, N p, occupying each grey level should be:  To approximate this, apply the transform  Where CH is the cumulative histogram (see next slide)  j is the gray value in the source image  i is the gray value in the equalized image N p = M*N G i = MAX 0, round CH(j) NpNp 44

45 800 600 400 200 0 0 1 2 3 4 5 6 8 ideal 800 600 400 200 0 G=8 MxN=2400 N p =300 jH(j)CH(j)i 01000 18002 27004 35006 41006 5 7 6 7 707 900 1600 2100 2200 2300 2400 CH(j) =  H(i) i=0 j 0 1 2 3 4 5 6 8 45

46 rgbI = imread('ship1.png'); J = histeq(rgbI); imshow(rgbI) figure, imshow(J) %get image histogram [counts bins]=imhist(rgbI); %show histogram figure(3) bar(bins,counts); %get image histogram [counts bins]=imhist(J); %show histogram figure(4) bar(bins,counts); 46

47 47

48 48

49 Histogram Equalization: Example 49

50 50

51 COLOR IMAGE 51

52 52

53 clc; % Clear the command window. close all; % Close all figures (except those of imtool.) imtool close all; % Close all imtool figures. clear; % Erase all existing variables. workspace; % Make sure the workspace panel is showing. fontSize = 20; % Read in standard MATLAB color demo image. rgbImage = imread('peppers.png'); [rows columns numberOfColorBands] = size(rgbImage); figure (1) imshow(rgbImage, []); redPlane = rgbImage(:, :, 1); greenPlane = rgbImage(:, :, 2); bluePlane = rgbImage(:, :, 3); % Let's get its histograms. [pixelCountR grayLevelsR] = imhist(redPlane); figure(2) %show histogram bar(grayLevelsR,pixelCountR,'r'); xlim([0 grayLevelsR(end)]); % Scale x axis manually. title('Histogram of red plane', 'Fontsize', fontSize); grid on; [pixelCountG grayLevelsG] = imhist(greenPlane); figure(3) %show histogram bar(grayLevelsG,pixelCountG,'g'); xlim([0 grayLevelsG(end)]); % Scale x axis manually. title('Histogram of green plane', 'Fontsize', fontSize); grid on; [pixelCountB grayLevelsB] = imhist(bluePlane); figure(4) %show histogram bar(grayLevelsB,pixelCountB,'b'); xlim([0 grayLevelsB(end)]); % Scale x axis manually. title('Histogram of blue plane', 'Fontsize', fontSize); grid on; 53

54 54

55 Questions? Discussion? Suggestions ? 55

56 56


Download ppt "DREAM PLAN IDEA IMPLEMENTATION 1. 2 3 Introduction to Image Processing Dr. Kourosh Kiani"

Similar presentations


Ads by Google