I used the link below for thresholding of my images. https://github.com/subokita/Sandbox/blob/master/otsu.py but my images was grayscale and I didn't as same as the link. now I want to use the function otsu2 or otsu1
img=cv2.imread('E:/tilpixs2/23_1050_450_5.0X/til1.G.png')
rows,cols,channelsNo=shape(img)
# create 256 bins histogram
hist = histogram(img, 256)[0]
# apply the otsu thresholding
thresh=otsu2(hist,rows*cols)
img2=img>=thresh
plt.imsave("E:/tilpixs2/img2.png", img2)
img2.dtype #it is boolean
To convert img2 to uint8, I did some convertions. Some of them are here"
img2.dtype='uint8'
or
img4=img2.astype(uint8)
or
npyage = np.array(img2)
img3=img2.np.uint8
But when I check the image when saved, the bit depths in properties of image is 32. I'm totally confused, What should I do? what does 32 in bit depth means? I want an image of 8 bit int