Thursday 5 March 2009

The THRESHOLD Filter




























The threshold filter takes the most predominant colours in an image and turns them white. Colours that are less intense are turned black. Depending on the threshold level, the decision whether to change a pixel white or black varies.
When no threshold level parameter is supplied, the default value (0.5) is applied to the display screen. As you have probably learned by now, each colour has red, green and blue values, that range from 0 to 255. The threshold filter examines a pixel's red, green and blue values and (using the default 0.5) if the highest colour value is greater than half of 255, it changes the pixel to white, otherwise it is turned black.
In the applet above we have added a method, to apply the threshold filter. This method is called, with an increased threshold level, each time the draw method is entered. The image therefore appears to get filled in with black as the threshold level is increased.
After the filter has been applied the pixels array is used in 3 for loops to change the colour of the pixels in a different quadrant of the display screen. The first quadrant's pixels are not changed.
If you reload this page the colours are randomly changed.

No comments:

Post a Comment