octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #46390] image package - im2bw interprets thres


From: Carnë Draug
Subject: [Octave-bug-tracker] [bug #46390] image package - im2bw interprets threshold slightly different than Matlab
Date: Thu, 12 Nov 2015 21:08:10 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.4.0

Follow-up Comment #10, bug #46390 (project octave):

Well, I think it is good to make it explicit that we do want it cast and
floored (and not only cast(), remember negative values).

Interestingly, I do get the same results as you:


I = uint8([0:255]);

## cast and floor
t = cputime (); for i=0:10000, bw = im2bw(I, i/100000); endfor, cputime() -t

ans =  3.7840

## no cast and no floor
t = cputime (); for i=0:10000, bw = im2bw(I, i/100000); endfor, cputime() -t

ans =  2.9200


However, when I use random and larger matrices, that doesn't happen anymore:


I = randi (255, 1000, "uint8");

## cast and floor
t = cputime (); for i=0:10000, bw = im2bw(I, i/100000); endfor, cputime() -t
ans =  13.024

## no cast and no floor
t = cputime (); for i=0:10000, bw = im2bw(I, i/100000); endfor, cputime() -t
ans =  15.292



For curiosity, I also timed the actual comparison step and it is faster
to make the cast explicitely:


a = randi (255, 1000, "uint8");

t_d = 190;
t_u = uint8 (t_d);

for i=1:100, b = a > t_d; endfor, t = cputime (); for i=1:1000, b = a > t_d;
endfor, cputime () -t
ans =  1.2880

for i=1:100, b = a > t_u; endfor, t = cputime (); for i=1:1000, b = a > t_u;
endfor, cputime () -t
ans =  0.90400

for i=1:100, b = a > t_u; endfor, t = cputime (); for i=1:1000, b = a > cast
(t_u, "uint8"); endfor, cputime () -t

for i=1:100, b = a > t_u; endfor, t = cputime (); for i=1:1000, b = a > cast
(t_d, "uint8"); endfor, cputime () -t
ans =  0.99200

for i=1:100, b = a > t_u; endfor, t = cputime (); for i=1:1000, b = a > cast
(floor(t_d), "uint8"); endfor, cputime () -t
ans =  1.0280



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46390>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]