I am trying to train a cnn model for ocr using keras. I preprocessed the images by converting to grayscale, removing noise and then converting it to binary, as binary images work better in ocr. But the problem I am getting is that binary image has 2 dimensions and no channel dimension and conv2d in keras(well any conv layer in general) require 3 dimensions. So what should I do to add a dimension but keep image binary? I am using cv2 for image processing so please tell solutions using that preferably. Also tell me whether I am right that using binary image dataset is better for ocr.
"When using this layer as the first layer in a model, provide the keyword argument input_shape (tuple of integers, does not include the batch axis), e.g. input_shape=(128, 128, 3) for 128x128 RGB pictures in data_format="channels_last"."
So I think you could useinput_shape=(height,width,1)
for your grayscale or binary data? Sorry, from my side it is only theoretical. And I don't know how to duplicate channels or sth. in python. – Mickainput_shape=(height,width,1)
– Micka