Skip to content

Instantly share code, notes, and snippets.

@esdrasbeleza
Last active August 29, 2015 14:20
Show Gist options
  • Save esdrasbeleza/5d4e96a8333444286cb6 to your computer and use it in GitHub Desktop.
Save esdrasbeleza/5d4e96a8333444286cb6 to your computer and use it in GitHub Desktop.
First version of Lightest operation
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