Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to remove the grid from a graph-paper

Subject: how to remove the grid from a graph-paper

From: Sem J.

Date: 19 Oct, 2010 22:29:05

Message: 1 of 10

Hello
Is there a way to remove the grid from the paper? Please see the scan image @ http://drop.io/sem4920
The grid has a different color from the graph that is dark; usually it's red shade. I would like to extract everything from the sheet except the grid.
Is it possible change a color range into another, so that the grid becomes completely white?

Regards,
  §em

Subject: how to remove the grid from a graph-paper

From: ImageAnalyst

Date: 20 Oct, 2010 01:19:26

Message: 2 of 10

§em:
I looked at your 3D color gamut, and it's too smeared between orange
and white. There's not good separation so color segmentation won't be
very good between orange and white. You'd be better off just trying
to get the black marks. There's some blending of the dark black marks
with the orange and gray but it's not as bad as between the orange and
white. I'd recommend trying to convert to LAB or HSV color space and
thresholding on L or V to segment out the black marks.

I also tried Fourier filtering to get rid of the grid but the results
weren't very satisfactory. Anyway, are you sure you want to extract
everything except the grid? In other words, do you want the white and
black, or are you interested in just the black? If you want just the
black, then threshold on L or V.

Here's some color segmentation demos to help you:
http://www.mathworks.com/matlabcentral/fileexchange/authors/31862

-Image Analyst

Subject: how to remove the grid from a graph-paper

From: Sem J.

Date: 20 Oct, 2010 16:21:05

Message: 3 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <ec90aee7-60fe-44a3-a4c4-ffa0d504511c@g13g2000yqj.googlegroups.com>...
> §em:
> I looked at your 3D color gamut, and it's too smeared between orange
> and white. There's not good separation so color segmentation won't be
> very good between orange and white. You'd be better off just trying
> to get the black marks. There's some blending of the dark black marks
> with the orange and gray but it's not as bad as between the orange and
> white. I'd recommend trying to convert to LAB or HSV color space and
> thresholding on L or V to segment out the black marks.
>
> I also tried Fourier filtering to get rid of the grid but the results
> weren't very satisfactory. Anyway, are you sure you want to extract
> everything except the grid? In other words, do you want the white and
> black, or are you interested in just the black? If you want just the
> black, then threshold on L or V.
>
> Here's some color segmentation demos to help you:
> http://www.mathworks.com/matlabcentral/fileexchange/authors/31862
>
> -Image Analyst

