Coloring labelled regions (or states) [message #92064] |
Tue, 06 October 2015 05:39  |
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 #92066 is a reply to message #92065] |
Tue, 06 October 2015 08:08   |
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   |
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   |
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 #92075 is a reply to message #92073] |
Tue, 06 October 2015 09:20   |
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.")
|
|
|
|
|