• 数字图像处理MATLAB


    数字图像处理MATLAB

    基(本)操(作)

    1. 图片读取
    A=imread('test.bmp');
    imshow(A);
    
    • 1
    • 2

    在这里插入图片描述
    2. 图像写入

    A=imread('test.bmp');
    imwrite(A,'test-bak.bmp');
    B=imread('test-bak.bmp');
    imshow(B);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述
    3. 图像文件信息查询

    info=imfinfo('test.bmp');
    
    
    • 1
    • 2

    在这里插入图片描述
    4. 显示图像

    imshow()
    
    • 1
    1. 添加颜色条到坐标轴colorbar
    RGB=imread('test.bmp');
    I=rgb2gray(RGB);
    h=[1 2 1;0 0 0;-1 -2 -1];
    I2=filter2(h,I);
    imshow(I2,[]),colorbar('vert')
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述
    6. 纹理映射wrap

    A=imread('test.bmp');
    I=rgb2gray(A);
    [x,y,z]=sphere;
    warp(x,y,z,I);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    1. 显示多幅图像subimage
    RGB=imread('test.bmp');
    I=rgb2gray(RGB);
    subplot(1,2,1),subimage(RGB);
    subplot(1,2,2),subimage(I);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    代数操作

    1. 加法imadd
    RGB=imread('test.bmp');
    J=imadd(RGB,100); %增加亮度
    subplot(1,2,1),subimage(RGB);
    subplot(1,2,2),subimage(J);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述
    2. 减法imsubtract

    I=imread('test.bmp');
    J=imsubtract(I,100);
    subplot(1,2,1),subimage(I);
    subplot(1,2,2),subimage(J);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述
    3. 乘法immultiply

    I=imread('test.bmp');
    J=immultiply(I,0.5); %将值缩小0.5,变暗
    sublpot(1,2,1),subimage(I);
    subplot(1,2,1),subimage(I);
    subplot(1,2,2),subimage(J);
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述
    4. 除法imdivide

    I=imread('test.bmp');
    J=imdivide(I,0.5); %除以0.5,值变大,亮度变亮
    subplot(1,2,1),subimage(I);
    subplot(1,2,2),subimage(J);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    空间域操作

    1. 缩放imresize
    I=imread('test.bmp');
    X1=imresize(I,2); %放大,宽高扩大两倍
    figure,imshow(I);
    
    • 1
    • 2
    • 3

    在这里插入图片描述
    在这里插入图片描述
    2. 旋转imrotate

    I=imread('test.bmp');
    J=imrotate(I,45,'bilinear'); %旋转45°,后面是使用的算法
    subplot(1,2,1),subimage(I);
    subplot(1,2,2),subimage(J);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述
    3. 裁剪imcrop

    I=imread('test.bmp');
    J=imcrop(I,[75 68 130 112]); %裁剪区域
    subplot(1,2,1),subimage(I);
    subplot(1,2,2),subimage(J);
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    特定区域处理

    1. 选择多边形区域roipoly
    I=imread('test.bmp');
    c=[200 250 278 248 199 172];
    r=[21 21 75 121 121 75];
    BW=roipoly(I,c,r);
    subplot(1,2,1),subimage(I); %12列的图像
    subplot(1,2,2),subimage(BW);
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    在这里插入图片描述
    2. 灰度区域选择roicolor

    a=imread('test.bmp');
    I=rgb2gray(a);
    BW=roicolor(I,128,225);
    subplot(1,2,1),subimage(I);
    subplot(1,2,2),subimage(BW);
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述

    1. 指定区域二值掩模poly2mask
    x=[63 186 54 190 63];
    y=[60 60 209 204 60];
    bw=poly2mask(x,y,256,256);
    imshow(bw);
    hold on
    plot(x,y,'b','LineWidth',2)
    hold off
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述
    4. roifillt2函数实现区域滤波
    5. roifill 函数实现对特定区域进行填充

    图像变换

    1. fft2 函数和ifft2 函数分别是计算二维的快速傅里叶变换和反变换
    2. fftshift 函数实现了补零操作和改变图像显示象限
    3. dct2 函数采用基于快速傅里叶变换的算法,用于实现较大输入矩阵的离散余弦变换,与之对应,idct2 函数实现图像的二维逆离散余弦变换
    4. dctmtx 函数用于实现较小输入矩阵的离散余弦变换
    5. edge 函数用于提取图像的边缘
    6. radon 函数用来计算指定方向上图像矩阵的投影

    图像增强、分割和编码

    1. imhist 函数产生图像的直方图
    2. histeq 函数用于对图像的直方图均衡化
    3. filter2 函数实现均值滤波
    4. wiener2 函数实现Wiener(维纳)滤波
    5. medfilt2 函数实现中值滤波

    图像模糊及复原

    1. deconvwnr 函数:使用维纳滤波器
    2. deconvreg 函数:使用约束最小二乘滤波器
    3. deconvlucy 函数:使用Lucy-Richardson 滤波器
    4. deconvblind 函数:使用盲卷积算法
    a=imread('test.bmp');
    I=rgb2gray(a);
    figure;imshow(I);  %原始图像
    title('Original Image');
    PSF=fspecial('motion',13,45); %运动模糊
    figure;imshow(PSF);	%真实的PSF图像
    Blurred=imfilter(I,PSF,'circ','conv'); %得到运动模糊图像
    figure;imshow(Blurred);title('Blurred Image');	%模糊化的图像
    INITPSF=ones(size(PSF));
    [J,P]=deconvblind(Blurred,INITPSF,30); %使用盲卷积
    figure;imshow(J);		%盲卷积初步复原的图像
    %figure;imshow(P,[],'notruesize'); %旧版本
    figure;imshow(P,[],'InitialMagnification','fit');  %初步重建使用的PSF
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    在这里插入图片描述

  • 相关阅读:
    ARM汇编
    Python武器库开发-基础篇(三)
    【手把手带你刷好题】Java刷题记录 01—>>08
    C++异步:asio的scheduler实现!
    Three光线投射实例
    【ASP.NET】Hello World
    免费SSL证书和付费SSL证书的区别
    全球建站10000+,中海达加速推动北斗万物互联
    【无标题】
    Consul安装使用
  • 原文地址:https://blog.csdn.net/weixin_45090728/article/details/127188691