most colors used (color analysis)

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?".
rudi

Re: most colors used (color analysis)

Post by rudi »

I was searching for some information about how the -segment option works and found this thread...
The -segment option does do this but is very hard to use.
Is there any information around that explains the output from -segment ?

What I'm trying to do is find areas of black text on a colour-indexed geographical map and obscure them. This is for a map-reading game where players are supposed to find a location by using the map information but without having placenames printed on the map to help them.

I can get the output from convert -segment using -verbose but it isn't all that meaningful to me.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: most colors used (color analysis)

Post by fmw42 »

What I'm trying to do is find areas of black text on a colour-indexed geographical map and obscure them. This is for a map-reading game where players are supposed to find a location by using the map information but without having placenames printed on the map to help them.
Perhaps you could explain this in more detail with an example. You may not need -segment as there may be easier ways to do what you want, for example using -fuzz XX% -fill some color -opaque black
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: most colors used (color analysis)

Post by anthony »

You may even be able replace the text with transparency and then use some 'hole filling' type algorithm.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rudi

Re: most colors used (color analysis)

Post by rudi »

fmw42
The map comes as a png file and has labels (e.g. placenames and names of other geographical features) printed on them. The players are meant to identify the location just by looking at the topography displayed on the map (contour lines representing hills and valleys, river courses, coastline, alignment of roads, tracks and railways etc.) without knowing the names of the features (as it would be possible to look them up and therefore spoil the point of the game). Either putting a bar across any names or blurring them would be fine - it doesn't have to be pretty or disguise the fact that a name is printed on the original map.
The names are printed in black but blend gradually into the surrounding colours. I was trying to find a way to locate dark pixels (i.e. those near to fuzzy black text), then to feather the selected area (to make it unreadable), and replace it with pure black.
It's the locating pixels by colour that I'm struggling with.

anthony
Do you mean hole filling in the sense of filling up the inner boundaries of a selected pattern, such as the inside of an 'o'? I would still have to do something about the outer boundary as well, as the text would still be legible with filled-in o's and p's etc - just like pages typed energetically on an old mechanical typewriter...

Thank you both for taking the trouble!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: most colors used (color analysis)

Post by anthony »

rudi wrote:anthony
Do you mean hole filling in the sense of filling up the inner boundaries of a selected pattern, such as the inside of an 'o'? I would still have to do something about the outer boundary as well, as the text would still be legible with filled-in o's and p's etc - just like pages typed energetically on an old mechanical typewriter...
In a way yes. You remove the text making a 'hole' (meaning it plays no part in the
final results - it is NOT PRESENT) then you fill in the hole based on the surrounding image. There are anumber of ways to do this, the best methods using only the
colors immediatally adjacent to the 'hole'.

One example of this is in IM Examples Photo Handling, removing text and logos
http://www.imagemagick.org/Usage/photos/#removing

There are also many other methods and techniques as well (morphology, FFT, sparse color filling), but these have not been developed exampled in IM as yet.

See the old discussion of this topic in...
viewtopic.php?p=41498#p41498
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: most colors used (color analysis)

Post by fmw42 »

you can remove text from an image via morphologic operators in particular the bottom hat.

see the topic at viewtopic.php?p=41498#p41498 for an example.
Post Reply