Problem with Writing the new image

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
nhamp07

Problem with Writing the new image

Post by nhamp07 »

I have a question that I thought maybe someone might know what was going on. I created a program through Perl that allows a user to start with a background image and add shapes...text...icons...arrows and lines to the background image.

I have run into one problem and cant seem to determine what is wrong. The background map is a map of counties in my jobs area of responsibility. One of the ways people use it is to shade counties they want to stick out. I do this by doing a FloodFill with the color they chose until it hits white (county boundaries). This works great...but for some reason if someone draws a white line through counties to get down on a smaller scale and then shades...the entire image becomes that color. This happens about 50% of the time. Sometimes it works the way intended and sometimes not. The only thing I can think of is when you draw the line and write the new file it skews the color slightly so when you try to shade it never hits the white for it to stop shading.

Does this make sense? This was my first program with ImageMagick and Im not that great of a programmer, but everything else works brilliantly.

Thanks for the help.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problem with Writing the new image

Post by snibgo »

Difficult to advise without seeing the application. You might try thickening the county boundaries so they are always at least 2 pixels wide at all scales.
snibgo's IM pages: im.snibgo.com
nhamp07

Re: Problem with Writing the new image

Post by nhamp07 »

that seems to have worked. I cant recreate the problem. Thanks for the help!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem with Writing the new image

Post by anthony »

Floodfill has a problem in that it will 'leak' though any small gap.

Thickening the boundaries using morphology 'Dilate' with maybe a 'Diamond' Kernel, then thinning using a 'skeleton' will generally close those gaps, though the boundaries may smooth out a little bit.

Morphology Dilation...
http://www.imagemagick.org/Usage/morphology/#dilate

Morphology Thinning Skeleton, and Pruning
http://www.imagemagick.org/Usage/morpho ... g_skeleton

NOTE Morphology is NEW, and some of these methods and kernels were only added a couple of months ago!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply