From 44448b2f4c6a330b6a4df57b62b9908976e30b22 Mon Sep 17 00:00:00 2001 From: Aaron Hopkins Date: Tue, 31 Jul 2018 20:30:33 -0700 Subject: [PATCH] Fix sobel implementation. --- cmd/fotomat/version.go | 2 +- vips/convolution.h | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/fotomat/version.go b/cmd/fotomat/version.go index c6ae214..3875f87 100644 --- a/cmd/fotomat/version.go +++ b/cmd/fotomat/version.go @@ -2,5 +2,5 @@ package main const ( // FotomatVersion is updated by git-hooks/pre-commit - FotomatVersion = "2.8.241" + FotomatVersion = "2.8.242" ) diff --git a/vips/convolution.h b/vips/convolution.h index efa8b14..9b8c0ff 100644 --- a/vips/convolution.h +++ b/vips/convolution.h @@ -59,18 +59,26 @@ cgo_sobel(VipsImage *in, VipsImage **out) { VipsImage *sx = NULL; VipsImage *sy = NULL; + VipsImage *ax = NULL; + VipsImage *ay = NULL; VipsImage *add = NULL; int ret = -1; if (!vips_conv(band, &sx, x, NULL)) { - if (!vips_conv(band, &sy, y, NULL)) { - if (!vips_add(sx, sy, &add, NULL)) { - if (!vips_cast(add, out, VIPS_FORMAT_UCHAR, NULL)) { - ret = 0; + if (!vips_abs(sx, &ax, NULL)) { + if (!vips_conv(band, &sy, y, NULL)) { + if (!vips_abs(sy, &ay, NULL)) { + if (!vips_add(ax, ay, &add, NULL)) { + if (!vips_cast(add, out, VIPS_FORMAT_UCHAR, NULL)) { + ret = 0; + } + g_object_unref(add); + } + g_object_unref(ay); } - g_object_unref(add); + g_object_unref(sy); } - g_object_unref(sy); + g_object_unref(ax); } g_object_unref(sx); }