From 17124e8396bac691897bb571a633ade6462e946a Mon Sep 17 00:00:00 2001 From: nuknal Date: Wed, 17 Jul 2024 12:55:31 +0800 Subject: [PATCH] constrast enhancement for browser image --- pkg/producer/jpg.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/producer/jpg.go b/pkg/producer/jpg.go index b729214..ebcf460 100644 --- a/pkg/producer/jpg.go +++ b/pkg/producer/jpg.go @@ -60,8 +60,12 @@ func GTiffToJPG(ftiff, fjpg string, reversed bool) error { channels := gocv.Split(img) for i, ch := range channels { switch config.GCONFIG.BrowserImg.Enhancement { - case NoEnhancement: - case StretchToMinimumMaximum: + case StretchToCumulativeCutMinMax: + channels[i] = cumulativeCountCutEnhancement(ch, + config.GCONFIG.BrowserImg.CumulativeCutLower, + config.GCONFIG.BrowserImg.CumulativeCutUpper) + ch.Close() + default: minVal, maxVal, _, _ := gocv.MinMaxLoc(ch) ce := NewContrastEnhancement(int(minVal), int(maxVal)) for y := 0; y < height; y++ { @@ -71,12 +75,8 @@ func GTiffToJPG(ftiff, fjpg string, reversed bool) error { ch.SetShortAt(y, x, int16(value)) } } - case StretchToCumulativeCutMinMax: - channels[i] = cumulativeCountCutEnhancement(ch, - config.GCONFIG.BrowserImg.CumulativeCutLower, - config.GCONFIG.BrowserImg.CumulativeCutUpper) - ch.Close() } + } img8bit := gocv.NewMat()