ImageDev

LocalAutocorrelationFilter2d

Computes the cross correlation of a two-dimensional image by itself in a given window size.

Access to parameter description

The autocorrelation is given by the formula: $$ O(n,m)=\frac{1}{2K}\sum_{i=-q}^{q}\sum_{j=-r}^{r}g(n-i,m-j) $$ $$ \mbox{where}~ g(l,k)=I(l,k)\times I(l+S,k)+I(l,k)\times I(l,k+S) $$ For a window of size $2q+1$ in X and $2r+1$ in Y.

$K$ is the Normalization coefficient: $K=(2q+1)\times(2r+1)$.

$S$ is autocorrelation offset. In this implementation it is equal to the size of the window: $S=2q+1=2r+1$.
The autocorrelation formula applied here can be written as follows: $$ O(n,m)=\frac{1}{2S^2}\sum_{i=-\frac{S-1}{2}}^{\frac{S-1}{2}}\sum_{j=-\frac{S-1}{2}}^{\frac{S-1}{2}} \left [I(n-i,m-j)\times I(n-i+S,m-j)+I(n-i,m-j)\times I(n-i,m-j+S)\right ] $$

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > localAutocorrelationFilter2d( std::shared_ptr< iolink::ImageView > inputImage, int32_t kernelSize, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
local_autocorrelation_filter_2d(input_image: idt.ImageType,
                                kernel_size: int = 3,
                                output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
LocalAutocorrelationFilter2d( IOLink.ImageView inputImage,
                              Int32 kernelSize = 3,
                              IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Grayscale nullptr
input
kernelSize
The size of the kernel (the side length of the square window in pixels). Int32 >=1 3
output
outputImage
The output image. Its dimensions are forced to the same values as the input. Its data type is promoted. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Grayscale None
input
kernel_size
The size of the kernel (the side length of the square window in pixels). int32 >=1 3
output
output_image
The output image. Its dimensions are forced to the same values as the input. Its data type is promoted. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Grayscale null
input
kernelSize
The size of the kernel (the side length of the square window in pixels). Int32 >=1 3
output
outputImage
The output image. Its dimensions are forced to the same values as the input. Its data type is promoted. Image null

Object Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

LocalAutocorrelationFilter2d localAutocorrelationFilter2dAlgo;
localAutocorrelationFilter2dAlgo.setInputImage( polystyrene );
localAutocorrelationFilter2dAlgo.setKernelSize( 3 );
localAutocorrelationFilter2dAlgo.execute();

std::cout << "outputImage:" << localAutocorrelationFilter2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

local_autocorrelation_filter_2d_algo = imagedev.LocalAutocorrelationFilter2d()
local_autocorrelation_filter_2d_algo.input_image = polystyrene
local_autocorrelation_filter_2d_algo.kernel_size = 3
local_autocorrelation_filter_2d_algo.execute()

print("output_image:", str(local_autocorrelation_filter_2d_algo.output_image))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

LocalAutocorrelationFilter2d localAutocorrelationFilter2dAlgo = new LocalAutocorrelationFilter2d
{
    inputImage = polystyrene,
    kernelSize = 3
};
localAutocorrelationFilter2dAlgo.Execute();

Console.WriteLine( "outputImage:" + localAutocorrelationFilter2dAlgo.outputImage.ToString() );

Function Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = localAutocorrelationFilter2d( polystyrene, 3 );

std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.local_autocorrelation_filter_2d(polystyrene, 3)

print("output_image:", str(result))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.LocalAutocorrelationFilter2d( polystyrene, 3 );

Console.WriteLine( "outputImage:" + result.ToString() );