inpainting_cedinpainting_cedInpaintingCedInpaintingCedinpainting_ced (算子名称)

名称

inpainting_cedinpainting_cedInpaintingCedInpaintingCedinpainting_ced — Perform an inpainting by coherence enhancing diffusion.

参数签名

inpainting_ced(Image, 区域 : InpaintedImage : Sigma, Rho, Theta, Iterations : )

Herror inpainting_ced(const Hobject Image, const Hobject 区域, Hobject* InpaintedImage, double Sigma, double Rho, double Theta, const Hlong Iterations)

Herror T_inpainting_ced(const Hobject Image, const Hobject 区域, Hobject* InpaintedImage, const Htuple Sigma, const Htuple Rho, const Htuple Theta, const Htuple Iterations)

void InpaintingCed(const HObject& Image, const HObject& 区域, HObject* InpaintedImage, const HTuple& Sigma, const HTuple& Rho, const HTuple& Theta, const HTuple& Iterations)

HImage HImage::InpaintingCed(const HRegion& 区域, double Sigma, double Rho, double Theta, Hlong Iterations) const

static void HOperatorSet.InpaintingCed(HObject image, HObject 区域, out HObject inpaintedImage, HTuple sigma, HTuple rho, HTuple theta, HTuple iterations)

HImage HImage.InpaintingCed(HRegion 区域, double sigma, double rho, double theta, int iterations)

def inpainting_ced(image: HObject, 区域: HObject, sigma: float, rho: float, theta: float, iterations: int) -> HObject

描述

该算子 inpainting_cedinpainting_cedInpaintingCedInpaintingCedInpaintingCedinpainting_ced performs an anisotropic diffusion process on the region 区域区域区域区域区域区域 of the input image ImageImageImageImageimageimage with the objective of completing discontinuous image edges diffusively by increasing the coherence of the image structures contained in ImageImageImageImageimageimage and without smoothing these edges perpendicular to their dominating direction. The mechanism is the same as in 该算子 coherence_enhancing_diffcoherence_enhancing_diffCoherenceEnhancingDiffCoherenceEnhancingDiffCoherenceEnhancingDiffcoherence_enhancing_diff, which is based on a discretization of the anisotropic diffusion equation formulated by Weickert. With a 2x2 coefficient matrix G that depends on the gray values in ImageImageImageImageimageimage, this is an enhancement of the mean curvature flow or intrinsic heat equation on the gray value function u defined by the input image ImageImageImageImageimageimage at a time . The smoothing operator mean_curvature_flowmean_curvature_flowMeanCurvatureFlowMeanCurvatureFlowMeanCurvatureFlowmean_curvature_flow is a direct application of the mean curvature flow equation. With 该算子 inpainting_mcfinpainting_mcfInpaintingMcfInpaintingMcfInpaintingMcfinpainting_mcf, it can also be used for image inpainting. The discrete diffusion equation is solved in IterationsIterationsIterationsIterationsiterationsiterations time steps of length ThetaThetaThetaThetathetatheta, so that the output image InpaintedImageInpaintedImageInpaintedImageInpaintedImageinpaintedImageinpainted_image contains the gray value function at the time IterationsIterationsIterationsIterationsiterationsiterations * ThetaThetaThetaThetathetatheta .

To detect the image direction more robustly, in particular on noisy input data, an additional isotropic smoothing step can precede the computation of the gray value gradients. The parameter SigmaSigmaSigmaSigmasigmasigma determines the magnitude of the smoothing by means of the standard deviation of a corresponding Gaussian convolution kernel, as used in 该算子 isotropic_diffusionisotropic_diffusionIsotropicDiffusionIsotropicDiffusionIsotropicDiffusionisotropic_diffusion for isotropic image smoothing.

Similar to 该算子 inpainting_mcfinpainting_mcfInpaintingMcfInpaintingMcfInpaintingMcfinpainting_mcf, the structure of the image data in 区域区域区域区域区域区域 is simplified by smoothing the level lines of ImageImageImageImageimageimage. By this, image errors and unwanted objects can be removed from the image, while the edges in the neighborhood are extended continuously. This procedure is called image inpainting. The objective is to introduce a minimum amount of artifacts or smoothing effects, so that the image manipulation is least visible to a human beholder.

While the matrix G is given by in the case of 该算子 inpainting_mcfinpainting_mcfInpaintingMcfInpaintingMcfInpaintingMcfinpainting_mcf, where I denotes the unit matrix, is again smoothed componentwise by a Gaussian filter of standard deviation RhoRhoRhoRhorhorho for coherence_enhancing_diffcoherence_enhancing_diffCoherenceEnhancingDiffCoherenceEnhancingDiffCoherenceEnhancingDiffcoherence_enhancing_diff. Then, the final coefficient matrix is constructed from the eigenvalues and eigenvectors of the resulting intermediate matrix, where the functions were determined empirically and taken from the publication of Weickert.

