Do RRC with histogram LUT, ineffective!

This commit is contained in:
nuknal
2024-06-17 10:59:48 +08:00
parent 35bf364e97
commit ce01f3b2ce
3 changed files with 12 additions and 7 deletions

View File

@@ -15,6 +15,8 @@ import (
var ( var (
params producer.Params params producer.Params
saveStrip bool saveStrip bool
doRRC bool
lutDir string
) )
var procCmd = &cobra.Command{ var procCmd = &cobra.Command{
@@ -44,7 +46,9 @@ var procCmd = &cobra.Command{
godal.RegisterAll() godal.RegisterAll()
os.MkdirAll(params.OutputDir, 0755) os.MkdirAll(params.OutputDir, 0755)
reg.DoRRC() if doRRC {
reg.DoRRC(lutDir)
}
if err := reg.DoPhaseCorrelation(); err != nil { if err := reg.DoPhaseCorrelation(); err != nil {
logrus.Fatal(err) logrus.Fatal(err)
@@ -93,6 +97,8 @@ func init() {
procCmd.Flags().BoolVarP(&params.SubScenes, "sub-scenes", "", false, "process sub-scenes") procCmd.Flags().BoolVarP(&params.SubScenes, "sub-scenes", "", false, "process sub-scenes")
procCmd.Flags().BoolVarP(&saveStrip, "save-strip", "", false, "save original and registered images as GDAL GTiff") procCmd.Flags().BoolVarP(&saveStrip, "save-strip", "", false, "save original and registered images as GDAL GTiff")
procCmd.Flags().StringVarP(&paramsXML, "params", "x", "", "params xml file path") procCmd.Flags().StringVarP(&paramsXML, "params", "x", "", "params xml file path")
procCmd.Flags().StringVarP(&lutDir, "lut", "l", "data/lut", "LUT directory")
procCmd.Flags().BoolVarP(&doRRC, "rrc", "", false, "do RRC")
} }
func initParams() producer.Params { func initParams() producer.Params {

View File

@@ -2,14 +2,15 @@ package producer
import ( import (
"fmt" "fmt"
"path/filepath"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"starwiz.cn/sjy01/image-proc/pkg/rrc" "starwiz.cn/sjy01/image-proc/pkg/rrc"
) )
func (r *Registrator) DoRRC() error { func (r *Registrator) DoRRC(lutDir string) error {
logrus.Println("try to do RRC...") logrus.Printf("try to do RRC [%s]...", lutDir)
lutPAN, err := rrc.LoadLUT("data/rrc/B0.LUT", 9344) lutPAN, err := rrc.LoadLUT(filepath.Join(lutDir, "B0.LUT"), 9344)
if err != nil { if err != nil {
logrus.Error("load pan gray table failed") logrus.Error("load pan gray table failed")
return err return err
@@ -23,7 +24,7 @@ func (r *Registrator) DoRRC() error {
} }
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
lutMSS, err := rrc.LoadLUT(fmt.Sprintf("data/rrc/B%d.LUT", i+1), 2336) lutMSS, err := rrc.LoadLUT(filepath.Join(lutDir, fmt.Sprintf("B%d.LUT", i+1)), 2336)
if err != nil { if err != nil {
logrus.Error("load mss gray table failed") logrus.Error("load mss gray table failed")
return err return err

View File

@@ -97,7 +97,6 @@ func (rrc *RRC) StatisticalPAN(dsfile string) error {
log.Println("sum PAN histogram...") log.Println("sum PAN histogram...")
rrc.Histograms[0].sum([]*ProbeHistogram{&hist}) rrc.Histograms[0].sum([]*ProbeHistogram{&hist})
hist.free() hist.free()
printMemStats()
runtime.GC() runtime.GC()
printMemStats() printMemStats()
@@ -177,7 +176,6 @@ func (rrc *RRC) StatisticalMSS(dsfile string) error {
log.Println("sum MSS histogram...") log.Println("sum MSS histogram...")
rrc.Histograms[i+1].sum([]*ProbeHistogram{&hist}) rrc.Histograms[i+1].sum([]*ProbeHistogram{&hist})
hist.free() hist.free()
printMemStats()
runtime.GC() runtime.GC()
printMemStats() printMemStats()