comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Curve Fitting Question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Curve Fitting Question [message #82021] Mon, 12 November 2012 16:23 Go to next message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
How about Otsu's method? Meant for images but works for any set of numbers.

http://www.cis.rit.edu/~cnspci/media/software/otsu_threshold .pro

If your numbers aren't integers, I'd multiply by 1000, round, run otsu, divide by 1000. That's assuming 3 sig figs are enough...
Otsu Threshold for Bimodal Data [message #82169 is a reply to message #82021] Wed, 21 November 2012 09:51 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gianguido Cianci writes in response to my question about
finding an automatic way to locate the threshold that will
separate a bimodal data set into two populations:

> How about Otsu's method? Meant for images but works for any set of numbers.
>
> http://www.cis.rit.edu/~cnspci/media/software/otsu_threshold .pro
>
> If your numbers aren't integers, I'd multiply by 1000, round, run otsu, divide by 1000. That's assuming 3 sig figs are enough...

The OTSU_THRESHOLD program Gianguido mentions above makes
a number of undocumented assumptions that can cause problems
in the real-world use of the program. In my first attempt
at implementing this algorithm I inadvertently copied all
those dangerous assumptions into my own cgOtsu_Threshold
program.

In particular, this Otsu_Threshold program assumes you
are working with byte type images and that your binsize
is 1. It returns erroneous thresholds if you are working with
real data outside the range 0 to 255 or using bin sizes
other than 1.

Since I work with both these conditions often in effect,
I needed a more robust algorithm. Today I found a great
web page that allowed me to rebuild the algorithm from
the ground floor up:

http://www.labbookpages.co.uk/software/imgProc/otsuThreshold .html

The new algorithm replicates the results of OTSU_Threshold
for byte data with a binsize of 1, but it also works with
real data of whatever data range and with different bin sizes.

You can find the old program with a new algorithm here:

http://www.idlcoyote.com/programs/cgotsu_threshold.pro

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Otsu Threshold for Bimodal Data [message #82274 is a reply to message #82169] Sat, 24 November 2012 09:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> The OTSU_THRESHOLD program Gianguido mentions above makes
> a number of undocumented assumptions that can cause problems
> in the real-world use of the program. In my first attempt
> at implementing this algorithm I inadvertently copied all
> those dangerous assumptions into my own cgOtsu_Threshold
> program.
>
> In particular, this Otsu_Threshold program assumes you
> are working with byte type images and that your binsize
> is 1. It returns erroneous thresholds if you are working with
> real data outside the range 0 to 255 or using bin sizes
> other than 1.
>
> Since I work with both these conditions often in effect,
> I needed a more robust algorithm. Today I found a great
> web page that allowed me to rebuild the algorithm from
> the ground floor up.

The new algorithm turned out to be not quite as robust
as I expected it to be. But, good news, this turned out
to be due to a faulty assumption on my part and not to
a failure of the algorithm. In particular, the program
was having problems dealing with integer data.

My fault entirely. I assumed an equation I was using with
the threshold values was converting the threshold values
to floats. It was not. Once this problem was solved, the
algorithm is again acting like a champ!

http://www.idlcoyote.com/programs/cgotsu_threshold.pro

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Using TexToIDL in Coyote Graphics Routines
Next Topic: printf within time interval (also posted on exelisvis.com)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:06:02 PDT 2025

Total time taken to generate the page: 0.00423 seconds