实用的 Matlab

来源:互联网 发布:中国家庭收入数据 编辑:程序博客网 时间:2024/05/19 03:26
  • activecontour:前景背景分离,Segment image into foreground and background using active contour
    • 该函数返回的是一副 binary image,二值图像;

1. Texture Segmentation

  • Texture Segmentation Using Gabor Filters

2. 删除图像中的网格(removing grids in an image)

Removing grids in an image - MATLAB Answers - MATLAB Central


这里写图片描述

  • (1)通过阈值化的处理,识别亮的部分(也即网格的部分),
  • (2)对图像进行中值滤波,
  • (3)步骤 1 获得的网格的部分,由步骤(2)的结果所取代;
clear, clcI = imread('./grid.png');grid = I > 125;filtered = medfilt2(I, [80, 80]);            % 当然也不一定非得是中值滤波,也可以采用其他插值形式I(grid) = filtered(grid);imshow(I)

3. 运动图像去模糊

基于matlab运动模糊图像处理的源代码

  • 使用维纳滤波;
function deblurred(im, a, b, NSPR)i = imread(im);f = im2double(i);PSF = fspecial('motion', a, b);                        %  point spread function (PSF)frest1 = deconvwnr(f, PSF, NSPR);                        % NSR is the noise-to-signal power ratio of the additive noise.                         % NSR can be a scalar or a spectral-domain array of the same size as I. subplot(221),imshow(f); title('原图像');subplot(222),imshow(frest1); title('维纳滤波处理后图像'); end
  • PSF = fspecial(‘motion’,len,ang); %建立扩散子,其中len是模糊长度,ang是模糊角度;
  • img2=deconvlucy(img,PSF,n); %用lucy-richardson方法复原图像,其中img是运动模糊图像,PSF是扩散子,n是迭代次数,img2是复原图像

一般模糊图像的模糊距离和模糊角度不好判断,但也可以通过查看图像的频谱图和实部二维图来大致估:

% 求角度img_fft=fftshift(fft2(img_gray));N=abs(img_fft);P=(N-min(min(N)))/(max(max(N))-min(min(N)))*225;figure;imshow(P);% 求长度h=fspecial('sobel');img_double=double(img_gray);J=conv2(img_double,h,'same');IP=abs(fft2(J));S=fftshift(real(ifft2(IP)));figure;plot(S);
0 0
原创粉丝点击