Description
Problem 1: Basic read and write images using Matlab
- Read and show the image lena.bmp (copy your code and the plot into your report).
- Convert the image into gray-scale using the Matlab’s built-in function rgb2gray.
- Write your own function my_rgb2gray to convert a RGB image to grayscale and test it on the lena.bmp image (show the image after being converted). Given that, for each pixel we have
𝑔𝑟𝑎𝑦 𝑠𝑐𝑎𝑙𝑒 𝑖𝑛𝑡𝑒𝑛𝑠𝑖𝑡𝑦 = 30% ∗ 𝑅 + 60% ∗ 𝐺 + 10% ∗ 𝐵
- Save the above gray-scale image to a file named lena_gray.jpg.
Problem 2: Histogram equalization (enhance the contrast of an image)
- Read and show the image lowcontrast.jpg.
- Show the histogram of the image using the function imhist.
- Using the function histeq to enhance contrast using histogram equalization, show the histogram and the image after enhancing.
Problem 3: Salt and pepper noise, median filter
- Add salt-and-pepper noise to the lena’s gray-scale image using the function imnoise. Assume that the noise density is 0.05 (read the function’s documentation for more information). Show the noisy image.
- Filter the noise using the function medfilt2 with the 3×3 window, show the filtered image.
- Filter the noise with the 5×5 window and show the filtered image; compare the filtered image to that of 3b). What happen when we increase the window size in the median filter?