pythreshold icon indicating copy to clipboard operation
pythreshold copied to clipboard

Histogram generation

Open pedrogalher opened this issue 4 years ago • 1 comments

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

pedrogalher avatar Sep 30 '21 19:09 pedrogalher

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!

manuelaguadomtz avatar Oct 31 '21 01:10 manuelaguadomtz