histogram RRC

This commit is contained in:
nuknal
2024-06-14 10:26:54 +08:00
parent 268076017e
commit 4a2fc805c9
5 changed files with 328 additions and 95 deletions

41
pkg/producer/rrc.go Normal file
View File

@@ -0,0 +1,41 @@
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
}