I am trying to calculate intensities in different regions in a image(taken in 16-bit). I have created binary masks first of the different regions, then using the masking I calculate the intensities. However, the problem was I was getting a negative values when I was doing the sum of the intensities. If do np.int64 the problem is not happening, but the values changes if I do int16/32. So which one would be correct and did I put it the correct place? Also is there any difference if I do np.int64 with astype("uint64")?
image = imread(path)
nucleus = gaussian_filter(image,5)
nucleus_mask = np.where(nucleus>10000,1,0)
tissue = gaussian_filter(image,5)
tissue_mask = np.where(tissue> 1000,1,0)
only_tissue = tissue_mask - nucleus_mask
only_tissue = np.where(only_tissue<0,0,only_tissue)
autoAb = imread(auto_path)
auto_nucleus = np.sum(np.int64(nucleus_mask*autoAb))
auto_cyto = np.sum(np.int64(only_tissue*autoAb))