Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I finally made it !

I pre-processed the cell images like that:

// remove noise
medianBlur(cell, cell_no_noise, 1);
// remove background/light
cell_no_light = removeLight(cell_no_noise, calculateLightPattern(cell),2);
// binarize image
adaptiveThreshold(cell_no_light, final_cell, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 3, 1);

After that I try to identify the area that I did not want. As it is a grid, numbers are surrounded by lines. So I filtered areas that are long enough:

int cell_height = cell.rows;
int cell_width = cell.cols;

// setting parameters for long lines filtering
float percent = 0.23;
float width_threshold = cell_width - cell_width * percent;
float height_threshold = cell_height - cell_height * percent;

if(width > width_threshold ) continue;
if(height > height_threshold) continue;

I have done the same for small areas.

if(boundingArea < 220 || boundingArea > 900) continue;
if(area < 110) continue; // area of the connected object

You will find the source code here if you want to play with ! I will be very thankful if you could find something that will improve the project especially in terms of performance as I'm not a cpp/opencv developper.