Remove antialias to improve tracing

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
blanpaol
Posts: 1
Joined: 2015-05-13T03:12:58-07:00
Authentication code: 6789

Remove antialias to improve tracing

Post by blanpaol »

Hi,

we are trying to trace some raster images using potrace.
So here is the flow we use :

1.get a cleaned image
2. remove white
3. get histogram
4. for x main colors: (we are limited to the number of color (print costs))
a. extract the current color
b. convert to black
c. make bitmap
d. trace with potrace & fill to the current color
5. merge files
--> we get an eps or svg with x paths , one path per color found in the main colors

this is working fine..

But here is the thing, the merged file has some white lines between each paths.
we think it's due to the antialias, because the color cyan betwee blue and green is not in the main colors so it's ignored,
thus here is my question :

Is there a way to get the 'outer pixel' of a specific color when extracting this color to another file ?
--> http://s9.postimg.org/lb6jm4u1b/Capture.png

here is the cmd we use to extract the color :

Code: Select all

convert xx.png -alpha set ( +clone -transparent #FF0000 ) -compose DstOut -composite yy.png 
here is the original image http://s21.postimg.org/wfna00yhj/logo_multi_color.jpg


thank you in advance !
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove antialias to improve tracing

Post by snibgo »

blanpaol wrote:But here is the thing, the merged file has some white lines between each paths.
we think it's due to the antialias, because the color cyan betwee blue and green is not in the main colors so it's ignored, ...
I can't be sure without seeing your code, but antialias probably is NOT the problem.

(If it is, you can use "-colors N" to eliminate it.)

The problem is more likely to be that where you for example have a yellow area adjacent to a red area, potrace creates a spline curve around the red area, and another spline curve around the yellow area. There should be a common edge to these two curves. Due to the way potrace works, there won't be a common edge. The two areas will slightly overlap (which you won't notice) or there will be a small gap (which is what you see as "some white lines".

If one colour was contained entirely within another, eg yellow entirely within red, the cure would be to first merge the red and yellow areas, and potrace that, and paint that as red. Then potrace the yellow area and paint that yellow.

Your case is more difficult. The solution may be to analyse the output from potrace, adjusting curves so they exactly fit each other. (For a one-off job, you can do ths manually.) Another possibililty is to pre-process each area before potrace, making all areas slightly larger, so they always overlap and there is never a gap.
snibgo's IM pages: im.snibgo.com
Post Reply