[ImageJ-devel] Fwd: Hist thresh toolbox license question

Antti Niemistö antti.niemisto at tut.fi
Mon Feb 18 16:01:14 CST 2013


Hello,

It seems like your ported version does not produce the correct threshold 
between the two peaks in the smoothed histogram in certain cases where you 
have flat areas in the smoothed histogram.

For example, try this one.

I = 40*ones(40);
I(10:30,10:30) = 120;
T = th_minimum(I);

You'll find the threshold becomes 121. This is of course not between the 
two peaks at 40 and 120.

The code in v1.02 did not assign any value to the threshold in this 
example case and in similar cases, so it clearly needed to be fixed.

I now realize that a much more elegant fix than what I put in v1.03 would 
be this (gives T=41 in my simple example):

for k = 2:n
   if y(k-1) > y(k) & y(k+1) >= y(k)
     T = k-1;
     break
   end
end

The "break" from the loop is essential, in addition to changing the latter 
">" to a ">=". I would definitely use this code in your port.

Antti


On Mon, 18 Feb 2013, Barry DeZonia wrote:

> Thanks Antti. I've already begun porting it into ImageJ2. I noticed that the
> release includes a tweak to the th_minimum.m code. I was going to
> incorporate it into our stuff but came across three versions (one our own)
> and wanted to make sure that if our code differs it is a mistake and not a
> bug we found.
> At the end of th_minimum.m the code looks like this in 1.02:
> 
> % The threshold is the minimum between the two peaks.
> for k = 2:n
>   if y(k-1) > y(k) & y(k+1) > y(k)
>     T = k-1;
>   end
> end
> 
> Our version (I believe ported from 1.02) is very similar except the test
> line looks like:
> 
>   if y(k-1) > y(k) & y(k+1) >= y(k)   // NOTICE THE SINGLE >= INSTEAD OF >
> 
> Finally your much changed version looks like this in 1.03:
> 
> % The threshold is the minimum between the two peaks.
> peakfound = false;
> for k = 2:n
>   if y(k-1) < y(k) & y(k+1) < y(k)
>     peakfound = true;
>   end
>   if peakfound  & y(k-1) >= y(k) & y(k+1) >= y(k)
>     T = k-1;
>     return
>   end
> end
> 
> I think Gabriel can shed light maybe on our change and if it was by design
> or not. (Gabriel its been present since 1.0). And I see your new version is
> >='s on both ends. So maybe this email is overkill. Any clarification on
> your thinking re: the 1.03 change would be appreciated.
> 
> 
> On Wed, Feb 13, 2013 at 8:15 AM, Antti Niemistö <antti.niemisto at tut.fi>
> wrote:
>       Hi Johannes,
>
>       On Tue, 12 Feb 2013, Johannes Schindelin wrote:
>
>             Hi Gabriel and Antti,
>
>             On Mon, 11 Feb 2013, Gabriel Landini wrote:
>
>                   On Monday 11 Feb 2013 23:23:11 Antti
>                   Niemistö wrote:
>                         Then that's what we'll do. I
>                         actually found a little bug
>                         in one of the
>                         methods (th_maxlik) some
>                         time ago, so I was thinking
>                         I'll put out a
>                         new version of the toolbox
>                         with that fixed. I'm not
>                         exactly a software
>                         guy and do not routinely
>                         deal with licensing, so can
>                         you give me a
>                         walkthrough as to how to go
>                         about making this new
>                         release with a dual
>                         BSD/GPL license? Or point me
>                         to one? I'll then update the
>                         toolbox page
>                         at
>                         http://www.cs.tut.fi/~ant/histthresh/
>                         The bug fix is ready so I'll
>                         get this up as soon as the
>                         licensing is sorted.
> 
>
>                   The maximum likelihood estimator method
>                   was never implemented in the
>                   ImageJ plugin because I could never make
>                   it replicate the results of the
>                   Matlab code.
> 
>
>             I look forward to trying that maximum likelihood
>             method!
> 
> 
> The updated version of the maximum likelihood method is now available
> with the brand new release 1.03 of HistThresh Toolbox for MATLAB at
> http://www.cs.tut.fi/~ant/histthresh/
> 
> I hope that it is useful to you.
> 
> --
> Antti Niemistö DSc(Tech)              office: TE410
> Research Fellow                       phone:  +358-40-849-0587 (GSM)
> Department of Signal Processing               +358-3-3115-4989 (fax)
> Tampere University of Technology      URI:  
>  http://www.cs.tut.fi/~ant/
> 
> 
> 
>

-- 
Antti Niemistö DSc(Tech)              office: TE410
Research Fellow                       phone:  +358-40-849-0587 (GSM)
Department of Signal Processing               +358-3-3115-4989 (fax)
Tampere University of Technology      URI:    http://www.cs.tut.fi/~ant/



More information about the ImageJ-devel mailing list