相关疑难解决方法(0)

Matlab:用透明背景保存图形

我有一个情节,并通过以下方式将背景设置为透明:

set(gcf, 'Color', 'None');
set(gca, 'Color', 'None');
Run Code Online (Sandbox Code Playgroud)

当我尝试保存图像(来自观看者)时,我保存为.png,但它以白色背景保存.如何用透明背景保存?

谢谢

matlab visualization image

12
推荐指数
1
解决办法
3万
查看次数

MATLAB: how do I crop out a circle from an image

I need to crop a circle in MATLAB.

I need to perform iris segmentation, and I´ve identified the center point and the radius of the iris, and I need to cut it off from the image.

I have a vector ci that ci(1) is X-coordinate ci(2) is Y-coordinate and ci(3) is the radius of the circle.

matlab crop image-processing

8
推荐指数
1
解决办法
1万
查看次数

matlab:在圆形neighboorhoods内有效计算局部直方图

我想要在圆形邻域内计算局部直方图的图像.邻域的大小由a给出radius.虽然下面的代码完成了这项工作,但它的计算成本却很高.我运行探查器,我访问圆形社区内的像素的方式已经很昂贵了.

是否有任何基于矢量化的改进/优化?或者,例如,将邻域存储为列?我在这篇文章中发现了一个类似的问题,所提出的解决方案完全符合下面代码的精神,但是解决方案仍然不适合我的情况.任何想法都非常受欢迎:-)想象一下,目前图像是二进制的,但该方法也应理想地与灰度图像一起使用:-)

[rows,cols] = size(img);
hist_img      = zeros(rows, cols, 2);
[XX, YY]      = meshgrid(1:cols, 1:rows);
for rr=1:rows
        for cc=1:cols
            distance      = sqrt( (YY-rr).^2 + (XX-cc).^2  );
            mask_radii = (distance <= radius);
            bwresponses   = img(mask_radii);
            [nelems, ~]   = histc(double(bwresponses),0:255);
            % do some processing over the histogram
            ...
        end
end
Run Code Online (Sandbox Code Playgroud)

编辑1鉴于收到的反馈,我试图更新解决方案.但是,它还不正确

radius = sqrt(2.0);
disk   = diskfilter(radius);
fun    = @(x) histc( x(disk>0), min(x(:)):max(x(:)) ); 
output = im2col(im, size(disk), fun);

function disk = diskfilter(radius)
    height  = 2*ceil(radius)+1;
    width …
Run Code Online (Sandbox Code Playgroud)

optimization performance matlab image-processing histogram

5
推荐指数
1
解决办法
506
查看次数