Raytracing   • Raytracing •

< Raytracing

< IBL and HDRI


> Intro

> Overview

> Fisheye

> Mirror Ball

> Cube

> Light

> Filter

> Plugins

• Plugin Filter


 

— IBL and HDRI: HDRShop, Plugin Filter —

Blur Filter

Motion-Blur
HDRShop features a motion blur filter already, Image > Filter > Horizontal Motion Blur… (see Filter) but it works only in the horizontal direction. This plugin, however, permits to enter the angle of motion. The plugin needs the following information:

  • Size, range e.g. 40.
  • Sigma, fuzziness, the higher the value the more blur is applied, e.g. 8.
  • Angle, e.g. 1.0.
Result

Left the source image, right motion blur with Size=20, Sigma=8.0 and Angle=-45.0


Statistical Filter

Maxmedin – Maximal, Median, Minimal (opening & closing)
Statistical filters are suitable to remove noise in a picture, for example. The plugin uses a square mask with an odd number of pixels which is moved over the picture. A new image is created. The values of the pixels lying below the mask are considered and inserted at the location that corresponds to the centre of mask in the new image.

The Minimal filter finds the pixel with the lowest value under the mask and inserts this value into the new image. The minimal filter erodes the picture.

Conversely, the Maximal filter finds the pixel with the highest value under the mask and inserts that one into the new image. The maximal filter expands the picture.

The Median filter fetches all pixel values under the mask, sorts them in ascending or descending order and puts them in a list. The value that can be found in the centre of the list is the one that makes up the new pixel in the new image.

If a picture is eroded (minimal filter) and the resulting image expanded (maximal filter) than the picture was Opened. A picture can be Closed if it is first expanded and the result eroded.

The mask can be configured in different fashions. The Maxmedin plugin uses a square mask by setting all fields in the mask to 1. Other statistical filters do not set all fields, ordering them to a '+' (cross) or a 'x' (diagonal). Thus, a 3 x 3 mask does only have 5 of 9 fields set and hence only 5 pixels below the mask are taken into account for the result.

The filter type and the mask size can be specified:

  • Size, size of mask. The value must be odd, sensible mask sizes are 3, 5 or possibly 7, e.g. 3.
  • Max/Med/Min, filter type to use, Maximal, Median or Minimal.
Maxmedin

The picture shows the effect of the filter with Size=5. [1] original, a noisy part of an astronomy photograph taken with a CMOS DSLR without noise reduction engaged. [2] minimal filter, [3] maximal filter, [4] median filter, [5] opened (min & max), [6] closed (max & min). In the picture with the maximal filter, the square mask format is very obvious.


MyFilter — Your own filter

Here, custom masks for convolving filters can be defined. Statistical filters select pixel values that lie under the mask that meet a particular specification and create a new image with them. Another variant of convolving filters additionally manipulates the values of the pixels found under the mask.

Highpass and lowpass filters (sharpen, blur) multiply the values of the pixels that lie under the mask by the value defined in the correspnding mask field and divide the result by the sum of all values found in the fields of the mask. This value is given to the new pixel in the new image at the position corresponding to the centre of the mask.

Contour or outline filters are different. The sum of all values in the fields of the mask must be 0. The values of the pixels under the mask are multiplied by the value of the corresponding mask field and the result saved at the position of the centre of the mask in the new picture. The new values may be negative because the mask may contain negative values in its fields. The resulting picture is displayed correctly in HDRShop but once saved and reloaded, it is just black. Prior to saving, all values have to be made positive using Image > Calculate > |A| (see Light > Mathematical Functions).

The full file specification (drive, path, file name) must be supplied:

  • Path of Filter, full file specs, e.g. D:\HDRI\HDRShop\plugins\myFilters\HPF1.txt.

If the filter file cannot be found, a black picture results, even though the plugin reports Success! Well, at least it does not crash.

MyFilter

Three examples. The masks for the filters are shown below. [1] is the original picture, [2] blurred with the low pass filter shown just below as example for a filter file, [3] sharpened with the very strong highpass filter (see masks below) and [4] contours emphasised with the diagonal contour filter after Sobel (mask shown below).

Format of the Filter File
Filters can be defined in a simple text file. The first line always contains the text «norma 0.0». The second line needs the length of the edges of the mask (odd number), the following lines contain the values of the fields.

norma 0.0
size: 5
1.0  1.0  1.0  1.0  1.0
1.0  1.0  1.0  1.0  1.0
1.0  1.0  1.0  1.0  1.0
1.0  1.0  1.0  1.0  1.0
1.0  1.0  1.0  1.0  1.0

The example shows the lowpass filter used for the example [2] above. It consists of a 5 x 5 mask (size: 5) and hence needs values in five columns and five rows. The values of the 25 pixels lying under the mask are added and the result is divided by 25. This will be the value for the new pixel.

Filter Masks
A couple of working masks for LPF (low pass filter, blur); HPF (high pass filter, sharpen) and contour filter are shown below.

LPF – Lowpass Filter, blur
very weak   weak   strong   very strong
011111 111111
11611121 141111
010111 111111
    Sum = 20         Sum = 20         Sum = 12         Sum = 9    
 
HPF – Highpass Filter, sharpen
very weak   weak   strong   very strong
0-100-10 -1-1-1-1-1-1
-120-1-110-1 -116-1-110-1
0-100-10 -1-1-1-1-1-1
    Sum = 16         Sum = 6         Sum = 8         Sum = 2    
 
Laplace – Contour           Prewitt – Contour
weak     strong vertical     horizontal
0-101-21 10-1-1-1-1
-14-1-24-2 10-1000
0-101-21 10-1111
    Sum = 0         Sum = 0         Sum = 0         Sum = 0    
   
Sobel – Contour
vertical     horizontal     diagonal
10-1-1-2 -1-2-10
20-200 0-101
10-112 1012
        Sum = 0                 Sum = 0                 Sum = 0        
 

Filter masks from Hans-Ruedi Wernli «Die CCD Astrokamera für den Amateur» (Birkhäuser 1995),
ISBN 3-7643-5218-3, Teil 3: Bildbearbeitung.
(The CCD astro-camera for the amateur; part 3, Image Processing). With the generous permission from the author.

All convolving filters exhibit a unprocessed frame. This frame is one pixel wide for a 3 x 3 mask, two pixels for a 5 x 5 and three pixels for a 7 x 7 mask. The larger the mask, the more effective the filter gets. For most applications, a 3 x 3 mask suffices nicely, though.

 
  © 2004 - 2018 by Horo Wernli.