Do RRC by moment matching method

This commit is contained in:
nuknal
2024-06-17 17:28:15 +08:00
parent ce01f3b2ce
commit d1733d0828
5 changed files with 87 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"os"
"path/filepath"
"runtime"
"sync"
@@ -21,17 +22,18 @@ const (
)
type RRC struct {
LUTOutDir string
Histograms [5]ProbeHistogram
}
func NewRRC() *RRC {
r := RRC{}
func NewRRC(dir string) *RRC {
r := RRC{LUTOutDir: dir}
r.Histograms[0].init(PANCameraProbeNum)
for i := 1; i < 5; i++ {
r.Histograms[i].init(MSSCameraProbeNum)
}
os.MkdirAll("data/rrc", 0755)
os.MkdirAll(r.LUTOutDir, 0755)
return &r
}
@@ -110,7 +112,7 @@ func (rrc *RRC) StatisticalPAN(dsfile string) error {
log.Println("compute PAN histogram...")
rrc.Histograms[0].compute()
log.Println("save PAN gray table matrix.")
rrc.Histograms[0].saveLUT("data/rrc/B0.LUT")
rrc.Histograms[0].saveLUT(filepath.Join(rrc.LUTOutDir, "B0.LUT"))
return nil
}
@@ -189,7 +191,7 @@ func (rrc *RRC) StatisticalMSS(dsfile string) error {
log.Println("compute MSS histogram...")
rrc.Histograms[i].compute()
log.Println("save MSS gray table matrix.")
rrc.Histograms[i].saveLUT(fmt.Sprintf("data/rrc/B%d.LUT", i))
rrc.Histograms[i].saveLUT(filepath.Join(rrc.LUTOutDir, fmt.Sprintf("B%d.LUT", i)))
}
return nil