inpainting_textureinpainting_textureInpaintingTextureInpaintingTextureinpainting_texture (Operator)

Name

inpainting_textureinpainting_textureInpaintingTextureInpaintingTextureinpainting_texture — Perform an inpainting by texture propagation.

Signature

inpainting_texture(Image, Region : InpaintedImage : MaskSize, SearchSize, Anisotropy, PostIteration, Smoothness : )

Herror inpainting_texture(const Hobject Image, const Hobject Region, Hobject* InpaintedImage, const Hlong MaskSize, const Hlong SearchSize, double Anisotropy, const char* PostIteration, double Smoothness)

Herror T_inpainting_texture(const Hobject Image, const Hobject Region, Hobject* InpaintedImage, const Htuple MaskSize, const Htuple SearchSize, const Htuple Anisotropy, const Htuple PostIteration, const Htuple Smoothness)

void InpaintingTexture(const HObject& Image, const HObject& Region, HObject* InpaintedImage, const HTuple& MaskSize, const HTuple& SearchSize, const HTuple& Anisotropy, const HTuple& PostIteration, const HTuple& Smoothness)

HImage HImage::InpaintingTexture(const HRegion& Region, Hlong MaskSize, Hlong SearchSize, double Anisotropy, const HString& PostIteration, double Smoothness) const

HImage HImage::InpaintingTexture(const HRegion& Region, Hlong MaskSize, Hlong SearchSize, double Anisotropy, const char* PostIteration, double Smoothness) const

HImage HImage::InpaintingTexture(const HRegion& Region, Hlong MaskSize, Hlong SearchSize, double Anisotropy, const wchar_t* PostIteration, double Smoothness) const   ( Windows only)

static void HOperatorSet.InpaintingTexture(HObject image, HObject region, out HObject inpaintedImage, HTuple maskSize, HTuple searchSize, HTuple anisotropy, HTuple postIteration, HTuple smoothness)

HImage HImage.InpaintingTexture(HRegion region, int maskSize, int searchSize, double anisotropy, string postIteration, double smoothness)

def inpainting_texture(image: HObject, region: HObject, mask_size: int, search_size: int, anisotropy: float, post_iteration: str, smoothness: float) -> HObject

Description

The operator inpainting_textureinpainting_textureInpaintingTextureInpaintingTextureInpaintingTextureinpainting_texture is used for removing large objects and image errors from the region RegionRegionRegionRegionregionregion of the input image ImageImageImageImageimageimage. Image blocks of side length MaskSizeMaskSizeMaskSizeMaskSizemaskSizemask_size are copied from the intact part of the image to the border of the computation area, until that area has been filled up with new gray values. This process is called image inpainting. Hence, the computation area is also referred to as the inpainting area and is reduced with every inserted rectangle, starting with RegionRegionRegionRegionregionregion. Let the center of the current block be at the point x. Since x is always chosen from the border of the inpainting area the current block overlaps with the known or already filled-in gray values. The gray value correlation with the overlapping part of this block is used to determine which other image block fits at the position x. As the correlation function, the sum of the squared gray value differences is used. The image blocks that are taken into account for the correlation, and hence as candidates for the data source of the next inpainting step, are called comparison blocks. The search area for suitable gray value patterns in which the centers of the comparison blocks is searched is limited to a square of side length 2*SearchSizeSearchSizeSearchSizeSearchSizesearchSizesearch_size around the point x.

On the one hand, the order in which the pixels of RegionRegionRegionRegionregionregion are filled in depends on the size of the overlapping area and thus the number of pixels available for the correlation. On the other hand, the absolute value of the derivative of the gray value function tangential to the border of the computation area is also considered. The larger the value of the parameter AnisotropyAnisotropyAnisotropyAnisotropyanisotropyanisotropy is, the more the points in which the derivative is large are preferred. This way it can be achieved that, e.g., straight lines which are represented by large gradients, are continued through the entire computation area without being interrupted by the inpainting of image structures from other parts of the border when the size of the inpainting area becomes small. On the other hand, a large value of AnisotropyAnisotropyAnisotropyAnisotropyanisotropyanisotropy also means that possible phantom edges, i.e., unwanted random structures that have developed during the inpainting process, are also propagated and the magnitude of those image disturbances is increased.

