Documentation
¶
Index ¶
- func AutoMask(img image.Image) *image.Gray
- func MaskFromAlpha(img image.Image) *image.Gray
- func MaskFromBackground(img image.Image, bg color.Color, tolerance float64) *image.Gray
- func MaskFromEdges(img image.Image, threshold float64) *image.Gray
- type Config
- type CropConfig
- type Mask
- type RemBG
- func (r *RemBG) Close() error
- func (r *RemBG) RemoveBackground(img image.Image) (image.Image, error)
- func (r *RemBG) RunInference(input []ort.Value, output []ort.Value) error
- func (r *RemBG) SmartCrop(img image.Image, config *CropConfig) (image.Image, error)
- func (engine *RemBG) SmartCropFromMask(img image.Image, maskFunc Mask, config *CropConfig) (image.Image, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaskFromBackground ¶ added in v1.2.0
Types ¶
type Config ¶
type Config struct {
// ModelPath is the path to the ONNX model file.
ModelPath string
// IntraOpNumThreads is the number of threads to use for intra-op parallelism.
IntraOpNumThreads int
// InterOpNumThreads is the number of threads to use for inter-op parallelism.
InterOpNumThreads int
// CpuMemArena is a flag indicating whether to use a CPU memory arena.
CpuMemArena bool
// MemPattern is a flag indicating whether to use a memory pattern.
MemPattern bool
}
Config for RemBG
type CropConfig ¶ added in v1.1.0
type CropConfig struct {
// Margin is the margin in pixels around the detected object (default: 20)
Margin int
// MarginPercent is the margin as a percentage of the object dimensions (overrides Margin if > 0)
MarginPercent float64
// MinThreshold is the minimum value of the mask to consider as part of the object (0-255, default: 10)
MinThreshold uint8
// SquareCrop forces the crop to be square, using the largest dimension
SquareCrop bool
}
CropConfig configures the behavior of the smart crop
type RemBG ¶
type RemBG struct {
// contains filtered or unexported fields
}
RemBG with session reuse and memory pooling
func (*RemBG) RemoveBackground ¶
RemoveBackground processes image with memory pooling
func (*RemBG) RunInference ¶
func (*RemBG) SmartCrop ¶ added in v1.1.0
SmartCrop removes the background and performs a smart crop focusing on the object
func (*RemBG) SmartCropFromMask ¶ added in v1.2.0
func (engine *RemBG) SmartCropFromMask(img image.Image, maskFunc Mask, config *CropConfig) (image.Image, error)
SmartCropFromMask performs a smart crop using an existing mask
Click to show internal directories.
Click to hide internal directories.