Skip to content

interpolate_scattered_data_imageInterpolateScatteredDataImageInterpolateScatteredDataImageinterpolate_scattered_data_imageT_interpolate_scattered_data_image🔗

Short description🔗

interpolate_scattered_data_imageInterpolateScatteredDataImageInterpolateScatteredDataImageinterpolate_scattered_data_imageT_interpolate_scattered_data_image — Interpolation of an image.

Signature🔗

interpolate_scattered_data_image( image Image, region RegionInterpolate, out image ImageInterpolated, string Method, attribute.name GenParamName, attribute.value GenParamValue )void InterpolateScatteredDataImage( const HObject& Image, const HObject& RegionInterpolate, HObject* ImageInterpolated, const HTuple& Method, const HTuple& GenParamName, const HTuple& GenParamValue )static void HOperatorSet.InterpolateScatteredDataImage( HObject image, HObject regionInterpolate, out HObject imageInterpolated, HTuple method, HTuple genParamName, HTuple genParamValue )def interpolate_scattered_data_image( image: HObject, region_interpolate: HObject, method: str, gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, int, float]] ) -> HObject

Herror T_interpolate_scattered_data_image( const Hobject Image, const Hobject RegionInterpolate, Hobject* ImageInterpolated, const Htuple Method, const Htuple GenParamName, const Htuple GenParamValue )

Description🔗

interpolate_scattered_data_imageInterpolateScatteredDataImage interpolates the Imageimageimage at the region RegionInterpolateregionInterpolateregion_interpolate and returns the result in ImageInterpolatedimageInterpolatedimage_interpolated. The difference of the domain of the Imageimageimage and the region RegionInterpolateregionInterpolateregion_interpolate specifies the valid data points that can be used for the interpolation whereas RegionInterpolateregionInterpolateregion_interpolate specifies the points, where the gray values of the Imageimageimage should be determined. With the parameter Methodmethodmethod the interpolation algorithm is specified. So far, only the 'thin_plate_splines'"thin_plate_splines" are supported. This method interpolates on a global scale, which means that all points are regarded for the interpolation, no matter how far away they are. The influence of far points is correlated to \(r^2 \cdot \log(r)\) where \(r\) defines the distance of two points. If the same Imageimageimage is interpolated at different points in subsequent steps, the operator create_scattered_data_interpolatorCreateScatteredDataInterpolator may be more efficient.

The following parameters can be adjusted with GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value:

  • 'alpha'"alpha": The parameter 'alpha'"alpha" is a smoothing factor. For 'alpha'"alpha" \(=\) 0, all points in the image Imageimageimage are interpolated exactly. With 'alpha'"alpha" getting larger, the interpolation smoothes the image points in way that all interpolated points of the result image ImageInterpolatedimageInterpolatedimage_interpolated lie on a common plane.

    Default: is 00

    Restriction: 'alpha'"alpha" \(>=\) 00

interpolate_scattered_data_imageInterpolateScatteredDataImage is best used with very few data points, e.g, less than 1000. In order to reconstruct destroyed image data in the region RegionInterpolateregionInterpolateregion_interpolate, the data points should be reduced to an appropriate number, e.g., by only using the border pixels of the hole regions. An example program is shown below.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Imageimageimage (input_object) singlechannelimage → object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject (byte / uint2 / real)

Image to interpolate

RegionInterpolateregionInterpolateregion_interpolate (input_object) region → objectHObjectHRegionHObjectHobject

Region to interpolate

ImageInterpolatedimageInterpolatedimage_interpolated (output_object) singlechannelimage → object (real)HObject (real)HImage (real)HObject (real)Hobject * (real)

Interpolated image

Methodmethodmethod (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Method for the interpolation

Default: 'thin_plate_splines'"thin_plate_splines"
Suggested values: 'thin_plate_splines'"thin_plate_splines"

GenParamNamegenParamNamegen_param_name (input_control) attribute.name-array → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Names of the generic parameters that can be adjusted

Default: [][]
Suggested values: 'alpha'"alpha"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value-array → (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)Sequence[Union[str, int, float]]Htuple (char* / Hlong / double)

Values of the generic parameters that can be adjusted

Default: [][]
Suggested values: 0, 1.0, 10.0, 100.00, 1.0, 10.0, 100.0

Example🔗

(HDevelop)

* This example program shows how to use the scattered data interpolator
* to fill holes in an image
gen_image_surface_second_order (ImageData, 'real', 1, 1, 0, 0, 0, 1, \
                                24, 24, 48, 48)
gen_circle (Circle, 12, 12, 6)
difference (ImageData, Circle, Region)
reduce_domain (ImageData, Region, ImageReduced)
dev_clear_window ()
dev_display (ImageReduced)
stop()
*
* Select only border pixels for the interpolation
dilation_circle (Circle, CircleDilation, 1.5)
intersection (CircleDilation, Region, RegionBorderData)
dev_clear_window ()
dev_display (ImageReduced)
dev_display (RegionBorderData)
stop()
*
* Interpolate pixels
reduce_domain (ImageData, RegionBorderData, ImageReducedBorder)
interpolate_scattered_data_image (ImageReducedBorder, Circle, \
                                  ImageInterpolated, \
                                  'thin_plate_splines', [], [])
paint_gray (ImageInterpolated, ImageData, ImageFilled)
dev_clear_window ()
dev_display (ImageFilled)

Result🔗

If the parameters are valid, the operator interpolate_scattered_data_imageInterpolateScatteredDataImage returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Alternatives

interpolate_scattered_data_points_to_imageInterpolateScatteredDataPointsToImage

Module🔗

Foundation