skip to Main Content

I need to find text areas on a natural image.

I = rgb2gray(imread('image-name.jpg'));
points = detectHarrisFeatures(I);
imshow(I); hold on;
plot(points); 

Above version of code retrieves all detected strongest points.

When I change the line that starts with “plot” like this:

[m,n] = size(points.Location);
plot(points.selectStrongest(int64((m*2)/3)));

I get the points with less noise from above but in various situations I need to reduce noisy points and the output figure was:

input image on left side and on the right side there is output
Input image is on the left side and Output image is on the right side

As you can see, there are still noisy points out of the rectangle(red lines) area. (rectangle lines are added byme on photoshop, output is the same without red lines)

The main question is I need a perspectively noised text regions rectangle like this (red rectangle on the image):

desired output with rectangle
Desired output with rectangle

By finding this rectangle, I can afford affine process to image to correct the perspective issue and make it ready for OCR process.

2

Answers


  1. We can’t detect bounding rectangle from printed text lines as lines may not cover entire page area or line detection itself may be improper as we’ve not yet done perspective corrections.

    So i suggest eased out approach for problem:

    1. Detect all four page edge lines which will give good estimate of page’s rotation on table’s plane (or camera roll). Correct image for rotation first.

    2. I guess much correction may not be required to image for camera yaw and tilt, as one will not be shooting a page from high angles say 45 degrees and for 5 to 10 degree yaw / tilt characters will still be recognizable. Moreover difference in width of top to bottom edge and left to right edge can be used to estimate correction factor against tilt and yaw for easing out detection algorithm threashold.

    Login or Signup to reply.
  2. The interest point density in noisy regions looks low compared to the point-density in other regions. By density, I mean the number of interest-points per unit area. Assuming this observation holds in general, it is possible to filter out the noisy regions.

    I don’t have matlab, so the code is in opencv.

    As I mentioned in a comment, I initially thought a median filter would work, but when I tried it, it didn’t. So I tried adaptive thresholding, because it is doing kind-of density calculation in my implementation and rejecting less-dense regions. Please see the comments in the code for further clarification.

    imfilt

    /* load image as gray scale */
    Mat im = imread("yEEy9.jpg", 0);
    /* find interest points: using FAST here */
    vector<KeyPoint> keypoints;
    FAST(im, keypoints, 15);
    /* mark interest points pixels with value 255 in a blank image */
    Mat goodfeatures = Mat::zeros(im.rows, im.cols, CV_8U);
    for (KeyPoint p: keypoints)
    {
        goodfeatures.at<unsigned char>(p.pt) = 255;
    }
    /* density filtering using adaptive thresholding:
       compute a threshold for each pixel as the mean value of blocksize*blocksize neighborhood
       of (x,y) minus c */
    int blocksize = 15, c = 7;
    Mat bw;
    adaptiveThreshold(goodfeatures, bw, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, blocksize, c);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search