ImageEn, unit IEVision

TIEVisionImage.seamlessClone

TIEVisionImage.seamlessClone

Declaration

function seamlessClone(src: TIEVisionImage; mask: TIEVisionImage; center: TIEVisionPoint; flags: TIEVisionSeamlessCloneFlags = ievNORMAL_CLONE): TIEVisionImage; safecall;

Description

Poisson seamless cloning. Pastes src into the current image (the destination/background) at center, blending illumination so the insert matches the surrounding pixels.
Returns a new blended image. Source and destination must be 8-bit 3-channel (ie24RGB). The mask must be 8-bit single-channel and the same size as src. Non-zero mask pixels are the region to insert (the outer 1-pixel border of the mask is ignored). center is the location in the destination where the center of the masked region is placed; that region must fit entirely inside the destination, otherwise an exception is raised.
Parameter Description
src Source image to insert (8-bit 3-channel)
mask 8-bit 1-channel mask the same size as src. Non-zero pixels are cloned
center Center of the source in destination coordinates
flags Clone mode: ievNORMAL_CLONE, ievMIXED_CLONE or ievMONOCHROME_TRANSFER

Note: This method will discard the AlphaChannel

Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr

Examples

Also see: Automated Samples
// Paste sourceIEV into the current image at (200, 150)
blended := ImageEnView1.IEBitmap.GetIEVisionImage().seamlessClone( sourceIEV, maskIEV, IEVisionPoint( 200, 150 ));
ImageEnView1.IEBitmap.AssignIEVisionImage( blended );
ImageEnView1.Update();


// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

  

// Seamlessly clone a transparent PNG onto the image at 400,300, using its alpha channel as the mask
bmp := TIEBitmap.Create( 'D:\Plane.png' );
bmp.Resize( 10, 10, 10, 10, 0, 0 );  // Add a transparent border
maskBmp := TIEBitmap.Create( bmp.AlphaChannel );
maskBmp.GetIEVisionImage().threshold( 127, 255, ievTHRESH_BINARY );
srcBmp := TIEBitmap.Create( bmp );
srcBmp.RemoveAlphaChannel( False );
ImageEnView1.IEBitmap.PixelFormat := ie24RGB;
ImageEnView1.IEBitmap.AssignIEVisionImage( ImageEnView1.IEBitmap.GetIEVisionImage().seamlessClone( srcBmp.GetIEVisionImage(), maskBmp.GetIEVisionImage(), IEVisionPoint( 400, 300 ), ievNORMAL_CLONE ));
ImageEnView1.Update();
bmp.Free();
maskBmp.Free();
srcBmp.Free();

  

See Also

◼TIEVisionSeamlessCloneFlags
◼inpaint