Colour Cylinder NetLogo Model
Produced for the book series "Artificial Intelligence";
Author: W. J. Teahan; Publisher: Ventus Publishing Aps, Denmark.
powered by NetLogo
view/download model file: Colour-Cylinder.nlogo
WHAT IS IT?
This model demonstrates how colour can be represented in 3 dimensions:
hue, saturation and brightness. These correspond to the dimensions that experiments indicate humans use to perceive colour.
WHAT IS ITS PURPOSE?
The purpose of this model is to show that if humans rely on three dimensions to perceive colour (hue, saturation and brightness), then it is not possible to exactly define precisely the concept of a particular colour (such as red or yellow) as it is not possible to define the boundaries between the different colours shown in the colour spindle or cylinder.
HOW IT WORKS
A drawer agent is used to draw the colour circle or rectangle. Two of the colour dimensions - hue, and saturation - determine what the colour circle looks like for a specific value of brightness. Peter Gardenfors' work with conceptual spaces theory talks about how humans perceive colour using a colour spindle - where the radius of the circle gets progressively smaller as the brightness is increased or decreased, eventually ending up at points for when the brightness is maximum or minimum. In the model, this is when the brightness is set to 255 and 0, and corresponds to the colours white and black, respectively.
As the model's visualisation is limited to 2D, the model depicts a colour cylinder instead of a colour spindle, with each colour circle representing a slice of the cylinder for a specific brightness value.
HOW TO USE IT
Press the setup button first. Then press either the draw-colour-rectangle or draw-colour-circle button next. The brightness slider determines the brightness of the colours that are drawn. The hue-increment and saturation-increment sliders can be used to control how fine the colour is drawn.
The model's Interface buttons are defined as follows:
- setup: This clears everything, makes the background white, and creates a drawer agent ready to draw the colour circle or rectangle.
- draw-colour-rectangle: This draws a colour rectangle for a specific brightness value. The hue is the x dimension and the saturation is the y dimension.
- draw-colour-circle: This draws a colour circle for a specific brightness value. The hue values are spread out around the 360 degrees of the circle, and the saturation values are spread out along various radii lengths from 0 to 255 from the centre of the circle.
The model's Interface sliders are defined as follows:
- brightness: This controls the brightness of the colour drawn.
- hue-increment and saturation-increment: This controls the increments used when drawing the colours. Smaller increments will mean that the drawing has finer detail.
THINGS TO NOTICE
Notice how difficult it is to define the region for a specific colour. For example, try drawing an imaginary line around everything that is yellow.
THINGS TO TRY
Try using the brightness slider to change the brightness value to see what effect it has on the colour circle and colour rectangle. Change the values of the hue-increment and saturation-increment sliders to change how fine an increment is used to draw the colour circle. Increasing the size of the increments will result in symmetrical patterns being drawn. Why is this? Try doing this while the circle is being drawn.
You can draw a border to the circle by modifying the following code:
[ set pcolor hsb-as-rgb ] ; set this to a specific color if you want to draw a border
; to the circle
Change "hsb-as-rgb" in the above code to the colour you want for your border. For example, if you want it to be black, set it to 0, if you want it to be blue, set it to 105.
EXTENDING THE MODEL
Have a go at adding labels to the colour circle such as red, yellow and green. Alternatively, set up a HubNet activity where each student chooses where to place colour labels. See how well they match across the classroom.
It uses the NetLogo command hsb to generate the patch colours based on the hue, saturation and brightness values. The patch-at-heading-and-distance command is used to draw the colour circle.
CREDITS AND REFERENCES
This model was created by William John Teahan.
To refer to this model in publications, please use:
Colour Cylinder NetLogo model.
Teahan, W. J. (2010). Artificial Intelligence. Ventus Publishing Aps
; Colour Cylinder model. ; ; Used to demonstrate how colour can be represented in 3 dimensions: ; hue, saturation and brightness. ; ; Copyright 2010 William John Teahan. All Rights Reserved. breed [ drawers drawer ] globals [ my-drawer ] to setup ask patches [ set pcolor white ] ; set background to white create-drawers 1 ; used for drawing the color circle or rectangle [ set color red set size 0 ; make invisible set xcor 0 set ycor 0 set my-drawer self ] end to draw-colour-rectangle ; displays the colours in a 2D environment let hue 0 let saturation 0 let h 0 let s 0 let hsb-as-rgb  set h min-pxcor while [h <= max-pxcor] [ ; spread out the different hues across the environment's x co-ordinates set hue (max-pxcor + h) / 2 set s min-pxcor while [s <= max-pycor] [ ; spread out the different saturations across the environment's y co-ordinates set saturation (max-pycor + s) / 2 set hsb-as-rgb hsb hue saturation brightness ask patch h s [ set pcolor hsb-as-rgb ] set s s + 1 ] set h h + 1 ] end to draw-colour-circle ; displays the colours in a 2D colour spindle let hue 0 let hue-heading 0 let reset-heading 0 ; for resetting the heading so that red is at 270 degrees let saturation 0 let hsb-as-rgb  set hue-heading 0 while [hue-heading < 360] [ ; spread out the different hues across headings from 0 to 360 degrees set hue (hue-heading * 256) / 360 ; scale 360 degrees down to 256 hues set saturation 0 while [saturation < 256] [ ; spread out the different saturations from 0 to 255 ; use saturation as the distance in patch-at-heading-and-distance below ask my-drawer [ set hsb-as-rgb hsb hue saturation brightness set reset-heading (hue-heading + 270) mod 360 ask patch-at-heading-and-distance reset-heading saturation [ ifelse (saturation > 252) [ set pcolor hsb-as-rgb ] ; set this to a specific color if you want to draw a border to the circle [ set pcolor hsb-as-rgb ] ] ] set saturation saturation + saturation-increment ] set hue-heading hue-heading + hue-increment ] end ; ; Copyright 2010 by William John Teahan. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from William John Teahan. ; Contact William John Teahan for appropriate licenses for redistribution for ; profit. ; ; To refer to this model in publications, please use: ; ; Teahan, W. J. (2010). Colour Cylinder NetLogo model. ; Artificial Intelligence. Ventus Publishing Aps. ;