What's the best way to detect lines of a grid in an image?

11 views (last 30 days)
I'm working on a project and I need to detect lines of a grid in an image captured by a camera or mobile of a Sudoku game.
I'm new to Matlab and I wish you give me some good advice. Thanks.

Answers (1)

Image Analyst
Image Analyst on 19 Mar 2013
Assuming the grid lines align with the image edges, I would sum the image horizontally and vertically and look for spikes.
horizontalProfile = sum(grayImage, 1); % Sum across all rows.
verticalProfile = sum(grayImage, 2); % Sum across all columns.
If the grid lines are rotated, then you'll have to use hough() or houghlines().

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!