Presentation is loading. Please wait.

Presentation is loading. Please wait.

1-Introduction (Computing the image histogram).

Similar presentations


Presentation on theme: "1-Introduction (Computing the image histogram)."— Presentation transcript:

1 ...Presentation Content of Chapter 4 (Counting the Pixels with Histograms).....
1-Introduction (Computing the image histogram). 2-Applying look-up tables to image appearance. 3-Equalizing the image histogram. 4-Back_projecting a histogram to detect specific image content. 5-Using the mean shift algorithm to find an object. 6-Retrieving similar images using histogram comparison. 7-Questions. #Galaxy_Flutes_Time :) ;) :)

2 Introduction (Computing the image histogram)
An image is composed of pixels of different values (colors). An image is made of pixels, each of them having different values. For example, in a 1-channel gray-level image, each pixel has a value between 0 (black) and 255 (white). Depending on the picture content The distribution of pixels values across the image constitutes an important characteristic of this image.

3 ...Presentation Content..... 1-Introduction (Computing the image histogram). 2-Applying look-up tables to image appearance. 3-Equalizing the image histogram. 4-Back_projecting a histogram to detect specific image content. 5-Using the mean shift algorithm to find an object. 6-Retrieving similar images using histogram comparison. 7-Questions. #Galaxy_Flutes_Time :) ;) :)

4 Introduction (Computing the image histogram)
A histogram is a simple table that gives the number of pixels that have a given value in an image (or sometime a set of images). The histogram of a gray-level image will therefore have 256 entries (or bins). Bin 0 gives the number of pixels having value 0, bin 1 the number of pixels having value 1, and so on. Obviously, if you sum all of the entries of a histogram, you should get the total number of pixels. Histograms can also be normalized such that sum of the bins equals 1. In that case, each bin gives the percentage of pixels having this specific value in the image.

5 Computing a histogram in OpenCV
Computing a histogram with OpenCV can be easily done by using the cv::calcHist function. This is a general function which can compute the histogram of multiple channel images of any pixel value type.

6 Apply coding in Page (90&91)

7 Output of previous code

8 Output of previous code

9 Apply code in page(92&93)

10 Output of previous code

11 Apply code in page(93&94)

12 Output of previous code

13 Apply code in page(94&95&96)

14 Output of previous code

15 Applying look-up tables to image appearance
Image histograms capture the way a scene is rendered using the available pixel intensity values. By analyzing the distribution of the pixel values over an image, it is possible to use this information to modify and possibly improve an image. This recipe explains how one can use a simple mapping function, represented by a look-up table, to modify the pixel values of an image.

16 Applying look-up tables to image appearance
A look-up table is a simple one-to- one (or many-to-one) function that defines how pixel values are transformed into new values. It is a 1D array with, in the case of regular gray-level images, 256 entries. Entry i of the table gives the new intensity value of the corresponding gray level, that is: newIntensity= lookup[oldIntensity];

