constrast enhancement for browser image

This commit is contained in:
nuknal
2024-07-17 12:55:31 +08:00
parent cab03827f0
commit 17124e8396

View File

@@ -60,8 +60,12 @@ func GTiffToJPG(ftiff, fjpg string, reversed bool) error {
channels := gocv.Split(img) channels := gocv.Split(img)
for i, ch := range channels { for i, ch := range channels {
switch config.GCONFIG.BrowserImg.Enhancement { switch config.GCONFIG.BrowserImg.Enhancement {
case NoEnhancement: case StretchToCumulativeCutMinMax:
case StretchToMinimumMaximum: channels[i] = cumulativeCountCutEnhancement(ch,
config.GCONFIG.BrowserImg.CumulativeCutLower,
config.GCONFIG.BrowserImg.CumulativeCutUpper)
ch.Close()
default:
minVal, maxVal, _, _ := gocv.MinMaxLoc(ch) minVal, maxVal, _, _ := gocv.MinMaxLoc(ch)
ce := NewContrastEnhancement(int(minVal), int(maxVal)) ce := NewContrastEnhancement(int(minVal), int(maxVal))
for y := 0; y < height; y++ { for y := 0; y < height; y++ {
@@ -71,12 +75,8 @@ func GTiffToJPG(ftiff, fjpg string, reversed bool) error {
ch.SetShortAt(y, x, int16(value)) 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() img8bit := gocv.NewMat()