Last active
August 29, 2015 14:20
-
-
Save esdrasbeleza/5d4e96a8333444286cb6 to your computer and use it in GitHub Desktop.
First version of Lightest operation
This file contains hidden or 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 (c LightestOperation) Result(images []image.Image) (image.Image, error) { | |
firstImage := images[0] | |
bounds := firstImage.Bounds() | |
lightest := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy())) | |
draw.Draw(lightest, bounds, firstImage, bounds.Min, draw.Src) | |
for _, currentImage := range images { | |
if currentImage.Bounds() != bounds { | |
return nil, errors.New("The images have different size!") | |
} | |
imageToCompare := image.NewRGBA(image.Rect(0, 0, bounds.Dx(), bounds.Dy())) | |
draw.Draw(imageToCompare, bounds, currentImage, bounds.Min, draw.Src) | |
c.getLightestImageBetweenTwo(lightest, imageToCompare) | |
} | |
return lightest, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment