Files
sjy01-image-proc/pkg/producer/rrc.go
2024-06-15 03:04:50 +08:00

42 lines
946 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...")
lutPAN, err := rrc.LoadLUT("data/rrc/B0.LUT", 9344)
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 := lutPAN[x][int(uint16(r.PanImage.GetShortAt(y, x)))]
r.PanImage.SetShortAt(y, x, int16(newGray))
}
}
for i := 0; i < 4; i++ {
lutMSS, err := rrc.LoadLUT(fmt.Sprintf("data/rrc/B%d.LUT", i+1), 2336)
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 := lutMSS[x][int(uint16(r.MssImages[i].GetShortAt(y, x)))]
r.MssImages[i].SetShortAt(y, x, int16(newGray))
}
}
}
return nil
}