当前位置:文档之家› 数字图像处理 课程设计报告 matlab

数字图像处理 课程设计报告 matlab

欢迎阅读数字图像处理课程设计报告姓名:学号:班级: .net设计题目:图像处理教师:赵哲老师提交日期: 12月29日一、设计内容:主题:《图像处理》详细说明:对图像进行处理(简单滤镜,模糊,锐化,高斯模糊等),对图像进行处理(上下对称,左右对称,单双色显示,亮暗程度调整等),对图像进行特效处理(反色,实色混合,色彩平衡,浮雕效果,素描效果,雾化效果等),二、涉及知识内容:1、二值化2、各种滤波3、算法等三、设计流程图插入图片对图片进行处理二值化处理重复输出两幅图结束四、实例分析及截图效果:运行效果截图:第一步:读取原图,并显示close all;clear;clc;% 清楚工作窗口clc 清空变量clear 关闭打开的窗口close allI=imread('1.jpg');% 插入图片1.jpg 赋给Iimshow(I);% 输出图II1=rgb2gray(I);%图片变灰度图figure%新建窗口subplot(321);% 3行2列第一幅图imhist(I1);%输出图片title('原图直方图');%图片名称一,图像处理模糊H=fspecial('motion',40);%% 滤波算子模糊程度40 motion运动q=imfilter(I,H,'replicate');%imfilter实现线性空间滤波函数,I图经过H滤波处理,replicate反复复制q1=rgb2gray(q);imhist(q1);title('模糊图直方图');二,图像处理锐化H=fspecial('unsharp');%锐化滤波算子,unsharp不清晰的qq=imfilter(I,H,'replicate');qq1=rgb2gray(qq);imhist(qq1);title('锐化图直方图');三,图像处理浮雕(来源网络)%浮雕图l=imread('1.jpg');f0=rgb2gray(l);%变灰度图f1=imnoise(f0,'speckle',0.01);%高斯噪声加入密度为0.01的高斯乘性噪声 imnoise噪声污染图像函数 speckle斑点f1=im2double(f1);%把图像数据类型转换为双精度浮点类型h3=1/9.*[1 1 1;1 1 1;1 1 1];%采用h3对图像f2进行卷积滤波f4=conv2(f1,h3,'same');%进行sobel滤波h2=fspecial('sobel');g3=filter2(h2,f1,'same');%卷积和多项式相乘 same相同的k=mat2gray(g3);% 实现图像矩阵的归一化操作四,图像处理素描(来源网络)f=imread('1.jpg');[VG,A,PPG] = colorgrad(f);ppg = im2uint8(PPG);ppgf = 255 - ppg;[M,N] = size(ppgf);T=200;ppgf1 = zeros(M,N);for ii = 1:Mfor jj = 1:Nif ppgf(ii,jj)<Tppgf1(ii,jj)=0;elseppgf1(ii,jj)=235/(255-T)*(ppgf(ii,jj)-T);endendendppgf1 = uint8(ppgf1);H=fspecial('unsharp');Motionblur=imfilter(ppgf1,H,'replicate');figure;imshow(ppgf1);调用function [VG, A, PPG] = colorgrad(f, T)if (ndims(f)~=3) || (size(f,3)~=3)error('Input image must be RGB');endsh = fspecial('sobel');sv = sh';Rx = imfilter(double(f(:,:,1)), sh, 'replicate');Ry = imfilter(double(f(:,:,1)), sv, 'replicate');Gx = imfilter(double(f(:,:,2)), sh, 'replicate');Gy = imfilter(double(f(:,:,2)), sv, 'replicate');Bx = imfilter(double(f(:,:,3)), sh, 'replicate');By = imfilter(double(f(:,:,3)), sv, 'replicate');gxx = Rx.^2 + Gx.^2 + Bx.^2;gyy = Ry.^2 + Gy.^2 + By.^2;gxy = Rx.*Ry + Gx.*Gy + Bx.*By;A = 0.5*(atan(2*gxy./(gxx-gyy+eps)));G1 = 0.5*((gxx+gyy) + (gxx-gyy).*cos(2*A) + 2*gxy.*sin(2*A));A = A + pi/2;G2 = 0.5*((gxx+gyy) + (gxx-gyy).*cos(2*A) + 2*gxy.*sin(2*A)); G1 = G1.^0.5;G2 = G2.^0.5;VG = mat2gray(max(G1, G2));RG = sqrt(Rx.^2 + Ry.^2);GG = sqrt(Gx.^2 + Gy.^2);BG = sqrt(Bx.^2 + By.^2);PPG = mat2gray(RG + GG + BG);if nargin ==2VG = (VG>T).*VG;PPG = (PPG>T).*PPG;endf1=rgb2gray(f);imhist(f1);title('素描图直方图');五,图像处理实色混合(来源网络)%实色混合I(I<=127)=0; %对像素进行处理,若值小于等于127,置0 I(I>127)=255; %对像素进行处理,若值大于127,置255 imshow(I);title('像素图');I1=rgb2gray(f);imhist(I1);title('像素图直方图');六,图像处理反色图f=imread('1.jpg');q=255-q;imshow(q);title('反色图');imhist(q1);title('反色图直方图');七,图像处理上下对称A=imread('1.jpg');B=A;[a,b,c]=size(A);a1=floor(a/2); b1=floor(b/2); c1=floor(c/2);B(1:a1,1:b,1:c)=A(a:-1:a-a1+1,1:b,1:c);figureimshow(B)title('上下对称');A=rgb2gray(A);figureimhist(A)title('上下对称直方图');八,图像处理类左右对称C=imread('1.jpg');A=C;C(1:a,1:b1,1:c)=A(1:a,b:-1:b+1-b1,1:c);figureimshow(C)title('左右对称');A=rgb2gray(A);figureimhist(A);title('左右对称直方图');九,图像处理单双色显示a=imread('1.jpg');a1=a(:,:,1);a2=a(:,:,2); a3=a(:,:,3);aa=rgb2gray(a);a4=cat(3,a1,aa,aa); a5=cat(3,a1,a2,aa);figuresubplot(121);imshow(a4);title('单色显示');subplot(122);imshow(a5);title('双色显示');a4=rgb2gray(a4);a5=rgb2gray(a5);figuresubplot(121);imhist(a4);title('单色显示直方图');subplot(122);imhist(a5);title('双色显示直方图');十,图像处理亮暗度调整a=imread('1.jpg');a1=0.8*a;a2=2*a;figuresubplot(121);imshow(a1);title('暗图');subplot(122);imshow(a2);title('亮图')q3=rgb2gray(a1);q4=rgb2gray(a2);figuresubplot(121);mhist(q3);title('暗图直方图') subplot(122);imhist(q4);title('亮图直方图')十一,图像处理雾化处理q=imread('1.jpg');m=size(q,1);n=size(q,2);r=q(:,:,1);g=q(:,:,2);b=q(:,:,3);for i=2:m-10for j=2:n-10k=rand(1)*10;%产生一个随机数作为半径di=i+round(mod(k,33));%得到随机横坐标dj=j+round(mod(k,33));%得到随机纵坐标r(i,j)=r(di,dj);%将原像素点用随机像素点代替 g(i,j)=g(di,dj);b(i,j)=b(di,dj);endenda(:,:,1)=r;a(:,:,2)=g;a(:,:,3)=b;imshow(a)title('雾化处理图');q=rgb2gray(a);figureimhist(q);title('雾化处理图直方图');十二,图像处理高斯滤波I = imread('1.jpg');G =fspecial('gaussian', [5 5], 2);% fspecial生成一个高斯滤波器Ig =imfilter(I,G,'same');%imfilter使用该滤波器处理图片imshow(Ig);title('高斯滤波');I1=rgb2gray(Ig);figureimhist(I1);title('高斯滤波直方图');十三,图像处理色彩平衡(来自网络)im=imread('1.jpg');im2=im;%存储元图像im1=rgb2ycbcr(im);%将im RGB图像转换为YCbCr空间。

相关主题