ImageEn, unit iexHelperFunctions |
|
TIEBitmapHelper.Inpaint
Declaration
// ImageEnView1.SelectionMask overload
function Inpaint(SelectionMask: TIEMask; Range: Double = 3; Method: TIEVisionInpaintMethod = ievINPAINT_NS): Boolean; overload;
// Rect overload
function Inpaint(aRect: TRect; Range: Double = 3; Method: TIEVisionInpaintMethod = ievINPAINT_NS): Boolean; overload;
// Brush overload
function Inpaint(CenterPt: TPoint; BrushSizeX, BrushSizeY: Integer; Range: Double = 3; Method: TIEVisionInpaintMethod = ievINPAINT_NS): Boolean; overload;
Description
A shortcut method that calls
inpaint with either a selection mask or rectangle to inpaint content.
Parameter | Description |
SelectionMask | The current selection mask, typically this will be ImageEnView1.SelectionMask |
aRect | Specify a rect that will be inpainted (in bitmap values) |
CenterPt, BrushSizeX, BrushSizeY | For brush inpainting, specify the center of the inpainting (e.g. click position) and the brush size (in bitmap values) |
Range | Radius of a circular neighborhood of each point inpainted that is considered by the algorithm (3 is a reasonable starting value) |
Method | The inpainting algorithm, either Navier-Stokes method (ievINPAINT_NS) or the Telea algorithm (ievINPAINT_TELEA) |
Result will be false if there is no selection or an error occurs.
Note:
◼You must add the iexHelperFunctions unit to your uses clause
◼Inpainting requires
IEVision. You will need to
register it before calling the method
◼If attached to a
TImageEnView, it will automatically call
Update
SelectionMask Overload
The following call:
ImageEnView1.IEBitmap.Inpaint( ImageEnView1.SelectionMask, 4, ievINPAINT_TELEA );
Is the same as calling:
// Encapsulate ImageEn 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 inpaint
ImageEnView1.IEBitmap.GetIEVisionImage().inpaint( mask, 4, ievINPAINT_TELEA );
ImageEnView1.Update();
Brush Overload
The following call:
procedure TMainForm.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
bmpX, bmpY: integer;
begin
// Convert screen coordinates to bitmap coordinates
bmpX := ImageEnView1.XScr2Bmp( X );
bmpY := ImageEnView1.YScr2Bmp( Y );
ImageEnView1.IEBitmap.Inpaint( Point(bmpX, bmpY), 30, 30, 3, ievINPAINT_TELEA );
end;
Is the same as calling:
procedure TMainForm.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
brushSize: integer;
rangeSize: integer;
maxSizeX, maxSizeY: integer;
bmpX, bmpY: integer;
rct: TIEVisionRect;
begin
// Convert screen coordinates to bitmap coordinates
bmpX := ImageEnView1.XScr2Bmp( X );
bmpY := ImageEnView1.YScr2Bmp( Y );
brushSize := 30;
rangeSize := 3;
maxSize := (brushSize + rangeSize*2); // make sure region of interest (ROI) > brush size
// Get ROI
rct := IEVisionRect(bmpX - maxSize div 2, bmpY - maxSize div 2, maxSize, maxSize);
// Ensure ROI is inside image rect
rct := IEVisionLib.createMath().rectIntersect(rct, IEVisionRect(0, 0, ImageEnView1.IEBitmap.Width, ImageEnView1.IEBitmap.Height ));
// Perform inpaint
ImageEnView1.IEBitmap.GetIEVisionImage().inpaint( brushSize, brushSize, rct, rangeSize, ievINPAINT_TELEA );
ImageEnView1.Update();
end;
// Perform inpainting on the current selection
ImageEnView1.IEBitmap.Inpaint( ImageEnView1.SelectionMask, StrToInt(ComboBox2.Text), ievINPAINT_TELEA );
ImageEnView1.Update();
// Perform inpainting when the user clicks the image
procedure TMainForm.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
bmpX, bmpY: integer;
begin
// Convert screen coordinates to bitmap coordinates
bmpX := ImageEnView1.XScr2Bmp( X );
bmpY := ImageEnView1.YScr2Bmp( Y );
ImageEnView1.IEBitmap.Inpaint( Point(bmpX, bmpY), 30, 30, 3, ievINPAINT_TELEA );
end;
// Perform inpainting on a rect
r := Rect( 100, 150, 140, 190 );
ImageEnView1.IEBitmap.Inpaint( r, 3 );