【问题标题】:make a smooth 3D matrix in matlab [closed]在matlab中制作一个平滑的3D矩阵[关闭]
【发布时间】:2012-11-24 20:18:21
【问题描述】:

我有 3D 矩阵,我想删除一些不连续性,我想更改统计属性。我的意思是,我不想更改全局统计属性。

有什么办法吗?

【问题讨论】:

    标签: image matlab image-processing pattern-matching


    【解决方案1】:

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

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

    【讨论】:

    • 我测试了那个算法,但我仍然有不连续性。有什么算法吗?
    【解决方案2】:

    我使用自制算法得到以下结果:

    思路如下:

    • 我们首先使用边缘检测来检测不连续性,将两个方向和阈值的结果相加。
    • 我们由此创建了两张图片:一张在每个方向都有线条。
    • 我们使用一维高斯滤波器创建原始图像的两个低通版本:一个在每个方向上进行滤波。
    • 我们还对包含线条的图像进行低通滤波:它们将用作权重。
    • 我们通过计算合成最终图像:(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);
    

    【讨论】:

    • 这种方法可以用于 3D 矩阵(比如说 50x50x20)吗?
    • 它不适用于 2D 图像(不是 rgb)并给我一个 NaN 矩阵!
    • 如果您认为立方体并排放置,并且希望在它们之间的边界处平滑,则可以概括。唯一棘手的部分是边缘检测(matlab 的“边缘”功能只在 2D 中有效)。 This can be helpful
    • 我尝试了几张灰度图像,但没有得到 NaN 矩阵。你能告诉我计算矩阵在哪一行开始包含 NaN 元素吗?也许调整参数(阈值、高斯的窗口大小)会有所帮助。
    • 我们运行 yedges = yedges / max(yedges(:));我得到了 NaN 矩阵!
    猜你喜欢
    • 2013-11-07
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    相关资源
    最近更新 更多