Hence, the diffusion direction in mean_curvature_flowmean_curvature_flowMeanCurvatureFlowMeanCurvatureFlowMeanCurvatureFlowmean_curvature_flow is only determined by the local direction of the gray value gradient, while considers the macroscopic structure of the image objects on the scale RhoRhoRhoRhorhorho and the magnitude of the diffusion in coherence_enhancing_diffcoherence_enhancing_diffCoherenceEnhancingDiffCoherenceEnhancingDiffCoherenceEnhancingDiffcoherence_enhancing_diff depends on how well this structure is defined.

To achieve the highest possible consistency of the newly created edges with the image data from the neighborhood, the gray values are not mirrored at the border of 区域区域区域区域区域区域 to compute the convolution with the smoothing filter mask of scale RhoRhoRhoRhorhorho on the pixels close to the border, although this would be the common approach for filter operators. Instead, the existence of gray values on a band of width ceil(3.1*Rho)+2 pixels around 区域区域区域区域区域区域 is presumed and these values are used in the convolution. This means that 区域区域区域区域区域区域 must keep this much distance to the border of the image matrix ImageImageImageImageimageimage. By involving the gray values and directional information from this extended area, it can be achieved that the continuation of the edges is not only continuous, but also smooth, which means without kinks. Please note that the inpainting progress is restricted to those pixels that are included in the ROI of the input image ImageImageImageImageimageimage. If the ROI does not include the entire region 区域区域区域区域区域区域, a band around the intersection of 区域区域区域区域区域区域 and the ROI is used to define the boundary values.

To decrease the number of iterations required for attaining a satisfactory result, it may be useful to initialize the gray value matrix in 区域区域区域区域区域区域 with the harmonic interpolant, a continuous function of minimal curvature, by applying 该算子 harmonic_interpolationharmonic_interpolationHarmonicInterpolationHarmonicInterpolationHarmonicInterpolationharmonic_interpolation to ImageImageImageImageimageimage before calling inpainting_cedinpainting_cedInpaintingCedInpaintingCedInpaintingCedinpainting_ced.

注意

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

运行信息

参数表

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

Input image.

区域区域区域区域区域区域 (input_object)  region objectHRegionHObjectHRegionHobject

Inpainting region.

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

Output image.

SigmaSigmaSigmaSigmasigmasigma (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Smoothing for derivative operator.

Default: 0.5

Suggested values: 0.0, 0.1, 0.5, 1.0

Restriction: Sigma >= 0

RhoRhoRhoRhorhorho (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Smoothing for diffusion coefficients.

Default: 3.0

Suggested values: 0.0, 1.0, 3.0, 5.0, 10.0, 30.0

Restriction: Rho >= 0

ThetaThetaThetaThetathetatheta (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Time step.

Default: 0.5

Suggested values: 0.1, 0.2, 0.3, 0.4, 0.5

Restriction: 0 < Theta <= 0.5

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

Number of iterations.

Default: 10

Suggested values: 1, 5, 10, 20, 50, 100, 500

Restriction: Iterations >= 1

例程 (HDevelop)

read_image (Image, 'fabrik')
gen_rectangle1 (Rectangle, 270, 180, 320, 230)
harmonic_interpolation (Image, Rectangle, InpaintedImage, 0.01)
inpainting_ced (InpaintedImage, Rectangle, InpaintedImage2, \
                0.5, 3.0, 0.5, 1000)
dev_display(InpaintedImage2)

可替代算子

harmonic_interpolationharmonic_interpolationHarmonicInterpolationHarmonicInterpolationHarmonicInterpolationharmonic_interpolation, inpainting_ctinpainting_ctInpaintingCtInpaintingCtInpaintingCtinpainting_ct, inpainting_anisoinpainting_anisoInpaintingAnisoInpaintingAnisoInpaintingAnisoinpainting_aniso, inpainting_mcfinpainting_mcfInpaintingMcfInpaintingMcfInpaintingMcfinpainting_mcf, inpainting_textureinpainting_textureInpaintingTextureInpaintingTextureInpaintingTextureinpainting_texture

References

J. Weickert, V. Hlavac, R. Sara; “Multiscale texture enhancement”; Computer analysis of images and patterns, Lecture Notes in Computer Science, Vol. 970, pp. 230-237; Springer, Berlin; 1995.
J. Weickert, B. ter Haar Romeny, L. Florack, J. Koenderink, M. Viergever; “A review of nonlinear diffusion filtering”; Scale-Space Theory in Computer Vision, Lecture Notes in Comp. Science, Vol. 1252, pp. 3-28; Springer, Berlin; 1997.

模块

Foundation