# Fractals/Mathematics/LIC

line Integral Convolution (LIC):
* visualize dense flow fields by imaging its integral curves
* "emulates what happens when an area of fine sand is blown by strong wind" ( Zhanping Liu)
Method
* vover domain with a input texture
* blur (convolve) the input texture along the path lines using a specified filter kernel
* smear out the texture along stream lines

# Dictionary

* the integral curve of the vector field = field line of vector field = streamline of steady ( time independent) flow
* In mathematics, convolution is a special type of binary operation on two functions. Here discrete convolution is used

# elements

input:
* texture, usually stationary white noise ( random texture)
* vector field: a stationary vector field defined by a map $v:R^{2}\to R^{2}$
kernel:
* one dimensional matrix ( array) of weights
* with an odd kernel size to ensure there is a valid integer (x, y)-coordinate at the center of the image
* normalized. Normalization is defined as the division of each element in the kernel by the sum of all kernel elements, so that the sum of the elements of a normalized kernel is unity. This will ensure the average pixel in the modified image is as bright as the average pixel in the original image.
* often simple box filter
* often symmetric (isotropic) = the convolution kernel is symmetric across its zero point.
Convolution formula ( convolution is not matrix multiplication, when kernel matrix is used )
output image = Final LIC image of input vector field. It is a smeared version of the input texture , where the direction of smearing is determined by the vector field.

## vector field

Source
* synthetic data
* experimental data
Method
* array of values
* functions defining vector field

# algorithm

General steps for LIC image:
* For each pixel of output 2D array compute it's color
* save complete output array as 2D static image file
Substeps performed for each pixel of LIC image:
* choose pixel $p_{0}(x,y)$ from output array
* go to the Vector array
** choose value at pixel $p_{0}(x,y)$
** find segment of local field line

## dimensions

* all images ( textures, domains) have the same dimensions =

## segment of field line

* The field lines are calculated on basis of a vector field
* a segment of locations $l(s)=(i,j)+sV(i,j)$ where $s\in \left\{-L,-L+1,...,0,...,L-1,L\right\}$
* a segment of pixels intensities $I(l(s))$ of length 2L + 1

## tuple

In mathematics, a tuple is a finite ordered list (sequence) of elements.
Properties The general rule for the identity of two n-tuples is
    $(a_{1},a_{2},\ldots ,a_{n})=(b_{1},b_{2},\ldots ,b_{n})$ if and only if $a_{1}=b_{1},{\text{ }}a_{2}=b_{2},{\text{ }}\ldots ,{\text{ }}a_{n}=b_{n}$.
Thus a tuple has properties that distinguish it from a set:
* A tuple may contain multiple instances of the same element, so tuple $(1,2,2,3)\neq (1,2,3)$; but set $\{1,2,2,3\}=\{1,2,3\}$.
* Tuple elements are ordered: tuple $(1,2,3)\neq (3,2,1)$, but set $\{1,2,3\}=\{3,2,1\}$.
* A tuple has a finite number of elements, while a set or a multiset may have an infinite number of elements.

## weighted mean

Color of output pixel is computed using weighted mean
The weighted mean of a non-empty finite tuple of:
* data $\left(x_{1},x_{2},\dots ,x_{n}\right)$,
* corresponding non-negative weights $\left(w_{1},w_{2},\dots ,w_{n}\right)$
is
    ${\bar {x}}={\frac {\sum \limits _{i=1}^{n}w_{i}x_{i}}{\sum \limits _{i=1}^{n}w_{i}}}={\frac {w_{1}x_{1}+w_{2}x_{2}+\cdots +w_{n}x_{n}}{w_{1}+w_{2}+\cdots +w_{n}}}$
Therefore, data elements with a high weight contribute more to the weighted mean than do elements with a low weight.
The weights cannot be negative. Some may be zero, but not all of them (since division by zero is not allowed).

# versions

line Integral Convolution (LIC)
* Oriented Line Integral Convolution (OLIC)
** Fast Rendering of Oriented Line Integral Convolution ( FROLIC)

# Implementation

* GPU-Based-Image-Processing-Tools by RaymondMcGuire in python
* LIC (Line Integral Convolution) principle and Python implementation
* github
* LicPy

# References

* ↑ Lic by Zhanping Liu
* ↑ Kernel_(image_processing) in wikipedia
* ↑ Fast Oriented Line Integral Convolution for Vector Field Visualization via the Internet by Rainer Wegenkittl and Eduard Gr¨oller
* ↑ Java Exploration Tool for Dynamical Systems by R. Wegenkittl and E. Gröller.