文档详情

digital image processing projects 数字图像处理 冈萨雷斯 第二章所有程序和报告.doc

发布:2017-12-18约5.45千字共13页下载文档
文本预览下载声明
Digital Image Processing Project chapter: Chapter 2 Project number: Proj02-03 ~ Proj02-04 Students name: Students number: Class: Contents Reducing the Number of Gray Levels in an Image 2 Zooming and Shrinking Images by Pixel Replication 4 Zooming and Shrinking Images by Bilinear Interpolation 8 Reducing the Number of Gray Levels in an Image Exp. 2,PROJECT 02-02 Objective To understand how the number of gray levels affect the image perceptual quality. Requirements Write a computer program capable of reducing the number of gray levels in Fig. 2.21(a) from 256 to 2, in integer powers of 2. Figure 1 2.21(a) Technical discussion 【1】imread(‘filename’) attempts to infer the format of the file from its content. 【2】imshow(I) displays the grayscale image I. 【3】C = bitshift(A, k) returns the value of A shifted by k bits. Program listings 【1】function of gray level reducing function fk=leftbitmaps(f,k) % f should be a uint8 image if k7 error(top bit map number should be less than 7); end bitout=(8-k); % numbers of bit map to be droped from right fk=bitshift(f,-bitout); fk=bitshift(fk,bitout); 【2】main fuction I = imread(Fig2.21(a).jpg); I1=uint8(I); figure; subplot(241); imshow(I1); title(Gray Level of 256); I2=leftbitmaps(I1,7); subplot(242); imshow(I2); title(Gray Level of 128); I3=leftbitmaps(I1,6); subplot(243); imshow(I3); title(Gray Level of 64); I4=leftbitmaps(I1,5); subplot(244); imshow(I4); title(Gray Level of 32); I5=leftbitmaps(I1,4); subplot(245); imshow(I5); title(Gray Level of 16); I6=leftbitmaps(I1,3); subplot(246); imshow(I6); title(Gray Level of 8); I7=leftbitmaps(I1,2); subplot(247); imshow(I7); title(Gray Level of 4); I8=leftbitmaps(I1,1); subplot(248); imshow(I8); title(Gray Level of 2); Discussion of results Figure 2 results of projec
显示全部
相似文档