1、EBU723U Image and Video Processing 2014/15Coursework report and exercisesName:_Yu Ma_Username:_jp10212769_Exercise 1 (a)Reading/writing PGM/PPM images: The first step towards image and video processing is reading images from file and write them to file. There exist different standards that store the
2、 information in different formats; before opening an image, knowledge of the standard is necessary. Two widely used image formats are PPM and PGM. The PGM format is a greyscale file format designed to be easy to manipulate. A PGM image represents a greyscale graphic image. For most purposes, a PGM i
3、mage can just be thought of an array of integers. The name PGM is the acronym of Portable Grey Map. The name PPM is the acronym for Portable Pixel Map. Images in this format (or a precursor of it) were once also called portable pixmaps. It is a highly redundant format, and contains a lot of informat
4、ion that the Human Visual System (HVS) cannot even discern. However, as PGM, PPM is very easy to write and analyze. The goal of the first part of todays lab is to let students become comfortable with these two formats. You will implement functions to read and to write PPM and PGM images. The final d
5、emonstration of the implemented software will be done using well-known test images: LENA, BABOON, PEPPERS, etc. You can find PPM and PGM versions of these images in the EBU723U intranet pages. The writing function must add as comment in the header: “image created by your_name your_surname”. Include
6、in your submission the file resulting from reading the images provided and writing them back in their original format.Summarize in 5 points the operations necessary to read a PGM/PPM image:1. Open the image in read mode.2. Ignore comments in the file3. Distinguish the image is a PGM or PPM.4. Read i
7、nformation of the image.5. Read matrix.Summarize in 5 points the operations necessary to write a PGM/PPM image:1. Open the image in write mode.2. Write comments in the file.3. Decide writting a PGM or PPM image.4. Write information of the image.5. Write matrix.What is the difference between the iden
8、tifier P3 and P6?For identifier P3,the image is stored as ASCII and each line is less than 70 characters.For identifier P6,the image is stored as binary.P6 format is smaller than P3 format and read P6 format file is faster than P3 format file.Exercise 1 (b)Format conversions: in this part of the lab
9、, the images will be converted from colour to grey scale; in other words a PPM image will be converted to the PGM format. You will implement a function called “BUPT_format_converter” which transforms images from color to grey-scale using the following YUV conversion:Y = 0.257R + 0.504G + 0.098B + 16
10、U = 0.439R + 0.368G 0.071B + 128V = -0.148R 0.291G + 0.439B + 128What component represents the luminance, i.e. the grey-levels, of an image? Y represents the luminance.Use thee boxes to display the results for the colour to grey-scale conversion. Lena colour (RGB)Lena greyBaboon greyBaboon colour (R
11、GB)Is the transformation between the two colour-spaces linear? Motivate your answerThe transformation between the two colour-spaces is linear.Transform each layer,then combine each outcome.Or Transform layers together.These two outcomes are same.f(ax+by) = af(x)+bf(y)Display in the box the Lena imag
12、e converted to YUV 3 channels format. Are the colors of the previous picture distorted? If yes why?They are different.Because RGB used for PC and YUV used for TV.If we show YUV image on PC,it will be distorted.Based on the formula for the RGB to YUV conversion, derive the formula for the YUV to RGB
13、conversion?R=1.164*(Y-16)+1.596*(V-128)G=1.164*(Y-16)-0.813*(V-128)-0.391*(U-128)B=1.164*(Y-16)+2.018*(U-128)Use the formula you derived at the previous step to convert the YUV image back to the original RGB format. Display the result in the box.Exercise 1 (c)Sub-sampling: The HVS is incapable of pe
14、rceiving certain details in an image. Therefore high compression ratios can be achieved by exploiting the characteristics of the HVS, thus discarding what has a low visual relevance. However, this process can introduce distortions in the compressed data. A simple way to exploit the characteristics o
15、f the HVS compression purposes is to sub-sample an image. A drawback of this approach is that it is possible to incur in well-know problems of a discrete representation, such as aliasing. This part of the lab covers some simple sub-sampling operations.Implement a function that sub-samples grey level images by a factor n, with n a multiple of 2. The function should be able to sub-sample independently in the horizontal and in the vertical direction or in both directions at the same time. Display the results of su