Prepare complex image for OCR

后端 未结 3 641
执念已碎
执念已碎 2020-12-30 07:29

I want to recognize digits from a credit card. To make things worse, the source image is not guaranteed to be of high quality. The OCR is to be realized through a neural net

3条回答
  •  不知归路
    2020-12-30 08:16

    The way how I would go about the problem is separate the cards into different section. There are not many unique credit cards to begin with (MasterCard, Visa, the list is up to you), so you can make like a drop down to specify which credit card it is. That way, you can eliminate and specify the pixel area:

    Example:

    Only work with the area 20 pixels from the bottom, 30 pixels from the left to the 10 pixels from right to 30 pixels from bottom (creating a rectangle) - This would cover all MasterCards

    When I worked with image processing programs (fun project) I turned up the contrast of the picture, converted it to grey scale, took the average of each individual RGB values of 1 pixel, and compared it to the all around pixels:

    Example:

    PixAvg[i,j] = (Pix.R + Pix.G + Pix.B)/3
    if ((PixAvg[i,j] - PixAvg[i,j+1])>30)
        boolEdge == true;
    

    30 would be how distinct you want your image to be. The lower the difference, the lower is going to be the tolerance.

    In my project, to view edge detection, I made a separate array of booleans, which contained values from boolEdge, and a pixel array. The pixel array was filled with only black and white dots. It got the values from the boolean array, where boolEdge = true is a white dot, and boolEdge = false is a black dot. So in the end, you end up with a pixel array (full picture) that just contains white and black dots.

    From there, it is much easier to detect where a number starts and where a number finishes.

提交回复
热议问题