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 »

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: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing guidelines from scanned sketch

Post 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
nibl
Posts: 3
Joined: 2017-08-27T03:15:23-07:00
Authentication code: 1151

Re: Removing guidelines from scanned sketch

Post 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.
Last edited by nibl on 2017-08-31T23:35:52-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing guidelines from scanned sketch

Post 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.
nibl
Posts: 3
Joined: 2017-08-27T03:15:23-07:00
Authentication code: 1151

Re: Removing guidelines from scanned sketch

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Removing guidelines from scanned sketch

Post by Bonzo »

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