Threshold of blurry image - part 2

前端 未结 6 1716
死守一世寂寞
死守一世寂寞 2021-02-03 11:40

How can I threshold this blurry image to make the digits as clear as possible?

In a previous post, I tried adaptively thresholding a blurry image (left)

6条回答
  •  迷失自我
    2021-02-03 12:09

    My proposal assumes you can identify the sudoku cells, which I think, is not asking too much. Trying to apply morphological operators (although I really like them) and/or binarization methods as a first step is the wrong way here, in my opinion of course. Your image is at least partially blurry, for whatever reason (original camera angle and/or movement, among other reasons). So what you need is to revert that, by performing a deconvolution. Of course asking for a perfect deconvolution is too much, but we can try some things.

    One of these "things" is the Wiener filter, and in Matlab, for instance, the function is named deconvwnr. I noticed the blurry to be in the vertical direction, so we can perform a deconvolution with a vertical kernel of certain length (10 in the following example) and also assume the input is not noise free (assumption of 5%) -- I'm just trying to give a very superficial view here, take it easy. In Matlab, your problem is at least partially solved by doing:

    f = imread('some_sudoku_cell.png');
    g = deconvwnr(f, fspecial('motion', 10, 90), 0.05));
    h = im2bw(g, graythresh(g)); % graythresh is the Otsu method
    

    Here are the results from some of your cells (original, otsu, otsu of region growing, morphological enhanced image, otsu from morphological enhanced image with region growing, otsu of deconvolution):

    enter image description here enter image description here enter image description hereenter image description here enter image description here enter image description here
    enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here
    enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here
    enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here
    enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here
    enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

    The enhanced image was produced by performing original + tophat(original) - bottomhat(original) with a flat disk of radius 3. I manually picked the seed point for region growing and manually picked the best threshold.

    For empty cells you get weird results (original and otsu of deconvlution):

    enter image description here enter image description here

    But I don't think you would have trouble to detect whether a cell is empty or not (the global threshold already solves it).

    EDIT:

    Added the best results I could get with a different approach: region growing. I also attempted some other approaches, but this was the second best one.

提交回复
热议问题