digital image processing projects 数字图像处理 冈萨雷斯 第六章所有程序和报告Word下载.docx
《digital image processing projects 数字图像处理 冈萨雷斯 第六章所有程序和报告Word下载.docx》由会员分享,可在线阅读,更多相关《digital image processing projects 数字图像处理 冈萨雷斯 第六章所有程序和报告Word下载.docx(10页珍藏版)》请在冰豆网上搜索。
Objective
ToknowwhatareWeb-safecolors,howtogeneratetheRGBcomponentsforagivenjpegcolorimage,orconvertanimagetoRGBmanually?
Requirements
(a)WriteacomputerprogramthatconvertsanarbitraryRGBcolorimagetoaweb-safeRGBimage(seeFig.6.10foradefinitionofweb-safecolors).
(b)DownloadtheimageinFig.6.8andconvertittoaweb-safeRGBcolorimage.Figure6.8isgiveninjpgformat,soconvertyourresultbacktojpg(seecommentsatthebeginningofthisproject).
Figure1Fig6.08.jpg
Technicaldiscussion
【1】B=fix(A)
roundstheelementsofAtowardzero,resultinginanarrayofintegers.ForcomplexA,theimaginaryandrealpartsareroundedindependently.
【2】imwrite(A,filename,fmt)
writestheimageAtothefilespecifiedbyfilenameintheformatspecifiedbyfmt.
Programlistings
I=imread('
Fig6.08.jpg'
);
subplot(131);
imshow(I);
title('
original'
I1=fix((I/51)*51);
subplot(132);
imshow(I1);
web-safecolors(jpg)'
imwrite(I1,'
web-safecolors.jpeg'
'
jpeg'
subplot(133);
web-safecolors(jpeg)'
Discussionofresults
Figure2resultsofproject06-01
Pseudo-ColorImageProcessing
Exp.21,PROJECT06-02
ToknowwhenthehighpassfilteringHhp(u,v)canbeobtainedbyusingtherelation1-Hlp(u,v).
(a)ImplementFig.6.23,withthecharacteristicthatyoucanspecifytworangesofgray-levelvaluesfortheinputimageandyourprogramwilloutputanRGBimagewhosepixelshaveaspecifiedcolorcorrespondingtoonerangeofgraylevelsintheinputimage,andtheremainingpixelsintheRGBimagehavethesameshadeofgrayastheyhadintheinputimage.
(b)DownloadtheimageinFig.6.22(a)andprocessitwithyourprogramsothattheriverappearsyellowandtherestofthepixelsarethesameshadesofgrayasintheinputimage.
Figure3Fig6.22(a).jpg
【1】RGBcomponents
rgb_R=I(:
:
1);
rgb_G=I(:
2);
rgb_B=I(:
3);
Fig6.22(a).jpg'
subplot(121);
I=double(I);
[m,n]=size(I);
L=256;
fori=1:
m
forj=1:
n
ifI(i,j)<
L/4
R(i,j)=0;
G(i,j)=4*I(i,j);
B(i,j)=L;
elseifI(i,j)<
=L/2
G(i,j)=L;
B(i,j)=-4*I(i,j)+2*L;
=3*L/4
R(i,j)=4*I(i,j)-2*L;
B(i,j)=0;
else
R(i,j)=L;
G(i,j)=-4*I(i,j)+4*L;
end
end
G2C(i,j,1)=R(i,j);
G2C(i,j,2)=G(i,j);
G2C(i,j,3)=B(i,j);
G2C=G2C/256;
subplot(122);
imshow(G2C);
Pseudo-Color'
Figure4resultsofproject06-02
ColorImageEnhancementbyHistogramProcessing
Exp.22,PROJECT06-03
Toknowhowtoimplementimageenhancementforcolorimagesbyhistogramprocessing.Notethatthedefinitionofhistogramforcolorimagesdiffersfromthatofhistogramforgrayimages.
Downloadthedark-streamcolorpictureinFig.6.35.Histogram-equalizetheR,G,andBimagesseparatelyusingthehistogram-equalizationprogramandconverttheimagebacktojpgformat.
Figure5Fig6.35(5).jpg
【1】C=cat(dim,A1,A2,A3,A4,...)
concatenatesalltheinputarrays(A1,A2,A3,A4,andsoon)alongarraydimensiondim.
Fig6.35(5).jpg'
a=I(:
:
1);
b=I(:
2);
c=I(:
3);
A=histeq(a);
B=histeq(b);
C=histeq(c);
I3=cat(3,A,B,C);
imshow(I3);
histogramprocessing'
Figure6resultsofproject06-03
ColorImageSegmentation
Exp.23,PROJECT06-04
Colorimagesegmentationisabigissueinimageprocessing.Thisstudentsneedtoknowthebasicsofthistopic.
DownloadFig.6.28(b)andduplicateExample6.15,butsegmentinsteadthedarkestregionsintheimage.
Figure7Fig6.30(01).jpg
【1】RGB2=im2double(RGB)
convertsthetruecolorimageRGBtodoubleprecision,rescalingthedataifnecessary
rgb=imread('
Fig6.30(01).jpg'
subplot(221);
imshow(rgb);
rgb1=im2double(rgb);
r=rgb1(:
g=rgb1(:
b=rgb1(:
r1=r(129:
256,86:
170);
r1_u=mean(mean(r1(:
)));
[m,n]=size(r1);
sd1=0.0;
sd1=sd1+(r1(i,j)-r1_u)*(r1(i,j)-r1_u);
r1_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);
segmentation'
subplot(234);
imshow(r);
Rcomponent'
subplot(235);
imshow(g);
Gcomponent'
subplot(236);
imshow(b);
Bcomponent'
Figure8resultsofproject06-04