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.
I got my solution. I used numpy function numpy.expand_dims() to add empty dimension. so it became (width,height,1). Here is what I did:-
img = np.expand_dims(img,axis=2)