Removing guidelines from scanned sketch

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nibl
Posts: 3
Joined: 2017-08-27T03:15:23-07:00
Authentication code: 1151

Removing guidelines from scanned sketch

Post by nibl » 2017-08-27T08:14:31-07:00

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.

User avatar
fmw42
Posts: 22080
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Removing guidelines from scanned sketch

Post by fmw42 » 2017-08-27T11:40:52-07:00

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

nibl
Posts: 3
Joined: 2017-08-27T03:15:23-07:00
Authentication code: 1151

Re: Removing guidelines from scanned sketch

Post by nibl » 2017-08-31T17:29:51-07:00

fmw42, Thank you so much. Your suggestions worked really well.

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

Edit: fixed typo.
Last edited by nibl on 2017-08-31T23:35:52-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 22080
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Removing guidelines from scanned sketch

Post by fmw42 » 2017-08-31T17:39:38-07:00

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.

nibl
Posts: 3
Joined: 2017-08-27T03:15:23-07:00
Authentication code: 1151

Re: Removing guidelines from scanned sketch

Post by nibl » 2017-08-31T23:53:18-07:00

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?

Bonzo
Posts: 2844
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Removing guidelines from scanned sketch

Post by Bonzo » 2017-08-31T23:58:12-07:00

This method on the usage site might be what you want: https://www.imagemagick.org/Usage/masking/#known_bgnd

Post Reply