-
Notifications
You must be signed in to change notification settings - Fork 6
/
texture.go
61 lines (51 loc) · 2.41 KB
/
texture.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gocv
import (
"github.com/fwessels/go-cv-simd/sse2"
)
// TextureBoostedSaturatedGradient calculates boosted saturated gradients for given input image.
// All images must have the same width, height and format (8-bit gray).
// For border pixels:
// dx[x, y] = 0;
// dy[x, y] = 0;
// For other pixels:
// dx[x, y] = (saturation + max(-saturation, min(saturation, (src[x + 1, y] - src[x - 1, y]))))*boost;
// dy[x, y] = (saturation + max(-saturation, min(saturation, (src[x, y + 1] - src[x, y - 1]))))*boost;
func TextureBoostedSaturatedGradient(src gocvsimd.View, saturation, boost uint8, dx, dy gocvsimd.View) {
gocvsimd.SimdSse2TextureBoostedSaturatedGradient(src, uint64(saturation), uint64(boost), dx, dy)
}
// TextureBoostedUv calculates boosted colorized texture feature of input image (actual for U and V components of YUV format).
// All images must have the same width, height and format (8-bit gray).
// For every pixel:
// lo = 128 - (128/boost);
// hi = 255 - lo;
// dst[x, y] = max(lo, min(hi, src[i]))*boost;
func TextureBoostedUv(src gocvsimd.View, boost uint8, dst gocvsimd.View) {
gocvsimd.SimdSse2TextureBoostedUv(src, uint64(boost), dst)
}
// TextureGetDifferenceSum calculates difference between current image and background.
// All images must have the same width, height and format (8-bit gray).
// For every pixel:
// sum += current - average(lo[i], hi[i]);
func TextureGetDifferenceSum(src, lo, hi gocvsimd.View) int64 {
return gocvsimd.SimdSse2TextureGetDifferenceSum(src, lo, hi)
}
// TexturePerformCompensation performs brightness compensation of input image.
// All images must have the same width, height and format (8-bit gray).
// For every pixel:
// dst[i] = max(0, min(255, src[i] + shift));
func TexturePerformCompensation(src gocvsimd.View, shift int, dst gocvsimd.View) {
gocvsimd.SimdSse2TexturePerformCompensation(src, shift, dst)
}