ImageEn, unit ievision




procedure inpaint(mask: TIEVisionImage; range: double; method: TIEVisionInpaintMethod = ievINPAINT_NS); overload; safecall;
procedure inpaint(brushWidth: int32_t; brushHeight: int32_t; const subimageRect: TIEVisionRect; range: double; method: TIEVisionInpaintMethod = ievINPAINT_NS); overload; safecall;


Restore the selected region in an image using the region neighborhood (to fill missing areas of image or erase blemishes).
First overload needs a mask to identify the area to be inpainted.
Second overload builds automatically the mask using specified brush size.

Parameter Description
mask Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that needs to be inpainted
range Radius of a circular neighborhood of each point inpainted that is considered by the algorithm (3 is a reasonable starting value)
method Inpainting algorithm, either Navier-Stokes method (ievINPAINT_NS) or the Telea algorithm (ievINPAINT_TELEA)
brushWidth Width of area to inpaint
brushHeight Height of area to inpaint
subimageRect Rectangle of area of interest (which includes the area to inpaint)

- A shortcut method for this is available: Inpaint
- Also available as a RetouchTool by setting MouseInteractGeneral to [miRetouchTool] and RetouchMode to iermIEVisionInpaint


Demo  Demos\IEVision\Inpaint_Brush\Inpaint_Brush.dpr
Demo  Demos\IEVision\Inpaint_Selection\Inpaint_Selection.dpr

Example 1

// Perform inpainting on the selected area of the image

// Encapsulate selection mask in IEVision image
mask := IEVisionLib.createImage( ImageEnView1.IEBitmap.Width, ImageEnView1.IEBitmap.Height, ievUINT8, 1 );
mask.copyFrom( ievUINT1, 1, ImageEnView1.SelectionMask.Rowlen, ImageEnView1.SelectionMask.ScanLine[ ImageEnView1.SelectionMask.Height-1 ]);
mask.flip( ievX_AXIS );

// Perform inpainting and update display
ImageEnView1.IEBitmap.GetIEVisionImage().inpaint( mask, 4, ievINPAINT_TELEA );

Example 2

// Perform inpainting on a specified rect of an image

rangeSize := 4;
roiSize := ( (selRect.Width + selRect.Height) div 2 + rangeSize * 2);     // Ensure region of interest (ROI) > selection size

// Get ROI
ipRect := IEVisionRect( selRect.Left + selRect.Width div 2 - roiSize div 2,
                        selRect.Top + selRect.Height div 2 - roiSize div 2,
                        roiSize, roiSize );
// Ensure ROI rect is inside image rect
ipRect := IEVisionLib.createMath().rectIntersect(ipRect, IEVisionRect(0, 0, ImageEnView1.IEBitmap.Width, ImageEnView1.IEBitmap.Height));

// perform inpaint if valid ROI
if (ipRect.width > 0) and (ipRect.height > 0) then
  ImageEnView1.IEBitmap.GetIEVisionImage().InPaint( selRect.Width, selRect.Height, ipRect, rangeSize, ievINPAINT_TELEA );