To confine the formation of such artifacts, the original algorithm can be extended by a post-iteration step that selects smooth and inconspicuous image patches as data sources for the inpainting. If the parameter PostIterationPostIterationPostIterationPostIterationpostIterationpost_iteration is set to 'min_grad'"min_grad""min_grad""min_grad""min_grad""min_grad" the sum of the squares of the gray value gradients is minimized on the comparison blocks. With the value 'min_range_extension'"min_range_extension""min_range_extension""min_range_extension""min_range_extension""min_range_extension", the growth of the gray value interval of the comparison blocks with respect to the reference block around the point x is minimized. If PostIterationPostIterationPostIterationPostIterationpostIterationpost_iteration has the value 'none'"none""none""none""none""none" no post-iteration is performed. The choice of feasible blocks for this minimization process is determined by the parameter SmoothnessSmoothnessSmoothnessSmoothnesssmoothnesssmoothness, which is an upper limit to the permitted increase of the mean absolute gray value difference between the comparison blocks and the reference block with respect to the block that was selected by the original algorithm. With increasing value of SmoothnessSmoothnessSmoothnessSmoothnesssmoothnesssmoothness, the inpainting result becomes smoother and loses structure. The matching accuracy of the selected comparison blocks decreases. If SmoothnessSmoothnessSmoothnessSmoothnesssmoothnesssmoothness is set to 0, the post-iteration only considers comparison blocks with an equally high correlation to the reference block.

If the inpainting process cannot be completed because there are points x, for which no complete block of intact gray value information is contained in the search area of size SearchSizeSearchSizeSearchSizeSearchSizesearchSizesearch_size, the remaining pixels keep their initial gray value and the ROI of the output image InpaintedImageInpaintedImageInpaintedImageInpaintedImageinpaintedImageinpainted_image is reduced by the region that could not be processed. If the structure size of the ROI of ImageImageImageImageimageimage or of the computation area RegionRegionRegionRegionregionregion is smaller than MaskSizeMaskSizeMaskSizeMaskSizemaskSizemask_size, the execution time of the algorithm can increase extremely. Hence, it is recommended to only use clearly structured input regions.

Attention

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution Information

Parameters

ImageImageImageImageimageimage (input_object)  (multichannel-)image(-array) objectHImageHObjectHImageHobject (byte / uint2 / real)

Input image.

RegionRegionRegionRegionregionregion (input_object)  region objectHRegionHObjectHRegionHobject

Inpainting region.

InpaintedImageInpaintedImageInpaintedImageInpaintedImageinpaintedImageinpainted_image (output_object)  image(-array) objectHImageHObjectHImageHobject * (byte / uint2 / real)

Output image.

MaskSizeMaskSizeMaskSizeMaskSizemaskSizemask_size (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Size of the inpainting blocks.

Default: 9

Suggested values: 7, 9, 11, 15, 21

Restriction: MaskSize >= 3 && odd(MaskSize)

SearchSizeSearchSizeSearchSizeSearchSizesearchSizesearch_size (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Size of the search window.

Default: 30

Suggested values: 15, 30, 50, 100, 1000

Restriction: 2 * SearchSize > MaskSize

AnisotropyAnisotropyAnisotropyAnisotropyanisotropyanisotropy (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Influence of the edge amplitude on the inpainting order.

Default: 1.0

Suggested values: 0.0, 0.01, 0.1, 0.5, 1.0, 10.0

Restriction: Anisotropy >= 0

PostIterationPostIterationPostIterationPostIterationpostIterationpost_iteration (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Post-iteration for artifact reduction.

Default: 'none' "none" "none" "none" "none" "none"

List of values: 'min_grad'"min_grad""min_grad""min_grad""min_grad""min_grad", 'min_range_extension'"min_range_extension""min_range_extension""min_range_extension""min_range_extension""min_range_extension", 'none'"none""none""none""none""none"

SmoothnessSmoothnessSmoothnessSmoothnesssmoothnesssmoothness (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Gray value tolerance for post-iteration.

Default: 1.0

Suggested values: 0.0, 0.1, 0.2, 0.5, 1.0

Restriction: Smoothness >= 0

Module

Foundation