hist_thresh icon indicating copy to clipboard operation
hist_thresh copied to clipboard

help with histogram split

Open slowkow opened this issue 4 years ago • 5 comments

Hi Jon,

Thanks for the great code and youtube video! I decided to try it out on my own data, and I am a bit confused with the result.

I would expect that GHT() should return 2.6 or so, but I don't understand the output. Could I please ask if you might be able to help me understand how to use this function and how to interpret the output? Is there a way to call GHT() to get the threshold of 2.6?

Here is my data: n.txt

In [65]: d = np.genfromtxt('n.txt')

In [66]: d
Out[66]:
array([2.98497713, 3.53869938, 3.21138755, ..., 3.29136885, 3.02036128,
       3.03059972])

In [67]: GHT(d)
Out[67]:
(27376.0,
 array([334782.46328283, 334583.29822872, 334583.01013452, ...,
        334581.54735645, 334582.1549913 , 334785.61749101]))

In [74]: import matplotlib.pyplot as plt

In [77]: plt.hist(d, bins = 100); plt.show()

image

slowkow avatar Jul 26 '20 21:07 slowkow

Is this how we're supposed to run the function?

In [90]: d = np.sort(d)

In [91]: res = GHT(d)

In [96]: d[int(res[0])]
Out[96]: 3.45438746714696

Does this mean that GHT() is suggesting to place a threshold at 3.45?

slowkow avatar Jul 26 '20 21:07 slowkow

It looks like you're running GHT on a list of points. Try running it on a histogram (or on a sorted list of points provided as input as "x", where "n" is a vector of 1s).

On Sun, Jul 26, 2020 at 2:22 PM Kamil Slowikowski [email protected] wrote:

Is this how we're supposed to run the function?

In [90]: d = np.sort(d)

In [91]: res = GHT(d)

In [96]: d[int(res[0])] Out[96]: 3.45438746714696

Does this mean that GHT() is suggesting to place a threshold at 3.45?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jonbarron/hist_thresh/issues/1#issuecomment-664042177, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZFNQMSGNEPUVX6XDDQBDR5SNBDANCNFSM4PIFH3IA .

jonbarron avatar Jul 26 '20 21:07 jonbarron

Here you go: https://drive.google.com/file/d/1IevRDSI3bYGVhcZuDU9IZ81insF3w0XO/view?usp=sharing. I tuned the knobs a bit to give me 2.6.

On Sun, Jul 26, 2020 at 2:42 PM Jon Barron [email protected] wrote:

It looks like you're running GHT on a list of points. Try running it on a histogram (or on a sorted list of points provided as input as "x", where "n" is a vector of 1s).

On Sun, Jul 26, 2020 at 2:22 PM Kamil Slowikowski < [email protected]> wrote:

Is this how we're supposed to run the function?

In [90]: d = np.sort(d)

In [91]: res = GHT(d)

In [96]: d[int(res[0])] Out[96]: 3.45438746714696

Does this mean that GHT() is suggesting to place a threshold at 3.45?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jonbarron/hist_thresh/issues/1#issuecomment-664042177, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZFNQMSGNEPUVX6XDDQBDR5SNBDANCNFSM4PIFH3IA .

jonbarron avatar Jul 26 '20 21:07 jonbarron

Thanks!

For anyone visiting this issue, here is the code. The d array holds a bunch of data points from n.txt

In [17]: print(GHT(np.ones_like(d), np.sort(d), 100000, .1, 0)[0])
Out[17]: 2.62013605497376

Could I ask if there's any intuitive way to describe the parameters nu and tau?

slowkow avatar Jul 26 '20 23:07 slowkow

They're the hyperparameters of a scaled inverse chi-squared distribution, if you find that intuitive. The paper goes into much more detail on this but they kinda serve to let you interpolate between MET and Otsu's method, and also kinda control how much the histogram is pre-filtered with a Gaussian blur.

On Sun, Jul 26, 2020 at 4:20 PM Kamil Slowikowski [email protected] wrote:

Thanks!

For anyone visiting this issue, here is the code. The d array holds a bunch of data points from n.txt https://github.com/jonbarron/hist_thresh/files/4978528/n.txt

In [17]: print(GHT(np.ones_like(d), np.sort(d), 100000, .1, 0)[0]) Out[17]: 2.62013605497376

Could I ask if there's any intuitive way to describe the parameters nu and tau?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jonbarron/hist_thresh/issues/1#issuecomment-664053463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZFNTHE27KREQZRCY6KWDR5S23DANCNFSM4PIFH3IA .

jonbarron avatar Jul 26 '20 23:07 jonbarron