Color into shape

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
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Color into shape

Post by myspacee »

Hello,
i've an huge map (6200x6000 px). This map has been cropped/divided in as many shapes as the cities.
http://static.repubblica.it/laprovincia ... v/huge.png

preview:
Image

Is there any way to change color in a single shape ?
(EG: as red example )

thank you for any magic,
m.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color into shape

Post by snibgo »

See the various floodfill options on http://www.imagemagick.org/script/comma ... ptions.php

For example:

Code: Select all

convert huge.png -fill Blue -fuzz 50% -draw "color 1000,1000 floodfill" h.png
snibgo's IM pages: im.snibgo.com
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Re: Color into shape

Post by myspacee »

Thank you snibgo for reply.

Is there any way to have back all coordinates of changed area?

I want to automate html shape tags, and make clickable different areas.

Html accept this :

Code: Select all

...SHAPE="POLY" COORDS="32,36 32,188 65,136 133,124 82,36 ...
for me is easy to script an x,y cordinates array.

thank you for any info,
m.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color into shape

Post by snibgo »

To get the polygon boundary, I would go back to whatever created the map.

You can get boundaries from ImageMagick, eg (Windows BAT syntax):

Code: Select all

convert ^
  huge.png ^
  h.png ^
  -compose Difference -composite ^
  -fill White +opaque Black ^
  -morphology EdgeIn disk:1 ^
  -transparent Black ^
  sparse-color:edge.txt
This finds the difference between the original and one filled area (from my first script), makes the area white, finds the edge, and lists all the pixels in the edge. [EDIT: I incorrectly said that this is a polygon.] The coordinates would need processing to change the order into a polygon.

You might use potrace to convert the area to vectors, and simplify the vectors, but that is more difficult.
snibgo's IM pages: im.snibgo.com
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Re: Color into shape

Post by myspacee »

Thank you again,
i scale image to 1024px. This contains coordinates in usable form.
Now making Autoit script to parse txt files and compose HTML.

Reading also examples on your site speaking abount 'SVG text' and its 'Text on paths'. Nice reading.
Your program RdXml is available for download ?

thank you again snibgo,
m.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color into shape

Post by snibgo »

Sorry, I haven't published RdXml or any other compiled programs. On that page, the work done by RdXml (extracting paths from SVG) can be done by hand, or a script.
snibgo's IM pages: im.snibgo.com
Post Reply