bwclearborder

Version 1.0.0.0 (1,86 KB) von Sean de
Same thing as IMCLEARBORDER, but faster for 2 and 3-dimensional binary images.
698 Downloads
Aktualisiert 3 Feb 2011

Lizenz anzeigen

This function removes white (true) objects touching the border of a 2 or 3-dimensional logical image. It produces the same result as IMCLEARBORDER and has the same syntax. It's just faster!

NOTE: The more sparse the image is, the faster this function is compared to IMCLEARBORDER.

%% Speed and Equality Comparison
tim = zeros(3,1); %time for imclearborder
tbw = zeros(3,1); %time for bwclearborder
idx = 0;

for n = [10 100 250] %side length of 3d volume
idx = idx+1;
A = rand(n,n,n)>.75;
t1 = 0;
t2 = 0;
for ii = 1:5
tic
I = imclearborder(A);
t1 = t1+toc;
tic
B = bwclearborder(A);
t2 = t2+toc;
end
tim(idx) = tim(idx)+t1;
tbw(idx) = tbw(idx)+t2;
end

isequal(I,B)
%{
ans = 1
%}

tbw
%{
0.0086875
1.033
19.462
%}

tim
%{
0.055181
5.3955
87.671
%}

tbw./tim
%{
0.15744
0.19145
0.22198
%}

Zitieren als

Sean de (2024). bwclearborder (https://www.mathworks.com/matlabcentral/fileexchange/30279-bwclearborder), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2009b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0