From d3e02f9b0ae2c0098b56b84fd0dfe2f739a26534 Mon Sep 17 00:00:00 2001 From: nuknal Date: Fri, 21 Feb 2025 15:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=BF=E6=9D=A1=E5=B8=A6=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=88=86=E6=AE=B5=E6=BB=A4=E6=B3=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/rrc/hf_filter.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pkg/rrc/hf_filter.go b/pkg/rrc/hf_filter.go index 5decf3a..9869852 100644 --- a/pkg/rrc/hf_filter.go +++ b/pkg/rrc/hf_filter.go @@ -1,6 +1,7 @@ package rrc import ( + "fmt" "image" "math" @@ -166,3 +167,32 @@ func visualizeDFT(DFT gocv.Mat, file string) { // 保存DFT结果 gocv.IMWrite(file, out) } + +func HFNoiseFilterSep(img gocv.Mat, radius float64) gocv.Mat { + const SepHeight = 4096 + IDFT := gocv.NewMat() + IDFTs := []gocv.Mat{} + for rows := 0; rows < img.Rows(); rows += SepHeight { + row0 := rows + row1 := rows + SepHeight + if row1 > img.Rows() { + row1 = img.Rows() + } + + fmt.Println("doing HF noise fileter rows range:", row0, row1) + + mat := img.Region(image.Rect(0, row0, img.Cols(), row1)) + matFiltered := HFNoiseFilter(mat, radius) + IDFTs = append(IDFTs, matFiltered) + } + + gocv.Vconcat(IDFTs[0], IDFTs[1], &IDFT) + IDFTs[0].Close() + IDFTs[0].Close() + for i := 2; i < len(IDFTs); i++ { + gocv.Vconcat(IDFT, IDFTs[i], &IDFT) + IDFTs[i].Close() + } + + return IDFT +}