I am using this python scripts https://github.com/mzucker/page_dewarp, which manages the rendering and the color conversion of the images with adaptiveThreshold (from OpenCV) and pillow.
I would ask if it is possibile to modify the script in order to obtain an eight colors grayscale image instead of the default bitonal.
I am quite new to python, but I think that the part of the code to edit is this:
img_gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
remapped = cv2.remap(img_gray, image_x_coords, image_y_coords,
cv2.INTER_CUBIC,
None, cv2.BORDER_REPLICATE)
thresh = cv2.adaptiveThreshold(remapped, 255, cv2.ADAPTIVE_THRESH_MEAN_C,
cv2.THRESH_BINARY, ADAPTIVE_WINSZ, 25)
pil_image = Image.fromarray(thresh)
pil_image = pil_image.convert('L')
threshfile = name + '_thresh.png'
pil_image.save(threshfile, dpi=(OUTPUT_DPI, OUTPUT_DPI))
It will be good if it is possible to eliminate the image thresholding and mantain only the dewarping feature, thus preserving the image as in the input.
EDIT: I added two examples: