Sunday, May 11, 2014

Fundamentals of Digital Image and Video Processing - Week 5 Solutions

Hi Coursera people,

This week's videos were large and I expected the assignment also to be challenging. On the contrary, the assignment was a very simple and was a replica of week 1's assignment.

Here is the question number 7 of week 5 :

In this problem you will perform median filtering to enhance the quality of a noise corrupted image. Recall from the video lecture that median filtering is effective for removing "salt-and-pepper" noise from images. Follow the instructions below to complete this problem. (1) Download the noisy image from here. Load the noisy image into a MATLAB array and convert the type of the array from 8-bit integer 'uint8' to real number 'double'. Refer to MATLAB problems in previous homework if you need help with loading and converting images. Visualize the noisy image using the built-in MATLAB function "imshow". The function "imshow" takes as its argument either [0-255] for an 8-bit integer array (i.e., of type 'uint8'), or [0-1] for a normalized real-valued array (i.e., of type 'double'). To provide "imshow" with the correct argument, you would need either to "cast" your real-valued array into 'uint8', or normalize it by 255. (2) Perform 3x3 median filtering using the built-in MATLAB function "medfilt2". For this problem, the only argument you need to provide "medfilt2" with is the array you have created in step (1). Visualize the filtered image using "imshow". Remember to either cast the result to 'uint8' or normalize it before feeding it to "imshow". (3) Perform a second-pass median filtering on the filtered image that you have obtained from step (2). Visualize the two-pass filtered image. Compare it with the noisy input image and the 1-pass filtered image. (4) Download the noise-free image from here. Compute the PSNR values between (a) the noise-free image and the noisy input image, (b) the noise-free image and the 1-pass filtering output, and (c) the noise-free image and the 2-pass filtering output. Enter the three PSNR values in the box below. Enter the numbers to two decimal points.

And here's my attempt at the code :

A = imread('C:\xxxxxx\Week 5\digital-images-week5_quizzes-noisy.jpg');
B = im2double(A);
C = medfilt2(B,[3 3]);
D = medfilt2(C,[3 3]);
E = imread('C:\xxxxxx\Week 5\digital-images-week5_quizzes-original.jpg');
F = im2double(E);
MaxI=1;
MSE1= mean(mean((F- B).^2));
PSNR1 = 10*log10((MaxI^2)/MSE1);
MSE2 = mean(mean((F-C).^2));
PSNR2 = 10*log10((MaxI^2)/MSE2);
MSE3 = mean(mean((F-D).^2));
PSNR3 = 10*log10((MaxI^2)/MSE3);


-Cheers,

Vijay.

7 comments:

  1. HW 6: This is very tricky. Have you got any solution yet?
    Question 6
    This problems pertains to inverse filtering. You should review the corresponding slides in the video lectures to refresh your memory before attempting this problem. To help you understand how inverse filter is implemented and applied, we have provided you with a MATLAB script here. Download the script and the original image, and open the script using MATLAB. Once you open the script, you will see on Line 8 the statement "T = 1e-1". This defines the threshold value used in the inverse filter. The script simulates the blur due to motion and applies inverse filtering for its removal. We encourage you to try different values of the threshold and see how it affects the performance of the inverse filter. We ask you to enter the ISNR value below when the threshold is set to 0.5. Make sure you enter the number with at least 2 decimal points.

    ReplyDelete
  2. Hi Hoa Hue,

    Yes, I agree this was a tricky question, especially as the resources in the world wide web on ISNR are limited! But I managed to get the solution right! Check my Week 6 solutions :)

    ReplyDelete
    Replies
    1. bro.... can u help me with this question ... actually i have got the same tricky question for my assignment of digital image processing. it will really help me a lot.

      Delete
  3. I got it, but i am in doubt my understanding about Mathwokrs. Thank you for your explanation

    ReplyDelete
  4. Great insights on Week 5 solutions for Digital Image and Video Processing! Utilizing clear fonts like FiraCode can significantly improve code readability, making complex concepts easier to grasp

    ReplyDelete