If I imwrite a binarized image, it only creates a grayscale image file not an indexed=2 file. What options do I need on the imwrite to accomplish this? I would also like LZW compression if possible.
orig = cv2.imread('rgb.tiff')
work = cv2.cvtColor(orig, cv2.COLOR_BGR2GRAY)
work = cv2.ximgproc.niBlackThreshold(work, 255, cv2.THRESH_BINARY, 41, -0.2,
binarizationMethod=cv2.ximgproc.BINARIZATION_NICK)
cv2.imwrite('bw.tiff', work)



imwrite Only 8-bit (or 16-bit unsigned (CV_16U) in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with ‘BGR’ channel order) images can be saved using this function.