HOMEWORK01

Image resizing is a widely use operation in image processing. Either for scaling up and for scaling down we need interpolation to find corresponding pixel intensity in the resulting image. Choice of the interpolation method is so important that it directly increases or decreases the quality of the resulting image.

Recalling the last lecture; we have seen three main interpolation methods:

If you look at pillows reference page you can see that the resize() function has predefined resampling functions namely:

From which the first three are the methods we have seen in the lecture. LANCZOS is a more sophisticated method which gives better results compared to first three methods. If you’re interested search the internet for more details on LANCZOS Resampling Method.

In this homework you will implement a jupyter notebook script and it will perform these operations:

PSNR (Peak signal to Noise Ratio): PSNR is a metric which measures the difference between two images. We can define it as Equation \eqref{eq:PSNR}, where R is the maximum intensity observed in the source image. MSE is the mean square cumulative difference between the source and the target image.

\[\begin{equation} PSNR = 10 log_{10}(\frac{R^2}{MSE})\label{eq:PSNR} \end{equation}\]

The following function can be used to calculate PSNR between a source (im1) and target (im2) image.

def PSNR(im1,im2):
	R2 = np.amax(im1)**2
	MSE =  np.sum(np.power(np.subtract(im1,im2),2))
	MSE /= (im1.size[0]*im1.size[1])
	PSNR = 10*np.log10(R2/MSE)
	return PSNR

Your program will create a inline 3 by 1 matplotlib plot, by using subplot method, inside your ipython notebook file which looks as follows.

png

From left to right:

x axis of the figures should be the corresponding PSNR value with respect to original input image where y axis of the figures should be the interpolation method.

Your homework file should contain not only the python script performing desired task but also your explanations and your interpretations. For example make the following interpretations in your homework in your own words:

HOMEWORK SUBMISSION GUIDELINE:

The homework submission guideline is of grave importance for this course. Improper submissions will not be graded!.