1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
23 #include "core/GP_Debug.h"
24 #include "core/GP_GetPutPixel.h"
26 #include "GP_Linear.h"
28 #include "GP_Laplace.h"
30 int GP_FilterLaplace(const GP_Context
*src
, GP_Context
*dst
,
31 GP_ProgressCallback
*callback
)
33 GP_DEBUG(1, "Laplace filter %ux%u", src
->w
, src
->h
);
35 float kern
[9] = {0, 1, 0,
39 if (GP_FilterLinearConvolution_Raw(src
, dst
, kern
, 3, 3, 1, callback
))
45 GP_Context
*GP_FilterLaplaceAlloc(const GP_Context
*src
,
46 GP_ProgressCallback
*callback
)
48 GP_Context
*ret
= GP_ContextCopy(src
, 0);
53 if (GP_FilterLaplace(src
, ret
, callback
)) {
62 int GP_FilterEdgeSharpening(const GP_Context
*src
, GP_Context
*dst
,
63 float w
, GP_ProgressCallback
*callback
)
66 float kern
[9] = {0, 0, 0,
70 GP_DEBUG(1, "Laplace Edge Sharpening filter %ux%u w=%f",
73 /* Create combined kernel */
80 GP_FilterKernelPrint(kern
, 3, 3, 1);
82 if (GP_FilterLinearConvolution_Raw(src
, dst
, kern
, 3, 3, 1, callback
))
88 GP_Context
*GP_FilterEdgeSharpeningAlloc(const GP_Context
*src
, float w
,
89 GP_ProgressCallback
*callback
)
91 GP_Context
*ret
= GP_ContextCopy(src
, 0);
96 if (GP_FilterEdgeSharpening(src
, ret
, w
, callback
)) {