func doSampling() { img, imgType, err := goImageBrightness.ImageFromFile("sampleImageAllWhite.png") if err != nil { log.Fatalf("Failed to decode [%s] image.", imgType) } brightnessPercentage := goImageBrightness.AnalyseImage(img) log.Printf("Total relative luminance is %d%%.", brightnessPercentage) img, imgType, err = goImageBrightness.ImageFromFile("sampleImageMostlyBrightGreen.png") if err != nil { log.Fatalf("Failed to decode [%s] image.", imgType) } brightnessPercentage = goImageBrightness.AnalyseImage(img) log.Printf("Total relative luminance is %d%%.", brightnessPercentage) img, imgType, err = goImageBrightness.ImageFromFile("sampleImageSlightlyBrightGreen.png") if err != nil { log.Fatalf("Failed to decode [%s] image.", imgType) } brightnessPercentage = goImageBrightness.AnalyseImage(img) log.Printf("Total relative luminance is %d%%.", brightnessPercentage) img, imgType, err = goImageBrightness.ImageFromFile("sampleImageAllBlack.png") if err != nil { log.Fatalf("Failed to decode [%s] image.", imgType) } brightnessPercentage = goImageBrightness.AnalyseImage(img) log.Printf("Total relative luminance is %d%%.", brightnessPercentage) }
func doLargeThreaded(pngPath *string) { start := time.Now() img, imgType, err := goImageBrightness.ImageFromFile(*pngPath) if err != nil { log.Fatalf("Failed to decode [%s] image.", imgType) } brightnessPercentage := goImageBrightness.ParallelAnalyseImage(img, 4) log.Printf("Threaded total relative luminance is %d%%. (%d ms)", brightnessPercentage, time.Since(start)/1000000) }