Files
sjy01-image-proc/pkg/producer/rrc.go
2024-06-14 10:26:54 +08:00

42 lines
997 B
Go

package producer
import (
"fmt"
"github.com/sirupsen/logrus"
"starwiz.cn/sjy01/image-proc/pkg/rrc"
)
func (r *Registrator) DoRRC() error {
logrus.Println("try to do RRC...")
tablePAN, err := rrc.LoadGrayTableMatrix("data/rrc/pan_gray_table.dat")
if err != nil {
logrus.Error("load pan gray table failed")
return err
}
for y := 0; y < r.PanImage.Rows(); y++ {
for x := 0; x < r.PanImage.Cols(); x++ {
newGray := tablePAN.At(x, int(uint16(r.PanImage.GetShortAt(y, x))))
r.PanImage.SetShortAt(y, x, int16(newGray))
}
}
for i := 0; i < 4; i++ {
tableMSS, err := rrc.LoadGrayTableMatrix(fmt.Sprintf("data/rrc/mss%d_gray_table.dat", i+1))
if err != nil {
logrus.Error("load mss gray table failed")
return err
}
for y := 0; y < r.MssImages[i].Rows(); y++ {
for x := 0; x < r.MssImages[i].Cols(); x++ {
newGray := tableMSS.At(x, int(uint16(r.MssImages[i].GetShortAt(y, x))))
r.MssImages[i].SetShortAt(y, x, int16(newGray))
}
}
}
return nil
}