comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Coloring labelled regions (or states)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Coloring labelled regions (or states) [message #92064] Tue, 06 October 2015 05:39 Go to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi,
I have an image where I identified regions (label_region). These regions are confining with one another as states do on a political map.
Can you suggest me a way to generate a colored image, so that I don't have neighboring "states" with too similar colors?

I can fill in the array values, I just dunno where to get appropriate colors or how to chose which one gets which.

I would be happy to get any information on how to do this. Something tells me that Brewer colors are the way to go, but I haven't figured out which one to use for which state...

Thanks,
Helder

PS: My problem has nothing to do with political maps, but that's a good approx. I'm not sure how many neighbors each region will have, but it should be comparable to typical values for political maps.
Re: Coloring labelled regions (or states) [message #92065 is a reply to message #92064] Tue, 06 October 2015 07:12 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Tuesday, October 6, 2015 at 7:39:53 AM UTC-5, Helder wrote:
> Hi,
> I have an image where I identified regions (label_region). These regions are confining with one another as states do on a political map.
> Can you suggest me a way to generate a colored image, so that I don't have neighboring "states" with too similar colors?
>
> I can fill in the array values, I just dunno where to get appropriate colors or how to chose which one gets which.
>

I always use this for help picking a palette:

http://colorbrewer2.org/

Sounds like you want a "qualitative" table.
Re: Coloring labelled regions (or states) [message #92066 is a reply to message #92065] Tue, 06 October 2015 08:08 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, October 6, 2015 at 4:12:22 PM UTC+2, Phillip Bitzer wrote:
> On Tuesday, October 6, 2015 at 7:39:53 AM UTC-5, Helder wrote:
>> Hi,
>> I have an image where I identified regions (label_region). These regions are confining with one another as states do on a political map.
>> Can you suggest me a way to generate a colored image, so that I don't have neighboring "states" with too similar colors?
>>
>> I can fill in the array values, I just dunno where to get appropriate colors or how to chose which one gets which.
>>
>
> I always use this for help picking a palette:
>
> http://colorbrewer2.org/
>
> Sounds like you want a "qualitative" table.

Hi,
that's a beautiful website. However, is there an easy way to automatically assign the colors?
For instance, I chose these colors (qualitative, 9 data classes, printer friendly):
228,26,28
55,126,184
77,175,74
152,78,163
255,127,0
255,255,51
166,86,40
247,129,191
153,153,153

How to I assign them? Is there an "ordered" way to do this or just from 1 to 9 looking at the result at the end?

Thanks,
Helder
Re: Coloring labelled regions (or states) [message #92067 is a reply to message #92066] Tue, 06 October 2015 08:18 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 10/6/15 9:08 am, Helder wrote:
> On Tuesday, October 6, 2015 at 4:12:22 PM UTC+2, Phillip Bitzer wrote:
>> On Tuesday, October 6, 2015 at 7:39:53 AM UTC-5, Helder wrote:
>>> Hi,
>>> I have an image where I identified regions (label_region). These regions are confining with one another as states do on a political map.
>>> Can you suggest me a way to generate a colored image, so that I don't have neighboring "states" with too similar colors?
>>>
>>> I can fill in the array values, I just dunno where to get appropriate colors or how to chose which one gets which.
>>>
>>
>> I always use this for help picking a palette:
>>
>> http://colorbrewer2.org/
>>
>> Sounds like you want a "qualitative" table.
>
> Hi,
> that's a beautiful website. However, is there an easy way to automatically assign the colors?
> For instance, I chose these colors (qualitative, 9 data classes, printer friendly):
> 228,26,28
> 55,126,184
> 77,175,74
> 152,78,163
> 255,127,0
> 255,255,51
> 166,86,40
> 247,129,191
> 153,153,153
>
> How to I assign them? Is there an "ordered" way to do this or just
from 1 to 9 looking at the result at the end?
>
> Thanks,
> Helder
>

Yes, this is what indexed color mode is for:

r = [228, 55, 77, 152, 255, 255, 166, 247, 153]
g = [26, 126, 175, 78, 127, 255, 86, 129, 153]
b = [28, 184, 74, 163, 0, 51, 40, 191, 153]

tvlct, r, g, b
device, decomposed=0

Then, just use COLOR=0, COLOR=1, etc.

Deciding on which areas just which colors is another matter...

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: Coloring labelled regions (or states) [message #92068 is a reply to message #92066] Tue, 06 October 2015 08:19 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helder writes:

> that's a beautiful website. However, is there an easy way to automatically assign the colors?
> For instance, I chose these colors (qualitative, 9 data classes, printer friendly):
> 228,26,28
> 55,126,184
> 77,175,74
> 152,78,163
> 255,127,0
> 255,255,51
> 166,86,40
> 247,129,191
> 153,153,153
>
> How to I assign them? Is there an "ordered" way to do this or just from 1 to 9 looking at the result at the end?

"He who strives for simplicity, wastes his time." - Coyote

I'd probably try it sequentially, and if that didn't look so great, I'd
probably try a bunch of random combinations, using various seeds so I
could reproduce the results. After that...I'd assign Coyote the job. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Coloring labelled regions (or states) [message #92071 is a reply to message #92068] Tue, 06 October 2015 09:01 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi Mike,
I was looking into how to properly sort (assign) the colors.
I'll start with Coyote's suggestion (sequentially) and see where it goes from there.
Thanks, Helder
Re: Coloring labelled regions (or states) [message #92072 is a reply to message #92068] Tue, 06 October 2015 09:05 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Thanks David, I'll try that and see. I thought that there would be some clever algorithm based on distances between center of masses and number of neighbors...
Cheers, Helder
Re: Coloring labelled regions (or states) [message #92073 is a reply to message #92072] Tue, 06 October 2015 09:10 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helder writes:

> Thanks David, I'll try that and see. I thought that there would be some clever algorithm based on distances between center of masses and number of neighbors...

I'm sure there is. And, it probably works about as well as assigning
random colors. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Coloring labelled regions (or states) [message #92075 is a reply to message #92073] Tue, 06 October 2015 09:20 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>
> Helder writes:
>
>> Thanks David, I'll try that and see. I thought that there would be some clever algorithm based on distances between center of masses and number of neighbors...
>
> I'm sure there is. And, it probably works about as well as assigning
> random colors. :-)

With sufficient colors and a limited number of "connections" between
regions, I can envision an algorithm that removes "neighboring" colors
from a list of colors, before picking one at random. This is guaranteed
to be slow, though, depending upon how many regions you have. And, a lot
of paperwork to keep track of. I'd definitely give random a shot first.

Maybe random with color removal? Assign a random color. Remove that from
the list of colors, assign the next random color from the shortened
list, etc. Rinse and repeat. I can still envision situations that it
wouldn't work with.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Coloring labelled regions (or states) [message #92076 is a reply to message #92075] Tue, 06 October 2015 09:38 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
On 10/06/2015 06:20 PM, David Fanning wrote:
> With sufficient colors

it seems that only four are needed ;-)

https://en.wikipedia.org/wiki/Four_color_theorem

Fabien
Re: Coloring labelled regions (or states) [message #92077 is a reply to message #92064] Tue, 06 October 2015 14:53 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Tuesday, October 6, 2015 at 8:39:53 AM UTC-4, Helder wrote:
> Hi,
> I have an image where I identified regions (label_region). These regions are confining with one another as states do on a political map.
> Can you suggest me a way to generate a colored image, so that I don't have neighboring "states" with too similar colors?

I had a similar problem a while back

https://groups.google.com/forum/?fromgroups&hl=en#!searc hin/comp.lang.idl-pvwave/wayne$20brewer/comp.lang.idl-pvwave /ZKTMA2GAgmw/e7GzEbdrlUIJ

I never found a single optimal solution but because my display was part of a widget, I could add buttons for the user to quickly click through different color tables - click, click,click -- till they found one they liked. --Wayne
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: formatting numbers in widget_propertysheet
Next Topic: Geometric mismatch using cgImage and cgDrawShapes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:07:05 PDT 2025

Total time taken to generate the page: 0.01615 seconds