McNeel Wiki
RhPicture Plugin Filter Routines
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Rhino Labs

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

 
.
SummaryA description of filter calls as exposed through the RhPicture plugin.

 

Filter types

The RhPicture plugin comes with a number of predefined filters that can be used to process entire images. These filters fall into three categories:

 

  • Per pixel filters
  • Convolution Matrix filters
  • Custom filters

 

Per pixel filters are easiest to understand. they simply iterate over all pixels in the image and apply some sort of colour-transformation to them. They are quite fast since every pixel will only have to be read/written once.

Convolution matrix filters use a similar approach, except that every operation involves more than one pixel. A predefined matrix with weighted values is centered over each pixel in the image and the surrounding pixels are all measured and weighted based on the matrix row and column values. Finally, all these weighted factors are averaged resulting in the new colour of the pixel in question. The matrices can have different sizes depending on the filter or the settings for a filter. The larger the matrix, the more pixels have to be read for every operation and the slower the filter will get:

 

 

The illustration above shows the matrix for a convolution blur filter with a radius of 1. The radius of a convolution matrix is defined as the number of pixels it extends beyond the center pixel. In order to calculate the blurred version of pixel E we have to sample a total of 9 pixels. As the radius increases to 2 the sample set grows to 25 pixels and so on and so forth.

Custom filters are simply unique algorithms that are not representable as convolution matrix logic.

 

 

Per Pixel filters

A comprehensive list of all per pixel filters available in the RhPicture plugin. For practical examples see the example scripts that come with the plugin download.

 

Per pixel filters
Syntax Description
RhPicture.SetRedChannel(V As Byte) Set all the red channel values of all pixels to this value.
RhPicture.SetGreenChannel(V As Byte) Set all the green channel values of all pixels to this value.
RhPicture.SetBlueChannel(V As Byte) Set all the blue channel values of all pixels to this value.
RhPicture.SetAlphaChannel(V As Byte) Set all the alpha channel values of all pixels to this value.
RhPicture.Flatten() Remove all alpha data from the image.
RhPicture.RetainRedChannel() Remove all colour and alpha data from the image except for the red channel.
RhPicture.RetainGreenChannel() Remove all colour and alpha data from the image except for the green channel.
RhPicture.RetainBlueChannel() Remove all colour and alpha data from the image except for the blue channel.
RhPicture.MapChannel(Src As Integer, Dst As Integer [, Swap As Boolean]) Copy the information in the Source channel to the destination channel. If Swap = True then the channel information is exchanged rather that duplicated. Channel indices are (Red=0, Green=1, Blue=2, Alpha=3).
RhPicture.Invert() Invert the colour data.
RhPicture.InvertAlpha() Invert the alpha data.
RhPicture.InvertAlpha() Invert the alpha data.
RhPicture.Desaturate() Convert the colour data to greyscale colours.
RhPicture.Contrast(Amount As Double) Boost or reduce the contrast of all colour channels. If (0.0 < Amount < 1.0) then contrast is reduced. If (1.0 < Amount < +Inf) then contrast is increased.
RhPicture.Brightness(Amount As Double) Boost or reduce the brightness of all colour channels. If (0.0 < Amount < 1.0) then brightness is reduced. If (1.0 < Amount < +Inf) then brightness is increased.
RhPicture.Gamma(Kf As Double) Apply a gamma transformation to all colour channels.
RhPicture.Gamma(KfRed As Double, KfGreen As Double, KfBlue As Double) Apply a gamma transformation to individual colour channels.
RhPicture.Noise(Amount As Double [, GreyScale As Boolean]) Apply random noise to the image. Valid amount values are (0.0~1.0). If Greyscale is True by default.

 

 

Convolution Matrix filters

A comprehensive list of all matrix filters available in the RhPicture plugin. For practical examples see the example scripts that come with the plugin download.

 

Convolution Matrix filters
Syntax Description
RhPicture.BlurBox([Radius As Integer]) Perform a Box blur operation. This is a slow and poor quality blur filter. Radius is 1 by default.
RhPicture.BlurWeighted([Radius As Integer]) Perform a Weighted blur operation. This is a slow but high quality blur filter. Radius is 1 by default.
RhPicture.BlurHorizontal([Radius As Integer]) Same as Weighted blur, except the vertical radius is always zero.
RhPicture.BlurVertical([Radius As Integer]) Same as Weighted blur, except the horizontal radius is always zero.
RhPicture.BlurQuick([Radius As Integer]) Perform a Weighted blur operation. This is a fast and high quality blur filter. Radius is 1 by default.
RhPicture.Sharpen() Perform a single 3x3 sharpen pass.
RhPicture.MeanRemoval() Perform a single 3x3 mean removal pass. This is another kind of sharpen filter.
RhPicture.FindVerticalEdges() Find all vertical edges using a Sobell filter.
RhPicture.FindHorizontalEdges() Find all horizontal edges using a Sobell filter.
RhPicture.FindAllEdges() Find all edges using a bidirectional Sobell filter.

 

 

Custom filters

A comprehensive list of all custom filters available in the RhPicture plugin. For practical examples see the example scripts that come with the plugin download.

Convolution Matrix filters
Syntax Description
RhPicture.Pixelate(Size As Integer) Create a pixelated tiles with average colours. Size ocntrols the width and height of the tiles in pixels.
RhPicture.ThresholdEdgeDetection([ThresHold As Integer [, Sensitivity As Double]]) Perform a 3x3 contrast detection on the image. The Threshold parameter controls how many neighbouring pixels must breach the contrast barrier before a pixel turns black. The default is 1. The value must be in the range (1~8). Sensitivity controls the tolerance of the contrast test. Vald values are in the range (0.0~1.0). The default is 0.5, the higher the Sensitivity the more contrast is allowed.
RhPicture.Resize(Width As Integer, Height As Integer [, Quality As Integer]) Resizes the image to fit the new dimensions. The Quality parameter is identical to the one in RhPicture.DrawImage.
RhPicture.Crop([Left As Integer[, Top As Integer[, Right As Integer[, Bottom As Integer]]]]) Crops the image by removing the specified amount of pixels from each edge. Default values for all edges are 0.
RhPicture.Padding([Left As Integer[, Top As Integer[, Right As Integer[, Bottom As Integer [, Colour As GDIColour]]]]]) Adds rows and columns of pixels to each edge. Default values for all edges are 0. The default colour is black.
rename · changes · history · subscriptions · lost and found · references · file upload