Extract cow number from image

前端 未结 5 2028
庸人自扰
庸人自扰 2020-12-13 07:13

every now and then my mom has to shift through these type of photos to extract the number from the image and rename it to the number.

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 08:04

    I have been looking at this a little and thinking how I might tackle it. I prefer the free ImageMagick software which is available for OSX, installed on most Linux distros and available for Windows.

    My first reaction was to try a Sobel edge detector to the images, then threshold that and remove noise and outliers with a median filter.

    I can do all that with a single command at the commandline like this:

    convert c1.jpg                                                          \
       -define convolve:scale='50%!' -bias 50% -morphology Convolve Sobel   \
       -solarize 50% -level 50,0% -auto-level -threshold 50% -median 3 result.jpg
    

    where c1.jpg is your first cow, and likewise for the other cows.

    I end up with this:

    enter image description here

    enter image description here

    enter image description here

    which is a pretty reasonable starting point for working out where the numbers are in the image. I am thinking of dividing the image into tiles next, or other techniques, and then I will look at tiles/areas containing the most white. That way I will start to get a handle on where I should be pointing tesseract to look... however, it is bedtime - apparently. Maybe someone clever like @rayryeng will take a look overnight :-)

提交回复
热议问题