在matlab中制作一个平滑的3D矩阵

时间:2012-12-06 18:06:24

标签: image matlab image-processing pattern-matching

我有3D矩阵,我想删除一些discntinuities,我想改变统计属性。我的意思是,我不想改变全球统计属性。

任何解决方案?

2 个答案:

答案 0 :(得分:2)

我使用自制算法得到以下结果: enter image description here

这个想法如下:

  • 我们首先使用边缘检测来检测不连续性,将结果在两个方向上求和并进行阈值处理。
  • 我们创建了两个图像:一个在每个方向都有一行。
  • 我们使用1D高斯滤波器创建两个原始图像的低通版本:一个在每个方向上过滤。
  • 我们还对包含线条的图像进行低通滤波:它们将用作权重。
  • 我们通过计算组成最终图像:(low-pass_line_image)。* filtered_image +(1 - low-pass_line_image)。* original_image。我们在两个方向上执行此操作。

以下是代码:

    % Load and treat image
    im = imread('...');
    im = im2double(im);
    im = rgb2gray(im);

    % Compute edges of the image
    bw = edge(im);

    % We want to find the positions of the strong lines in the image :
    % Since they go through the whole image, we sum among x and y directions
    % and then threshold.
    xedges = sum(bw);
    xedges = xedges > 1/3*max(xedges(:));
    yedges = sum(bw,2);
    yedges = yedges > 1/3*max(yedges(:));

    % We create images of the same size that the original one and containing
    % the horizontal and vertical lines
    [xedges, yedges] = meshgrid(xedges, yedges);

    % We create a 1D gaussian filter
    gaussian = gausswin(12);
    gaussian = gaussian / sum(gaussian);

    % We filter the image among both directions
    imfy = imfilter(im, gaussian);
    imfx = imfilter(im, gaussian');

    % We also filter the images with the lines to get the weights
    xedges = im2double(xedges);
    xedges = imfilter(xedges, gaussian');
    xedges = xedges / max(xedges(:));
    yedges = im2double(yedges);
    yedges = imfilter(yedges, gaussian);
    yedges = yedges / max(yedges(:));

    % We use the filtered versions of the images with lines as weights between
    % the original image and the filtered images
    imfinal = xedges.*imfx + (1-xedges).*im;
    imfinal = yedges.*imfy + (1-yedges).*imfinal;
    imshow(imfinal);

答案 1 :(得分:0)

也许,您可以使用Efros等人提出的纹理合成算法:

http://graphics.cs.cmu.edu/people/efros/research/EfrosLeung.html