Assignment #1
-
Reducing the Number of Gray Levels in an Image
(a) Write a computer program capable of reducing the number of gray levels in an image from 256 to 2, in integer powers of 2. The desired number of gray levels needs to be a variable input to your program.
(b) Download Fig. 2.21(a) and duplicate the results shown in Fig. 2.21 of the book. -
Zooming and Shrinking Images by Bilinear Interpolation
(a) Write a computer program capable of zooming and shrinking an image by bilinear interpolation. The input to your program is the desired size of the resulting image in the horizontal and vertical direction. You may ignore aliasing effects.
(b) Download Fig. 2.19 and use your program to shrink this image from 1024 x 1024 to 256 x 256 pixels.
© Use your program to zoom the image in (b) back to 1024 x 1024. Explain the reasons for their differences.
一、技术实现
1.降低图像灰度级
灰度图像是一种单色图像,该图像只有灰度等级,没有颜色变化。图像的灰度级是指图像中的亮度的最大值与最小值之差的级别,级数越多,图像的亮度范围越大,图像质量越高,级数越少则图像质量越差,当图像只有两个灰度色阶时,成为二值图像。
本实验中,要实现写一个Matlab函数,输入一个图像和整数n,给定图像的灰度级将以2的n次方减少,所采用的量化方法为:
灰度级数=(原灰度级数/量化级数)*量化级数n
2.双线性插值
双线性插值又称双线性内插,双线性插值算法通过计算原图像四个点的像素质来填充目标像素,并根据四个点对填充点的像素贡献度不一样而采用不同的权值,这样带来了平滑滤波的效果,使得图像的细节差生退化。
双线性差值公式:
二、实验结果
1.降低图像灰度级
输入图片Fig.2.21(a),并将图像灰度级将为2。
2.双线性差值实现图像的缩放
将Fig.2.19(a)由10241024缩小为256 256
将缩小为256256的图像再放大为1024 1024
对比同为1024*1