mosaic

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 24 Imported by: 0

README

go-mosaic

Go Report Card

go-mosaic是一个制作相片马赛克的工具。相片馬賽克,或稱蒙太奇照片、蒙太奇拼貼,是一種影像處理的藝術技巧,利用這個方式做出來的圖片,近看時是由許多張小照片合在一起的,但遠看時,每張照片透過光影和色彩的微調,組成了一張大圖的基本像素,就叫做相片馬賽克技巧

README_EN

特性

  • 专为海量图片设计,可支持数百万张图片
  • 内建缓存数据库,图片删除、更改自动从缓存剔除
  • 多核构建,加载、计算、替换均为并发

使用

  • 克隆项目,编译,或者下载release
  • 执行命令,等待完成
./go-mosaic -src input.png -target output.jpg -lib ./test
  • 其中./test为图片文件夹,用来组成最终图片的元素。input.png为目标图片,用来生成最终的大图output.jpg。素材图片越多,生成越精确
  • 更多参数,参考help
Usage of D:\project\go-mosaic\test.exe:
  -checkhash
    	check database pic hash (default true)
  -database string
    	cache datbase (default "./database.bin")
  -lib string
    	image lib path
  -libname string
    	image lib name in database (default "default")
  -maxsize int
    	pic max size in GB (default 4)
  -pixelsize int
    	pic scale size per one pixel (default 64)
  -scalealg string
    	pic scale function NearestNeighbor/ApproxBiLinear/BiLinear/CatmullRom (default "CatmullRom")
  -src string
    	src image path
  -srcsize int
    	src image auto scale pixel size (default 128)
  -target string
    	target image path
  -worker int
    	worker thread num (default 12)

示例

image image

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Black   = color.RGBA{0, 0, 0, 0}
	White   = color.RGBA{255, 255, 255, 0}
	Red     = color.RGBA{255, 0, 0, 0}
	Lime    = color.RGBA{0, 255, 0, 0}
	Blue    = color.RGBA{0, 0, 255, 0}
	Yellow  = color.RGBA{255, 255, 0, 0}
	Cyan    = color.RGBA{0, 255, 255, 0}
	Magenta = color.RGBA{255, 0, 255, 0}
	Silver  = color.RGBA{192, 192, 192, 0}
	Gray    = color.RGBA{128, 128, 128, 0}
	Maroon  = color.RGBA{128, 0, 0, 0}
	Olive   = color.RGBA{128, 128, 0, 0}
	Green   = color.RGBA{0, 128, 0, 0}
	Purple  = color.RGBA{128, 0, 128, 0}
	Teal    = color.RGBA{0, 128, 128, 0}
	Navy    = color.RGBA{0, 0, 128, 0}
)

Functions

func ColorDistance

func ColorDistance(c1 color.RGBA, c2 color.RGBA) float64

func GetXXHashString

func GetXXHashString(s string) string

func Mosaic

func Mosaic(req *Request) error

Types

type CacheInfo

type CacheInfo struct {
	// contains filtered or unexported fields
}

type CalFileInfo

type CalFileInfo struct {
	// contains filtered or unexported fields
}

type ColorData

type ColorData struct {
	// contains filtered or unexported fields
}

type FileInfo

type FileInfo struct {
	Filename string
	R        uint8
	G        uint8
	B        uint8
	Hash     string
}

type Request

type Request struct {
	Src       string  // src image path
	Target    string  // target image path
	Lib       string  // image lib path
	Worker    *int    // worker thread num
	Database  *string // cache datbase
	PixelSize *int    // pic scale size per one pixel
	Scalealg  *string // pic scale function NearestNeighbor/ApproxBiLinear/BiLinear/CatmullRom
	CheckHash *bool   //
	MaxSize   *int    // pic max size in GB
	LibName   *string //  image lib name in database
	SrcSize   *int    // src image auto scale pixel size
}

type ThreadPool

type ThreadPool struct {
	// contains filtered or unexported fields
}

func NewThreadPool

func NewThreadPool(max int, buffer int, exef func(interface{})) *ThreadPool

func (*ThreadPool) AddJob

func (tp *ThreadPool) AddJob(hash int, v interface{})

func (*ThreadPool) AddJobTimeout

func (tp *ThreadPool) AddJobTimeout(hash int, v interface{}, timeoutms int) bool

func (*ThreadPool) GetStat

func (tp *ThreadPool) GetStat() ThreadPoolStat

func (*ThreadPool) ResetStat

func (tp *ThreadPool) ResetStat()

func (*ThreadPool) Stop

func (tp *ThreadPool) Stop()

type ThreadPoolStat

type ThreadPoolStat struct {
	Datalen    []int
	Pushnum    []int
	Processnum []int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL