Page 1 of 1

Color into shape

Posted: 2014-04-23T04:54:03-07:00
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.

Re: Color into shape

Posted: 2014-04-23T05:14:14-07:00
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

Re: Color into shape

Posted: 2014-04-24T00:26:02-07:00
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.

Re: Color into shape

Posted: 2014-04-24T01:04:47-07:00
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.

Re: Color into shape

Posted: 2014-04-24T03:35:33-07:00
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.

Re: Color into shape

Posted: 2014-04-24T03:46:50-07:00
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.