



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上哈哈哈MATLAB显示正炫余炫图:plot(x,y1,'* r',x,y2,'o b')定义【0,2】;t=0:pi/10:2*pi;定义函数文件:function 返回变量列表=函数名(输入变量列表)顺序结构:选择结构1)if-else-end语句其格式为:if 逻辑表达式程序模块1;else程序模块2;End图片读取:%选择图片路径filename, pathname = . uigetfile('*.jpg''*.bmp''*.gif','选择图片'); %合成路径+
2、文件名 str=pathname,filename;%为什么pathname和filename要前面出现的位置相反才能运行呢?%读取图片 im=imread(str); %使用图片 axes(handles.axes1); %显示图片 imshow(im);边缘检测:global im str=get(hObject,'string');axes (handles.axes1);switch str case ' 原图 ' imshow(im); case 'sobel' BW = edge(rgb2gray(im),'sobel'
3、;); imshow(BW); case 'prewitt' BW = edge(rgb2gray(im),'prewitt'); imshow(BW); case 'canny' BW = edge(rgb2gray(im),'canny'); imshow(BW); Canny算子边缘定位精确性和抗噪声能力效果较好,是一个折中方案end; 开闭运算:se=1,1,1;1,1,1;1,1,1;1,1,1; %Structuring ElementI=rgb2gray(im);imshow(I,);title('Origi
4、nal Image');I=double(I);im_height,im_width=size(I);se_height,se_width=size(se);halfheight=floor(se_height/2);halfwidth=floor(se_width/2);se_origin=floor(size(se)+1)/2);image_dilation=padarray(I,se_origin,0,'both'); %Image to be used for dilationimage_erosion=padarray(I,se_origin,256,'
5、;both'); %Image to be used for erosion% Dilation %for k=se_origin(1)+1:im_height+se_origin(1) for kk=se_origin(2)+1:im_width+se_origin(2) dilated_image(k-se_origin(1),kk-se_origin(2)=max(max(se+image_dilation(k-se_origin(1):k+halfheight-1,kk-se_origin(2):kk+halfwidth-1); endendfigure;imshow(dila
6、ted_image,);title('Image after Dilation');% Erosion %se=se'for k=se_origin(2)+1:im_height+se_origin(2) for kk=se_origin(1)+1:im_width+se_origin(1) eroded_image(k-se_origin(2),kk-se_origin(1)=min(min(image_erosion(k-se_origin(2):k+halfwidth-1,kk-se_origin(1):kk+halfheight-1)-se); endendfi
7、gure;imshow(eroded_image,);title('Image after Erosion');% Opening(Erosion first, then Dilation) %se=se'image_dilation2=eroded_image; %Image to be used for dilationfor k=se_origin(1)+1:im_height-se_origin(1) for kk=se_origin(2)+1:im_width-se_origin(2) opening_image(k-se_origin(1),kk-se_or
8、igin(2)=max(max(se+image_dilation2(k-se_origin(1):k+halfheight-1,kk-se_origin(2):kk+halfwidth-1); endendfigure;imshow(opening_image,);title('Opening Image');% Closing(Dilation first, then Erosion) %se=se'image_erosion2=dilated_image; %Image to be used for erosionfor k=se_origin(2)+1:im_h
9、eight-se_origin(2) for kk=se_origin(1)+1:im_width-se_origin(1) closing_image(k-se_origin(2),kk-se_origin(1)=min(min(image_erosion2(k-se_origin(2):k+halfwidth-1,kk-se_origin(1):kk+halfheight-1)-se); endendfigure;imshow(closing_image,);title('Closing Image');Warning: Image is too big to fit on
10、 screen; displaying at 31% scale.> In truesize>Resize1 at 308 In truesize at 44 In imshow at 161图像的直方图归一化:I=imread(red.bmp);%读入图像figure;%打开新窗口 M,N=size(I);%计算图像大小 counts,x=imhist(I,32);%计算有32个小区间的灰度直方图 counts=counts/M/N;%计算归一化灰度直方图各区间的值 stem(x,counts);%绘制归一化直方图图像平移:I=imread('shuichi.jpg
11、9;);se=translate(strel(1),180 190);B=imdilate(I,se);figure;subplot(1,2,1),subimage(I);title('原图像');subplot(1,2,2),subimage(B);title('平移后图像');图像的转置;A=imread('nir.bmp');tform=maketform('affine',0 1 0;1 0 0;0 0 1);B=imtransform(A,tform,'nearest');figure;imshow(A)
12、;figure;imshow(B);imwrite(B,'nir转置后图像.bmp'); 图像滤波:B = imfilter(A,H,option1,option2,.)或写作g = imfilter(f, w, filtering_mode, boundary_options, size_options)其中,f为输入图像,w为滤波掩模,g为滤波后图像。filtering_mode用于指定在滤波过程中是使用“相关”还是“卷积”。boundary_options用于处理边界充零问题,边界的大小由滤波器的大小确定。具体参数选项见下表:选项描述filtering_modecorr通过使用相关来完成,该值为默认。conv通过使用卷积来完成boundary_optionsX输入图像的边界通过用值X(无引号)来填充扩展其默认值为0replicate图像大小通过复制外
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO/TS 20428:2024 EN Genomics Informatics - Data elements and their metadata for describing structured clinical genomic sequence information in electronic health records
- 【正版授权】 ISO 6900:2025 EN Dried red jujubes - Specification and test methods
- 2025年度大型企事业单位公务车辆租赁服务协议合同范本
- 2025年变配电保护自动化项目合作计划书
- 离职管理与退出面谈流程计划
- 秋季信息化教学推进计划
- 2025年酸碱平衡调节药合作协议书
- 智研咨询发布-2025年中国智慧环保行业产业链全景分析及发展趋势预测报告
- 2025年特异性植物源农药项目合作计划书
- 2025年医用氧化亚氮系统合作协议书
- TSG11-2020锅炉安全技术规程(现行)
- 一年级20以内加减及混合口算练习题
- 中南大学《药理学》2023-2024学年第一学期期末试卷
- 机电队技术员安全生产责任制(3篇)
- 血透机常见报警原因及处理课件
- 2024快手非遗生态报告
- 第三章企业的生产和成本
- 统编版 高中语文 必修下册 《祝福》《林教头风雪山神庙》
- 2024年职教高考《机械制图》考试题库
- 房地产行业房地产销售业绩考核方案
- 2025届高校毕业生公开招聘工作人员报名登记表
评论
0/150
提交评论