数字图像处理第六章
- 格式:ppt
- 大小:2.82 MB
- 文档页数:41
Digital Image ProcessingProject chapter:Chapter 6Project number:Proj06-01 ~ Proj06-04 Student's name:Student's number:Class:ContentsWEB-SAFE COLORS (2)PSEUDO-COLOR IMAGE PROCESSING (2)COLOR IMAGE ENHANCEMENT BY HISTOGRAM PROCESSING (5)COLOR IMAGE SEGMENTATION (7)Web-Safe ColorsExp. 20,PROJECT 06-01ObjectiveTo know what are Web-safe colors, how to generate the RGB components for a given jpeg color image, or convert an image to RGB manually?Requirements(a) Write a computer program that converts an arbitrary RGB color image to a web-safe RGB image (see Fig. 6.10 for a definition of web-safe colors).(b) Download the image in Fig. 6.8 and convert it to a web-safe RGB color image. Figure 6.8 is given in jpg format, so convert your result back to jpg (see comments at the beginning of this project).Figure 1 Fig6.08.jpgTechnical discussion【1】B = fix(A)rounds the elements of A toward zero, resulting in an array of integers.For complex A, the imaginary and real parts are rounded independently.【2】imwrite(A,filename,fmt)writes the image A to the file specified by filename in the format specified by fmt. Program listingsI=imread('Fig6.08.jpg');subplot(131);imshow(I);title('original');I1=fix((I/51)*51);subplot(132);imshow(I1);title('web-safe colors(jpg)');imwrite(I1,'web-safe colors.jpeg','jpeg');subplot(133);I=imread('web-safe colors.jpeg');imshow(I);title('web-safe colors(jpeg)');Discussion of resultsoriginal web-safe colors(jpg)web-safe colors(jpeg)Figure 2 results of project 06-01Pseudo-Col or Image ProcessingExp. 21,PROJECT 06-02ObjectiveTo know when the highpass filtering H hp(u,v) can be obtained by using the relation 1-H lp(u,v).Requirements(a)Implement Fig. 6.23, with the characteristic that you can specify two ranges of gray-level values for the input image and your program will output an RGB image whose pixels have a specified color corresponding to one range of gray levels in the input image, and the remaining pixels in the RGB image have the same shade of gray as they had in the input image.(b) Download the image in Fig. 6.22(a) and process it with your program so that the river appears yellow and the rest of the pixels are the same shades of gray as in the input image.Figure 3 Fig6.22(a).jpgTechnical discussion【1】RGB componentsrgb_R=I(:, :, 1);rgb_G=I(:, :, 2);rgb_B=I(:, :, 3);Program listingsI=imread('Fig6.22(a).jpg');subplot(121);imshow(I);title('original');I=double(I);[m,n]=size(I);L=256;for i=1:mfor j=1:nif I(i,j)<L/4R(i,j)=0;G(i,j)=4*I(i,j);B(i,j)=L;else if I(i,j)<=L/2R(i,j)=0;G(i,j)=L;B(i,j)=-4*I(i,j)+2*L;else if I(i,j)<=3*L/4R(i,j)=4*I(i,j)-2*L;G(i,j)=L;B(i,j)=0;elseR(i,j)=L;G(i,j)=-4*I(i,j)+4*L;B(i,j)=0;endendendendendfor i=1:mfor j=1:nG2C(i,j,1)=R(i,j);G2C(i,j,2)=G(i,j);G2C(i,j,3)=B(i,j);endendG2C=G2C/256;subplot(122);imshow(G2C);title('Pseudo-Color');Discussion of resultsoriginal Pseudo-ColorFigure 4 results of project 06-02Color Image Enhancement by Histogram ProcessingExp. 22,PROJECT 06-03ObjectiveTo know how to implement image enhancement for color images by histogram processing. Note that the definition of histogram for color images differs from that of histogram for gray images.RequirementsDownload the dark-stream color picture in Fig. 6.35. Histogram-equalize the R,G,and B images separately using the histogram-equalization program and convert the imageback to jpg format.Figure 5 Fig6.35(5).jpgTechnical discussion【1】C = cat(dim, A1, A2, A3, A4, ...)concatenates all the input arrays (A1, A2, A3, A4, and so on) along array dimension dim.Program listingsI=imread('Fig6.35(5).jpg');subplot(121);imshow(I);title('original');a=I(:,:,1);b=I(:,:,2);c=I(:,:,3);A=histeq(a);B=histeq(b);C=histeq(c);I3=cat(3,A,B,C);subplot(122);imshow(I3);title('histogram processing');Discussion of resultsoriginal histogram processingFigure 6 results of project 06-03Color Image SegmentationExp. 23,PROJECT 06-04ObjectiveColor image segmentation is a big issue in image processing. This students need to know the basics of this topic.RequirementsDownload Fig. 6.28(b) and duplicate Example 6.15, but segment instead the darkest regions in the image.Figure 7 Fig6.30(01).jpgTechnical discussion【1】RGB2 = im2double(RGB)converts the truecolor image RGB to double precision, rescaling the data if necessaryProgram listingsrgb=imread('Fig6.30(01).jpg');subplot(221);imshow(rgb);title('original');rgb1=im2double(rgb);r=rgb1(:,:,1);g=rgb1(:,:,2);b=rgb1(:,:,3);r1=r(129:256,86:170);r1_u=mean(mean(r1(:)));[m,n]=size(r1);sd1=0.0;for i=1:mfor j=1:nsd1=sd1+(r1(i,j)-r1_u)*(r1(i,j)-r1_u);endendr1_d=sqrt(sd1/(m*n));r2=zeros(size(rgb1,1),size(rgb1,2));ind=find((r>r1_u-1.25*r1_d)&(r<r1_u+1.25*r1_d));r2(ind)=1;subplot(222);imshow(r2);title('segmentation');subplot(234);imshow(r);title('R component');subplot(235);imshow(g);title('G component');subplot(236);imshow(b);title('B component');Discussion of resultsoriginal segmentationR component G component B componentFigure 8 results of project 06-04。