17 Apply LUT in OpenCV Function cv::LUT in OpenCV applies a look-up table to an image in order to produce a new image. We can add this function to our Histogram1D class: cv::Mat applyLookUp(const cv::Mat& image, // input image const cv::Mat& lookup) { // 1x256 uchar matrix // the output image cv::Mat result; // apply lookup table cv::LUT(image,lookup,result); return result; }

18 Apply code in pages(97&98&99)

19 Output of previous code

20 Code in page with output(99&100)

21 Equalizing the image histogram
The histogram shown in the first recipe of this chapter is a good example of this phenomenon. The middle-gray intensities are indeed heavily represented, while darker and brighter pixel values are rather rare. In fact, one can think that a good- quality image should make equal use of all available pixel intensities. This is the idea behind the concept of histogram equalization, that is making the image histogram as flat as possible.

22 Histogram Equalization in OpenCV
OpenCV offers an easy-to-use function that performs histogram equalization. It can be called as follows: cv::Mat equalize(const cv::Mat &image) { cv::Mat result; cv::equalizeHist(image,result); return result; }

23 Apply code in page with output (101&102)

24 Back_Projecting A histogram is an important characteristic of an image's content. If you look at an image area showing a particular texture or a particular object, then the histogram of this area can be seen as a function giving the probability that a given pixel belongs to this specific texture or object. In this recipe, you will learn how the image histogram can be advantageously used to detect specific image content.

25 Back_Projection in OpenCV
cv::Mat imageROI; imageROI= image(cv::Rect(360,55,40,50)); // Cloud region You then extract the histogram of this ROI. This is easily accomplished using the Histogram1D class defined in the first recipe of this chapter: Histogram1D h; cv::MatND hist= h.getHistogram(imageROI); By normalizing this histogram, we obtain a function that gives the probability of a pixel of a given intensity value to belong to the defined area: cv::normalize(histogram,histogram,1. 0);

26 Steps of algorithm

27 Main techniques

28 Apply code in page( )

29 Output of code

30 Using the mean shift algorithm to find an object.
The result of a histogram backprojection is a probability map that expresses the probability that a given image content is found at a specific image location. Suppose we now know the approximate location of an object in an image, the probability map can be used to find the exact location of the object. The most probable will be the one that maximizes this probability inside a given window. Therefore, if we start from an initial, location and iteratively move around, it should be possible to find the exact object location. This is what is accomplished by the mean shift algorithm.

31

32

33 Histogram comparison Content-based image retrieval is an important problem in computer vision. It consists of finding a set of images presenting content similar to a given query image. Since we have learned that histograms constitute an effective way to characterize an image's content, it makes sense to think that they can be used to solve the content-based retrieval problem. The key here is to be able to measure the similarity between two images by simply comparing their histograms. A measurement function which will estimate how different, or how similar, two histograms are will need to be defined. Various such measures have been proposed in the past, and OpenCV proposes few of them in its implementation of the cv::compareHist function.

34 First technique of histogram comparison(Metrics)

35 First technique of histogram comparison(Earth Mover)

36 Apply code in page(113&114)

37 Output of previous code
What does this program do? 1-Loads a base image and 2 test images to be compared with it. 2-Generate 1 image that is the lower half of the base image. 3-Convert the images to HSV format 4-Calculate the H-S histogram for all the images and normalize them in order to compare them. 5-Compare the histogram of the base image with respect to the 2 test histograms, the histogram of the lower half base image and with the same base image histogram. 6-Display the numerical matching parameters obtained.

38 Another code running

39 Output of previous code

40 Questions Time #enjoy 1. In _______ image we notice that the components of histogram are concentrated on the low side on intensity scale. a) bright b) dark c) colourful d) All of the Mentioned 2. What is Histogram Equalisation also called as? a) Histogram Matching b) Image Enhancement c) Histogram linearisation d) None of the Mentioned

41 Notes:: if u solve 4 questions correctly u win a galaxy flutes …...
Questions time #enjoy 3. Histogram Equalisation is mainly used for _________________________. a) Image enhancement b) Blurring c) Contrast adjustment d) None of the Mentioned 4. The type of Histogram Processing in which pixels are modified based on the intensity distribution of the image is called _______________. a) Intensive b) Local c) Global d) Random Notes:: if u solve 4 questions correctly u win a galaxy flutes …...

42 Answers 1. In _______ image we notice that the components of histogram are concentrated on the low side on intensity scale. a) bright b) dark c) colourful d) All of the Mentioned View Answer Answer: b 2. What is Histogram Equalisation also called as? a) Histogram Matching b) Image Enhancement c) Histogram linearisation d) None of the Mentioned View Answer Answer: c

43 Answers 3. Histogram Equalisation is mainly used for _________________________. a) Image enhancement b) Blurring c) Contrast adjustment d) None of the Mentioned View Answer Answer: a 4. The type of Histogram Processing in which pixels are modified based on the intensity distribution of the image is called _______________. a) Intensive b) Local c) Global d) Random View Answer Answer: c

44 Members of Group: Yasmin Salah Ibrahim(Leader Of Group).
Mona Mahmoud Sabry Ashour. Maha Abd-Elnasir El-rayes.


Download ppt "1-Introduction (Computing the image histogram)."

Similar presentations


Ads by Google