Very interesting subject. Thank you for your help!
I'm trying thresholding on Value component in HSV color space...
Is there a way to change a color range into another such as in some graphics tool ?
(I'm thinking about the "rotate color" function in GIMP program or maybe also in Paint Shop, Photoshop, etc.)
Best regards,
§em

Subject: how to remove the grid from a graph-paper

From: ImageAnalyst

Date: 20 Oct, 2010 17:01:44

Message: 4 of 10

Not that I know of. You'd have to do it "manually" through code.
Were you going to answer my questions at all?

Subject: how to remove the grid from a graph-paper

From: Sean

Date: 20 Oct, 2010 18:40:23

Message: 5 of 10

"Sem J." <foibosetdemos@libero.it> wrote in message <i9l63g$dvj$1@fred.mathworks.com>...
> Hello
> Is there a way to remove the grid from the paper? Please see the scan image @ http://drop.io/sem4920
> The grid has a different color from the graph that is dark; usually it's red shade. I would like to extract everything from the sheet except the grid.
> Is it possible change a color range into another, so that the grid becomes completely white?
>
> Regards,
> §em

For how many images do you have to do this and if many, how similar is the acquisition process? Could you scan a blank piece of graph paper and subtract it from the one you showed us?

Subject: how to remove the grid from a graph-paper

From: ImageAnalyst

Date: 20 Oct, 2010 21:53:53

Message: 6 of 10

On Oct 20, 2:40 pm, "Sean "
> For how many images do you have to do this and if many, how similar is the acquisition process?  Could you scan a blank piece of graph paper and subtract it from the one you showed us?
---------------------------------------
But that would just make the image black in the location of the grid
lines, and that would make it even more difficult to discriminate from
the black scribbles. I still think the best way is to just find the
black scribbles in the first place but I'm waiting for confirmation by
Sem. I think this is one of those common situations where people
think they know how to solve the problem (find the black scribbles)
but choose the wrong method (by eliminating the orange grid and
replacing it with white). If so, then replacing the grid with white
does absolutely nothing as far as getting the black scribbles - it's
totally unnecessary. Now if you wanted the black scribbles on a white
background that looks as close as possible to the original white
background, then you would want to find the grid and eliminate it. I
don't know which situation he wants and why he wants it.

Subject: how to remove the grid from a graph-paper

From: Sem J.

Date: 20 Oct, 2010 23:52:03

Message: 7 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <df4ed534-c427-4c1c-b793-a2f422896458@l20g2000yqm.googlegroups.com>...
> On Oct 20, 2:40 pm, "Sean "
> > For how many images do you have to do this and if many, how similar is the acquisition process?  Could you scan a blank piece of graph paper and subtract it from the one you showed us?
> ---------------------------------------
> But that would just make the image black in the location of the grid
> lines, and that would make it even more difficult to discriminate from
> the black scribbles. I still think the best way is to just find the
> black scribbles in the first place but I'm waiting for confirmation by
> Sem. I think this is one of those common situations where people
> think they know how to solve the problem (find the black scribbles)
> but choose the wrong method (by eliminating the orange grid and
> replacing it with white). If so, then replacing the grid with white
> does absolutely nothing as far as getting the black scribbles - it's
> totally unnecessary. Now if you wanted the black scribbles on a white
> background that looks as close as possible to the original white
> background, then you would want to find the grid and eliminate it. I
> don't know which situation he wants and why he wants it.

I've uploaded @ http://drop.io/sem4920 two images; the Value_graph_paper.jpg
is the value of HSV color space while the second is the result after applying a brightness adjustment and median filter.
I agree with ImageAnalyst to solve the problem finding the darkest strokes.
Now I would like to highlight the features and also add the dark interior scratches (see the "graph_paper.jpg").
Thanks,

 §em

Subject: how to remove the grid from a graph-paper

From: Image Analyst

Date: 21 Oct, 2010 02:39:04

Message: 8 of 10

§em:
Like I said, just threshold on HSV. Look for low V, and low S. That should get it. Look to my demos for info on how to do it:

http://www.mathworks.com/matlabcentral/fileexchange/28512-simple-color-detection-by-hue

http://www.mathworks.com/matlabcentral/fileexchange/28972-custom-shaped-histogram

Subject: how to remove the grid from a graph-paper

From: Sem J.

Date: 25 Oct, 2010 18:41:06

Message: 9 of 10

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <i9o948$oq4$1@fred.mathworks.com>...
> §em:
> Like I said, just threshold on HSV. Look for low V, and low S. That should get it. Look to my demos for info on how to do it:
>
> http://www.mathworks.com/matlabcentral/fileexchange/28512-simple-color-detection-by-hue
>
> http://www.mathworks.com/matlabcentral/fileexchange/28972-custom-shaped-histogram


-------------------------------

Related with the last problem I got this logical image:
http://drop.io/sem4920/asset/bw-a-png

I worked it in a graphics program to remove the noise and focus only with edges.

How do I join the broken edges in that image? I don't want to use dilation and closing morphological functions because they thicken the edges and I want to keep the upper-left of the image (where is the hole).
Any suggestions?

§em

Subject: how to remove the grid from a graph-paper

From: ImageAnalyst

Date: 25 Oct, 2010 19:55:31

Message: 10 of 10

Who's to say your first boundary is so accurate anyway? Closing
dilates and then erodes so you have roughly the same size image
afterwards, just with a smoother perimeter. I'd do a closing (with
imclose) and then use bwboundaries to find the outer perimeter.

Or you can try finding endpoints (use bwmorph's skel and endpoints
functions) and then use the Bresenham line algorithm to write a line
in between every endpoint and the closest other endpoint.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us