Skip to content

Commit e6a0eb0

Browse files
committed
fix: fix blendings and change handling gray value
1 parent 2eb62a5 commit e6a0eb0

File tree

14 files changed

+140
-109
lines changed

14 files changed

+140
-109
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: aznyan
33
Title: Image Filters with 'OpenCV'
4-
Version: 26.02.12
4+
Version: 26.02.13
55
Authors@R: c(
66
person("Akiru", "Kato", , "paithiov909@gmail.com", role = c("aut", "cre")),
77
person("Jeroen", "Ooms", role = "cph")

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export(as_recordedplot)
55
export(aznyan_num_threads)
66
export(bilateral_filter)
77
export(blend_add)
8+
export(blend_alpha)
89
export(blend_average)
910
export(blend_colorburn)
1011
export(blend_colordodge)
@@ -19,7 +20,6 @@ export(blend_lighten)
1920
export(blend_linearlight)
2021
export(blend_luminosity)
2122
export(blend_multiply)
22-
export(blend_over)
2323
export(blend_overlay)
2424
export(blend_pinlight)
2525
export(blend_screen)

R/blend.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ NULL
1010

1111
#' @rdname blend
1212
#' @export
13-
blend_over <- function(src, dst) {
13+
blend_alpha <- function(src, dst) {
1414
check_nr_dim(src, dst)
15-
as_nr(azny_blend_over(src, dst, nrow(src), ncol(src)))
15+
as_nr(azny_blend_alpha(src, dst, nrow(src), ncol(src)))
1616
}
1717

1818
#' @rdname blend

R/cpp11.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by cpp11: do not edit by hand
22

3-
azny_blend_over <- function(src, dst, height, width) {
4-
.Call(`_aznyan_azny_blend_over`, src, dst, height, width)
3+
azny_blend_alpha <- function(src, dst, height, width) {
4+
.Call(`_aznyan_azny_blend_alpha`, src, dst, height, width)
55
}
66

77
azny_blend_darken <- function(src, dst, height, width) {

man/blend.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/aznyan_types.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <opencv2/opencv.hpp>
33
#include <cpp11.hpp>
44

5+
namespace {
6+
57
inline float srgb_to_linear(float x) {
68
if (x <= 0.04045f) return x / 12.92f;
79
return std::pow((x + 0.055f) / 1.055f, 2.4f);
@@ -12,6 +14,15 @@ inline float linear_to_srgb(float x) {
1214
return 1.055f * std::pow(x, 1.0f / 2.4f) - 0.055f;
1315
}
1416

17+
inline float gray_value(const cv::Vec3b& v) {
18+
const float r = static_cast<float>(v[2]) * 0.299f;
19+
const float g = static_cast<float>(v[1]) * 0.587f;
20+
const float b = static_cast<float>(v[0]) * 0.114f;
21+
return (r + g + b) / 255.0f;
22+
}
23+
24+
}; // namespace
25+
1526
namespace aznyan {
1627

1728
/**

0 commit comments

Comments
 (0)