manuelaguadomtz / pythreshold

PyThreshold is a python package featuring Numpy/Scipy implementations of state-of-the-art image thresholding algorithms.
MIT License
58 stars 17 forks source link

Histogram generation #5

Open pedrogalher opened 3 years ago

pedrogalher commented 3 years ago

Hi,

I think there is a typo in the calculation of the histogram using:

hist = np.histogram(image, bins=range(256))[0].astype(np.float)

I think that it should be:

hist = np.histogram(image, bins=range(257))[0].astype(np.float)

Since you are passing a list to the bins parameters you need to specify the value of the last edge of the bins of the histogram, that is 256 for an 8-bit image [0-255]. Otherwise the histogram puts the counts for the 254 and 255 in the same bin.

I have double-checked it using Fiji

This is just a constructive comment as I had issues in the past with this. Let me know what you think Pedro

manuelaguadomtz commented 3 years ago

Hi Pedro!

Apologies for the delayed answer, I am immersed in a lot of work these days.

I think you are right!. That´s a mistake, it wasn´t a typo, I just misunderstood the documentation for np.histogram. Thank you very much for pointing it out.

I will get this fixed in the next version.

Thanks once again!