数字图像处理第一次作业1.docx

上传人:b****6 文档编号:4016424 上传时间:2022-11-27 格式:DOCX 页数:11 大小:1.06MB
下载 相关 举报
数字图像处理第一次作业1.docx_第1页
第1页 / 共11页
数字图像处理第一次作业1.docx_第2页
第2页 / 共11页
数字图像处理第一次作业1.docx_第3页
第3页 / 共11页
数字图像处理第一次作业1.docx_第4页
第4页 / 共11页
数字图像处理第一次作业1.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

数字图像处理第一次作业1.docx

《数字图像处理第一次作业1.docx》由会员分享,可在线阅读,更多相关《数字图像处理第一次作业1.docx(11页珍藏版)》请在冰豆网上搜索。

数字图像处理第一次作业1.docx

数字图像处理第一次作业1

P1:

(a)Loadtheimageslena.tifandmandril.tifinMatlab.Whatarethesizesofthetwoimages?

Useimread()toloadtheimagesinMatlab.Youcanfindoutthesizeoftheimagesbyusingthecommandsize()orwhostolookattheMatlabworkspace.

Answer:

Thesizeoflena.tifis(512,512)andsizeofmandril.tifis(256,256).

(b)Whatarethevaluesofpixelslena(29,86)andmandril(198,201).Notethatforus(basedonthenotationfollowedinthetextbook)imagematrixindicesstartfrom(0,0).InMatlabthematrixindicesstartfrom(1,1).

Answer:

lena(29,86)isactuallythepixelof30throwand87thcolumn,sothevalueofpixellena(29,86)is105;

mandril(198,201)isactuallythepixelof199throwand202thcolumn,sothevalueofpixelmandril(198,201)is158.

(c)Plotthe103rdrowoflena.Plotthe69thcolumnofmandril.Usetheplot()commandtoplottherow/column.

Answer:

Plotthe103rdrowoflena:

Plotthe69thcolumnofmandril:

(d)Generateanddrawtheimageshownbelowwheretheimagesub-block(ofsize128x128)onthetop-leftcornercomesfrommandril.Therestoftheimageisfromlena.Useimshow()todrawtheimage.

Answer:

P2:

Useimread()toloadtheimageinMatlab.Youcanseetheinitialimageconsistsofeightbitsofdataforeachpixel.Pleasecreatenewimagesusing5,4,3,2and1bitonlyforeachpixel.Howmanybitsareneededtopreserveimagequality?

Doesitchangefromplacetoplaceintheimage?

Howso?

Answer:

Imageusing5bitforeachpixel:

程序代码如下:

campusdrive=imread('campusdrive.tif');

cam=double(campusdrive);

cam5=floor(cam/8);

%将原来的256个灰度级按比例减少为32个灰度级

cam5=cam5*8;

%为32个灰度级重新分配亮度(0为黑色,31为白色)

cam5=uint8(cam5);

imshow(cam5);

Imageusing4bitforeachpixel:

程序代码如下:

campusdrive=imread('campusdrive.tif');

cam=double(campusdrive);

cam4=floor(cam/16);

%将原来的256个灰度级按比例减少为16个灰度级

cam4=cam4*16;

%为16个灰度级重新分配亮度(0为黑色,15为白色)

cam4=uint8(cam4);

imshow(cam4);

Imageusing3bitforeachpixel:

程序代码如下:

campusdrive=imread('campusdrive.tif');

cam=double(campusdrive);

cam3=floor(cam/32);

%将原来的256个灰度级按比例减少为8个灰度级

cam3=cam3*32;

%为8个灰度级重新分配亮度(0为黑色,7为白色)

cam3=uint8(cam3);

imshow(cam3);

Imageusing2bitforeachpixel:

程序代码如下:

campusdrive=imread('campusdrive.tif');

cam=double(campusdrive);

cam2=floor(cam/64);

%将原来的256个灰度级按比例减少为4个灰度级

cam2=cam2*64;

%为4个灰度级重新分配亮度(0为黑色,3为白色)

cam2=uint8(cam2);

imshow(cam2);

Imageusing1bitforeachpixel:

程序代码如下:

campusdrive=imread('campusdrive.tif');

cam=double(campusdrive);

cam1=floor(cam/64);

%将原来的256个灰度级按比例减少为2个灰度级

cam1=cam1*64;

%为2个灰度级重新分配亮度(0为黑色,1为白色)

cam1=uint8(cam1);

imshow(cam1);

观察发现,5bits基本可以保持图像质量,使之不出现伪轮廓,少于5bits图像会出现伪轮廓;

P3:

Subtractingtogetimagechange.Downloadimagescarvision1.tifandcarvision2.tiffrom

(a)LoadthetwoimagesinMatlab.Determinethelinelengthanddisplaytheimages.

Answer:

Thelengthofthetwoimagesis640;

Toshowthetwoimages,

Carvision1:

Carvision2:

(b)Comparethetwoimagesandnoteanydifferences.

Answer:

Thelocationofthetwocarsintheimagesisdifferent.

(c)Subtractthesecondimagefromthefirstanddisplaythedifferencetohighlightanychangesintheimage.Whatpartsoftheimagearehighlighted,andwhy?

Answer:

car1=imread('carvision1.tif');

car2=imread('carvision2.tif');

dcar1=double(car1);

dcar2=double(car2);

dcar=dcar1-dcar2;

car=abs(dcar);

car=uint8(car);

imshow(car>100);

imshow(im2bw(car));

车辆前后不同位置被高亮显示,因为两幅图片中车位置不同,不同处会被高亮显示。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 节日庆典

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1