Mapping Central color to areas covered by edges

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
aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Mapping Central color to areas covered by edges

Post by aigo »

Hi Everyone,

I am working on some images and would like to create an effect using an edge representation/skeleton of an image based on un-similar (unique) colours in the original image.

After which I will like to superimpose this edge mask on the original image and color the individual areas, one color (as dictated by the average/central of the colors present) per area.

I would appreciate any point in the right direction.

Cheers!

Aigo.
aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Mapping Central color to areas covered by edges

Post by aigo »

My IM version is 7.0.6-0 Q16 X86_64
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mapping Central color to areas covered by edges

Post by snibgo »

Edges and skeletons are two different effects.

Sample inputs and outputs might help us understand what you want.
snibgo's IM pages: im.snibgo.com
aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Mapping Central color to areas covered by edges

Post by aigo »

Hi,

my bad.

what I aim to achieve is a skeleton-like mask of an image derived from the distribution of colours which can be used to create a representation of the original image but with one colour, for each area. Akin to the technique used in creating in cartoons I guess, where whole sections of an image is represented with a single colour.

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

Re: Mapping Central color to areas covered by edges

Post by snibgo »

That seems similar to:
Flat-colour cartoons
Partition boundary masks
Cartoon and texture
But perhaps not exactly the same?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mapping Central color to areas covered by edges

Post by fmw42 »

You have not said what OS you are using. If on Unix-like systems, see my kmeans script at the link below. Also for any OS, see IM -mean-shift. Examples of the latter are at viewtopic.php?f=4&t=25504
aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Mapping Central color to areas covered by edges

Post by aigo »

fmw42 wrote: 2017-08-01T18:21:02-07:00 You have not said what OS you are using. If on Unix-like systems, see my kmeans script at the link below. Also for any OS, see IM -mean-shift. Examples of the latter are at viewtopic.php?f=4&t=25504
Yeah I am on UNIX, and both the k-means and mean-shift helped me with the investigation.
And just as is mentioned on the site, they are quite slow for obvious reasons.

Thanks!
aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Mapping Central color to areas covered by edges

Post by aigo »

snibgo wrote: 2017-08-01T16:17:28-07:00 That seems similar to:
Flat-colour cartoons
Partition boundary masks
Cartoon and texture
But perhaps not exactly the same?
Yeah, the partition boundary masks are exactly what I am looking for.
Sadly, for a newbie to IM like myself the tutorials are not easy to follow plus they are bat files.

Is there an equivalent tutorial but for Unix Systems?
Or an inbuilt function in IM that can help me with this, I don't want to do much. Just have a decent boundary mask that I can superimpose on the original image to trace.

Thank you for you help so far.

Best!

Aigo.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mapping Central color to areas covered by edges

Post by fmw42 »

Perhaps you can provide an example input image. You can post to some free hosting service such as dropbox.com and put your URL here.

Please always provide your IM version and platform when asking questions, since syntax may vary.
aigo
Posts: 29
Joined: 2017-06-26T12:02:47-07:00
Authentication code: 1151

Re: Mapping Central color to areas covered by edges

Post by aigo »

Hi there.

Sorry about that.

Here's the sample image https://drive.google.com/file/d/0B3sq7o ... sp=sharing
IM version is 7.0.6-0, Mac-OS Sierra

Thanks!

Aigo
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mapping Central color to areas covered by edges

Post by fmw42 »

Code: Select all

convert faces.png -canny 0x1+10%+30% faces_canny.png
Image

Or perhaps a combination of kmeans and canny edges.

Code: Select all

kmeans -n 10 -m 10 faces.png tmp.png
convert tmp.png \( +clone -canny 0x1+10%+30% -negate \)  -compose multiply -composite faces_kmeans_canny.png
Image


Or

Code: Select all

kmeans -n 10 -m 10 faces.png tmp.png
convert tmp.png \( +clone -canny 0x1+5%+10% -negate \)  -compose multiply -composite faces_kmeans_canny2.png
Image
Post Reply