Hi Sai,
It seems that you are extracting images from a video and performing OCR by selecting a region of interest to recognize the text. Since you have already tried binarizing the image, try preprocessing the image before performing OCR.
I have saved the image that you have attached in the question and tried to preprocess it. Have a look at the following steps:
1. Import the image and convert it to grayscale:
img = imread('ocr_img.jpeg');
2. Following that you could apply a filter to reduce noise. For example, try a median filter:
filteredI = medfilt2(grayI);
3. Adjust the contrast and sharpen the image:
contrastAdjustedI = imadjust(filteredI);
sharpenedI = imsharpen(contrastAdjustedI);
For more information about “imadjust” and “imsharpen” you can refer to the following documentation links:
4. As a final preprocessing step, binarize and dilate the image to fill gaps. Prior to dilation, complement the image. Have a look at the following code snippet:
bI = imcomplement(sharpenedI);
dilatedImage = imdilate(bI, se);
filledImage = imcomplement(dilatedImage);
5. For retrieving the text through OCR, you can follow the same process of creating a region of interest as shown in the following code snippet:
textStruct = ocr(filledImage,roi,Language = "seven-segment");
Using the above steps, I was able to retrieve the numerical value present in the image.
I hope this helps!