Created
August 1, 2022 05:32
-
-
Save NickSablukov/0263a8ab33c9a8c4a444b6a10fe2f87d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (b *MosaicBuilder) getPartsMap(parts []string) (map[PixelColor]image.Image, error) { | |
partsMap := make(map[PixelColor]image.Image, len(parts)) | |
for _, path := range parts { | |
src, err := b.loadImage(path) | |
if err == nil { | |
partsMap[calculateModalAverageColour(src)] = src | |
} | |
} | |
if len(partsMap) == 0 { | |
return nil, fmt.Errorf("empty map") | |
} | |
return partsMap, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment