HistomicsTK
HistomicsTK copied to clipboard
compute_haralick_features works incorrectly when `im_intensity` is a float with [0, 1] values
My understanding of compute_haralick_features is that you can provide im_intensity as a 2d array of float intensity values between 0 and 1. However, as written, the function will always cast im_intensity
to an int in this line. This leads to incorrect behavior for [0,1] intensity valued images i.e. these will be binarized, which is not what we want to do. For example, most of the Haralick features end up being constant.
A simple fix would be to simply remove the .astype(np.uint8)
i.e.
subImage = im_intensity[minr:maxr+1, minc:maxc+1]
I'm not sure what the purpose of casing subImage to np.uint8 -- is there a problem with removing this?
@idc9 this is addressed by #948 . We'll get this merged after the reviewer returns from travel.
Hi, just wanted to add here as the PR that was mentioned seems to still be open. I've been using the haralick features function and I ran into a related issue. My input arrays are uint16 array and the current behaviour causes overflow once the arrays are cast to uint8 without any previous rescaling of the intensities.
I've also encountered this problem, and at the very least it should be added in the documentation that the image has to be scaled to uint8 for compute_haralick_features to work properly.