[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.FilterPixel

Name FilterPixel
Type Method
Summary Performs a filtering operation on one pixel
Prototype long FilterPixel(long Pixel, short Operation, double Options);

View list of data type meanings


This applies the specified filtering operation to the pixel supplied (an RGB code).

This does largely the same thing as WindowFilter, except it operates on a single pixel (that is, a single RGB colour). This does the same operations (with the same codes as for WindowFilter) excepting the ones which require more than one pixel (like Blur, Sharpen, Find Edges, and Emboss).

Operation - the filter operation. At present, one of:

1 - Apply colour noise

2 - Apply monochrome noise

7 - Adjust Brightness (by adding Options to the pixel)

8 - Adjust Contrast

9 - Adjust Gamma

10 - Adjust Brightness for red channel only (by adding Options to the pixel)

11 - Adjust Contrast for red channel only

12 - Adjust Gamma for red channel only

13 - Adjust Brightness for green channel only (by adding Options to the pixel)

14 - Adjust Contrast for green channel only

15 - Adjust Gamma for green channel only

16 - Adjust Brightness for blue channel only (by adding Options to the pixel)

17 - Adjust Contrast for blue channel only

18 - Adjust Gamma for blue channel only

19 - Convert to grayscale - mix red/green/blue equally

20 - Convert to grayscale - mix 30% red + 59% green + 11% blue for normal perception

21 - Adjust Brightness (by multiplying Options by the pixel)

22 - Adjust Brightness for red channel only (by multiplying Options by the pixel)

23 - Adjust Brightness for green channel only (by multiplying Options by the pixel)

24 - Adjust Brightness for blue channel only (by multiplying Options by the pixel)

27 - Average - the pixel's average colour (that is, itself)

Single channel operations - the modes which specify a single channel (10 to 18, 22 to 24) operate on that colour channel only (red, green or blue) leaving the others untouched. Thus by, say, increasing brightness on the red channel you add to the red value, but leave green and blue alone, making the image look redder. However decreasing brightness on the red channel would make the image look more cyan (as cyan is the complementary colour to red).

The complementary colours are:

red / cyan
green / magenta
blue / yellow

Options - filtering options.

For the Noise filter:

A number from about 0 to 255 indicating how much noise to add.

For the Brightness (additive) filter:

A number from -255 to +255 to indicate the amount to increase (or decrease) the value of the pixel - by adding. A negative number will make it darker, a positive number will make it brighter.

For the Brightness (multiplicative) filter:

A number which is multiplied by the value of the pixel. A number less than 1 will make it darker, a number greater than 1 will make it brighter. However black (zero) will remain black.

For the Contrast filter:

A number to indicate the amount to multiply by the value of the pixel. Zero will make the picture zero contrast, that is totally grey. If you use 1 the pixel will be normal contrast (as each pixel is multiplied by 1). A value between 0 and 1 will be lower contrast. A value above 1 will increase contrast. Negative numbers will have the effect of making the image look negative.

For the Gamma filter:

A number to indicate the amount of Gamma adjustment. Mathematically the pixel is raised to the power of this number. Thus, a gamma of 1 will result in no change. A gamma of 2 will darken the image somewhat. A gamma of 0.5 will lighten the image. A gamma of zero will make the image totally white.
The difference between gamma and brightness is that increasing brightness simply adds to the value of each pixel, so that black becomes gray, and bright pixel become clipped. Similarly, decreasing brightness means that white pixels become grey, and dark ones are clipped.

However because gamma is a power function, black stays black, and white stays white, with the biggest change in the mid range. A higher gamma value results in a darker image with more contrast. A lower gamma value (between 0 and 1) results in a lighter image with less contrast.

For more information, see:


Note: Available in version 4.36 onwards.

Lua example
-- Brightness

FilterPixel (0x445566, 7, -4) -- lower by 4 (gives 0x405162)
FilterPixel (0x445566, 7, 10) -- raise by 10 (gives 0x4e5f70)

FilterPixel (0x445566, 21, 0.5) -- halve the brightness (gives 0x222a33)
FilterPixel (0x445566, 21, 2) -- double the brightness (gives 0x88aacc)

-- Contrast

FilterPixel (0x445566, 8, 0.5) -- reduce (gives 0x626a73)
FilterPixel (0x445566, 8, 2) -- increase (gives 0x082a4c)

-- Gamma

FilterPixel (0x445566, 9, 0.3) -- brighter, lower contrast (gives 0xabb7c1)
FilterPixel (0x445566, 9, 1.5) -- darker, higher contrast (gives 0x233140)
FilterPixel (0x445566, 9, 5)   -- very dark and contrasty (gives 0x000102)
Lua notes
You can use the following constants for the Operation argument:

miniwin.filter_noise = 1
miniwin.filter_monochrome_noise = 2
miniwin.filter_brightness = 7
miniwin.filter_contrast = 8
miniwin.filter_gamma = 9
miniwin.filter_red_brightness = 10
miniwin.filter_red_contrast = 11
miniwin.filter_red_gamma = 12
miniwin.filter_green_brightness = 13
miniwin.filter_green_contrast = 14
miniwin.filter_green_gamma = 15
miniwin.filter_blue_brightness = 16
miniwin.filter_blue_contrast = 17
miniwin.filter_blue_gamma = 18
miniwin.filter_grayscale = 19
miniwin.filter_normal_grayscale = 20
miniwin.filter_brightness_multiply = 21
miniwin.filter_red_brightness_multiply = 22
miniwin.filter_green_brightness_multiply = 23
miniwin.filter_blue_brightness_multiply = 24
miniwin.filter_average = 27
Returns -1 : filter mode not in the list above.

Otherwise, the filtered pixel as an RGB code
Introduced in version 4.36

See also ...

Function Description
WindowFilter Performs a filtering operation over part of the miniwindow.

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.

Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes

Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes

View all functions


Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]