Site Tools


RhPicture Plug-in Filter Routines

Summary: A description of filter calls as exposed through the RhPicture plug-in

Filter types

The RhPicture plug-in comes with several 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 color-transformation to them. They are quite fast since every pixel is only 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 color of the pixel. The matrices can have different sizes depending on the filter or the settings for a filter. The larger the matrix, the more pixels that have to be read for every operation and the slower the filter will get:



The illustration 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. 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.

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 plug-in. For practical examples see the example scripts that come with the plug-in 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 color and alpha data from the image except for the red channel.
RhPicture.RetainGreenChannel() Remove all color and alpha data from the image except for the green channel.
RhPicture.RetainBlueChannel() Remove all color 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 color data.
RhPicture.InvertAlpha() Invert the alpha data.
RhPicture.InvertAlpha() Invert the alpha data.
RhPicture.Desaturate() Convert the color data to greyscale colours.
RhPicture.Contrast(Amount As Double) Boost or reduce the contrast of all color 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 color 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 color channels.
RhPicture.Gamma(KfRed As Double, KfGreen As Double, KfBlue As Double) Apply a gamma transformation to individual color 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 RHINOSCRIPTIMAGEEXTENSION|RhPicture]] plug-in. For practical examples see the example scripts that come with the plug-in 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 3×3 sharpen pass.
RhPicture.MeanRemoval() Perform a single 3×3 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 RHINOSCRIPTIMAGEEXTENSION|RhPicture]] plug-in. For practical examples see the example scripts that come with the plug-in download.

Convolution matrix filters
Syntax Description
RhPicture.Pixelate(Size As Integer) Create a pixelated tiles with average colors. Size controls the width and height of the tiles in pixels.
RhPicture.ThresholdEdgeDetection([ThresHold As Integer [, Sensitivity As Double]]) Perform a 3×3 contrast detection on the image. The Threshold parameter controls how many neighboring 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. Valid 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 color is black.
developer/rhpicture/filtermethods.txt ยท Last modified: 2016/04/07 by sandy