Skip to content

Commit 9f443b3

Browse files
committed
feat: optimize normalize
1 parent a0d1def commit 9f443b3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

cpp/FOCV_Function.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,10 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime &runtime, const jsi::Value *argum
740740
auto src = args.asMatPtr(1);
741741
auto dst = args.asMatPtr(2);
742742
auto alpha = args.asNumber(3);
743-
auto normType = args.asNumber(4);
743+
auto beta = args.asNumber(4);
744+
auto normType = args.asNumber(5);
744745

745-
cv::normalize(*src, *dst, alpha, normType);
746+
cv::normalize(*src, *dst, alpha, beta, normType, -1, cv::Mat());
746747
}
747748
break;
748749
case hashString("patchNaNs", 9):
@@ -1845,21 +1846,25 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime &runtime, const jsi::Value *argum
18451846
Mat src1 = *src;
18461847

18471848
// we compute the histogram from the 0-th and 1-st channels
1848-
int channels[] = {0};
1849+
// Use the 0-th and 1-st channels
1850+
int channels[] = {0, 1};
18491851

1850-
const int bins[1] = {256};
1851-
float hranges[2] = {0, 255};
1852-
const float *ranges[1] = {hranges};
1852+
int h_bins = 50, s_bins = 60;
1853+
int histSize[] = {h_bins, s_bins};
1854+
// hue varies from 0 to 179, saturation from 0 to 255
1855+
float h_ranges[] = {0, 180};
1856+
float s_ranges[] = {0, 256};
1857+
const float *ranges[] = {h_ranges, s_ranges};
18531858

18541859
// 计算灰度图像的直方图
18551860
cv::calcHist(&src1,
18561861
1,
18571862
channels,
18581863
cv::Mat(),
18591864
*dst,
1860-
1,
1861-
bins,
1862-
ranges);
1865+
2,
1866+
histSize,
1867+
ranges, true, false);
18631868
}
18641869
break;
18651870
case hashString("compareHist", 11):

src/functions/Core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ export type Core = {
707707
src: Mat,
708708
dst: Mat,
709709
alpha: number,
710+
beta: number,
710711
normType: NormTypes
711712
): void;
712713

0 commit comments

Comments
 (0)