Improved character image patch
This commit is contained in:
parent
838cf1711e
commit
f59865a82f
@ -30,6 +30,9 @@ func main() {
|
|||||||
fmt.Printf("[%d / %d] %s\n", index+1, len(characters), character)
|
fmt.Printf("[%d / %d] %s\n", index+1, len(characters), character)
|
||||||
process(character)
|
process(character)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char, _ := arn.GetCharacter("EI3HwrmiRm")
|
||||||
|
// process(char)
|
||||||
}
|
}
|
||||||
|
|
||||||
func process(character *arn.Character) {
|
func process(character *arn.Character) {
|
||||||
@ -51,8 +54,7 @@ func process(character *arn.Character) {
|
|||||||
|
|
||||||
newImg := removeBorders(img)
|
newImg := removeBorders(img)
|
||||||
|
|
||||||
fmt.Println(img.Bounds().Dx(), img.Bounds().Dy(), format)
|
fmt.Println(img.Bounds().Dx(), "->", newImg.Bounds().Dx(), "width", format)
|
||||||
fmt.Println(newImg.Bounds().Dx(), newImg.Bounds().Dy())
|
|
||||||
|
|
||||||
buffer := bytes.NewBuffer(nil)
|
buffer := bytes.NewBuffer(nil)
|
||||||
err = png.Encode(buffer, newImg)
|
err = png.Encode(buffer, newImg)
|
||||||
@ -82,7 +84,7 @@ func removeBorders(img image.Image) image.Image {
|
|||||||
|
|
||||||
borderLength := 0
|
borderLength := 0
|
||||||
|
|
||||||
for ; borderLength < maxBorderLength; borderLength++ {
|
for ; borderLength <= maxBorderLength; borderLength++ {
|
||||||
edgeColors := []icolor.Color{}
|
edgeColors := []icolor.Color{}
|
||||||
|
|
||||||
// Top edge
|
// Top edge
|
||||||
@ -126,7 +128,7 @@ func removeBorders(img image.Image) image.Image {
|
|||||||
averageG := uint32(totalG / uint64(len(edgeColors)))
|
averageG := uint32(totalG / uint64(len(edgeColors)))
|
||||||
averageB := uint32(totalB / uint64(len(edgeColors)))
|
averageB := uint32(totalB / uint64(len(edgeColors)))
|
||||||
|
|
||||||
const tolerance = 11000
|
const tolerance = 12000
|
||||||
|
|
||||||
// Check if the colors are close to the average color
|
// Check if the colors are close to the average color
|
||||||
notSimilarCount := 0
|
notSimilarCount := 0
|
||||||
|
Loading…
Reference in New Issue
Block a user