Page 1 of 1

Removing guidelines from scanned sketch

Posted: 2017-08-27T08:14:31-07:00
by nibl
I'm trying to remove a color by replacing it with the white background. It works partially, as you can see in the images below. Is it possible to fully replace a color?

Reason: I use colored guidelines for drawing and need to remove the lines when the sketch is done and has been scanned.

Here is the original image, which would be scanned in from a sketchbook or piece of paper.

http://www.dropbox.com/s/xvuw5q6w89zgfa ... skater.jpg

I used this imagemagick command:

Code: Select all

convert red-grid-skater.jpg -fuzz 30% -fill white -opaque 'rgb(255,0,0)' im-out.jpg
Resulting image:
https://www.dropbox.com/s/jam2ko5pioq5c ... 30perc.jpg

There is still a lot of the guidelines visible. Is there a way to improve the results?

IM 7.0.6-9 on Mac OS X El Capitan

Btw, how do you embed images here? My dropbox links are not being embedded.

Re: Removing guidelines from scanned sketch

Posted: 2017-08-27T11:40:52-07:00
by fmw42
try getting a better average red color with a color picker and play with the fuzz value.

Code: Select all

convert red-grid-skater.jpg -fuzz 50% -fill white -opaque 'rgb(255,160,167)' im-out.jpg
or

Code: Select all

convert red-grid-skater.jpg -fuzz 30% -fill black -opaque black -fill white +opaque black \
-morphology open octagon:2 im-out.jpg
or

Code: Select all

convert red-grid-skater.jpg -fuzz 30% -fill black -opaque black -fill white +opaque black \
-morphology erode diamond:1 im-out.jpg

Re: Removing guidelines from scanned sketch

Posted: 2017-08-31T17:29:51-07:00
by nibl
fmw42, Thank you so much. Your suggestions worked really well.

Which colors do you think would be easiest to filter out?

Edit: fixed typo.

Re: Removing guidelines from scanned sketch

Posted: 2017-08-31T17:39:38-07:00
by fmw42
Medium to light brightness so that they are far from black. Basically my commands above try to find near black (due to antialiasing of lines they are not pure black), then make them pure black and then it makes everything else white.

Re: Removing guidelines from scanned sketch

Posted: 2017-08-31T23:53:18-07:00
by nibl
Thanks, that makes total sense and works great for sketches with black lines.

Can we take it a step further and use it for drawings that have been colored in? How would IM remove only a light grey shade for the gridlines, and keep all other colors, not only black?

Re: Removing guidelines from scanned sketch

Posted: 2017-08-31T23:58:12-07:00
by Bonzo
This method on the usage site might be what you want: https://www.imagemagick.org/Usage/masking/#known_bgnd