matlab 删除图形,通过matlab删除图像中不需要的区域 您所在的位置:网站首页 cmac是什么意思 matlab 删除图形,通过matlab删除图像中不需要的区域

matlab 删除图形,通过matlab删除图像中不需要的区域

#matlab 删除图形,通过matlab删除图像中不需要的区域| 来源: 网络整理| 查看: 265

您可能更喜欢使用bsxfun的更快速和矢量化方法以及从bwlabel本身获得的信息.

注意:bsxfun是内存密集型的,但这正是使它更快的原因.因此,请注意以下代码中B1的大小.一旦达到系统设置的内存约束,此方法将变慢,但在此之前它提供了优于regionprops方法的加速.

[L,num] = bwlabel( Img );

counts = sum(bsxfun(@eq,L(:),1:num));

B1 = bsxfun(@eq,L,permute(find(counts>threshold),[1 3 2]));

NewImg = sum(B1,3)>0;

编辑1:接下来讨论bsxfun和regionprops方法之间比较的几个基准.

情况1

基准代码

Img = imread('coins.png');%%// This one is chosen as it is available in MATLAB image library

Img = im2bw(Img,0.4); %%// 0.4 seemed good to make enough blobs for this image

lb = bwlabel( Img );

threshold = 2000;

disp('--- With regionprops method:');

tic,out1 = regionprops_method1(Img,lb,threshold);toc

clear out1

disp('---- With bsxfun method:');

tic,out2 = bsxfun_method1(Img,lb,threshold);toc

%%// For demo, that we have rejected enough unwanted blobs

figure,

subplot(211),imshow(Img);

subplot(212),imshow(out2);

产量

基准测试结果

--- With regionprops method:

Elapsed time is 0.108301 seconds.

---- With bsxfun method:

Elapsed time is 0.006021 seconds.

案例2

基准代码(仅列出案例1中的更改​​)

Img = imread('snowflakes.png');%%// This one is chosen as it is available in MATLAB image library

Img = im2bw(Img,0.2); %%// 0.2 seemed good to make enough blobs for this image

threshold = 20;

产量

基准测试结果

--- With regionprops method:

Elapsed time is 0.116706 seconds.

---- With bsxfun method:

Elapsed time is 0.012406 seconds.

如前所述,我已经使用其他更大的图像和大量不需要的blob进行了测试,bsxfun方法没有对regionprops方法提供任何改进.由于MATLAB库中没有任何这样大的图像,因此无法在此讨论.总之,可以建议基于输入特征使用这两种方法中的任何一种.看看这两种方法如何为输入图像执行会很有趣.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有