;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "opencv/cv-config")



#? *** derivative

;; dummy function that adds OpenCV C header files in C file
(eval `(de dummy_derivative () ,cv-cpheader-cmd ()))

;; #? * (dummy_derivative)
;; #? * (cvsobel <src> <dst> <xorder> <yorder> <a>)
;; #? * (cvlaplace <src> <dst> <a>)

;; ********************************************************

;;  /****************************************************************************************\
;;  *                              Derivative calculation                                    *
;;  \****************************************************************************************/

#? (cvSobel <src> <dst> <xorder> <yorder> <a>)
;;.VP
;;  /*F///////////////////////////////////////////////////////////////////////////////////////
;;  //    Name:    cvSobel
;;  //    Purpose: calculates an image derivative d^(xorder+yorder)I/((dx)^xorder)*(dy^yoder))
;;  //             by convolving the image with extended Sobel operators.
;;  //             No scaling is performed.
;;  //
;;  //             |-1 -2 -1|     |-1 0 1|
;;  //             | 0  0  0| and |-2 0 2| are partial cases of it.
;;  //             | 1  2  1|     |-1 0 1|
;;  //
;;  //             First one corresponds to xorder = 0, yorder = 1, apertureSize = 3,
;;  //             And the second corresponds to xorder = 1, yorder = 0, apertureSize = 3.
;;  //    Context:
;;  //    Parameters:
;;  //      src    - source image
;;  //      dst    - destination derivative image
;;  //      xorder - order of x derivative
;;  //      yorder - order of y derivative
;;  //      apertureSize - size of colvolution operator. Must be odd: 3, 5, ... or
;;  //                                        | -3  0  3 |    | -3 -10 -3 |
;;  //                     CV_SCHARR (-1) for | -10 0 10 | or |  0   0  0 | kernels.
;;  //                                        | -3  0  3 |    |  3  10  3 |
;;  //    Returns:
;;  //    Notes:
;;  //      The function uses replicatation border mode.
;;  //      In case of yorder is odd, the image origin is taken into account.
;;  //      (for matrices the top-left origin is assumed)
;;  //F*/
;;  #define CV_SCHARR -1
;;  OPENCVAPI void cvSobel( const CvArr* src, CvArr* dst,
;;                          int xorder, int yorder,
;;                          int apertureSize CV_DEFAULT(3));
(de cvSobel(src dst xorder yorder a)
    ((-gptr- "const CvArr *") src)
    ((-gptr- "CvArr *") dst)
    ((-int-) xorder)
    ((-int-) yorder)
    ((-int-) a)
    #{  cvSobel($src, $dst, $xorder, $yorder, $a);  #}
    ())

#? (cvLaplace  <src> <dst> <a>)
;;.VP
;;  /*F///////////////////////////////////////////////////////////////////////////////////////
;;  //    Name:     cvLaplace
;;  //    Purpose:  Calculates Laplacian of the image: deltaI = d^2(I)/dx^2 + d^2(I)/dy^2.
;;  //              Sobel operator is used for calculating derivatives.
;;  //    Context:
;;  //    Parameters:
;;  //      src - source image
;;  //      dst - destination image
;;  //      apertureSize - size of applied aperture
;;  //    Returns:
;;  //    Notes:
;;  //F*/
;;  OPENCVAPI void cvLaplace( const CvArr* src, CvArr* dst,
;;                            int apertureSize CV_DEFAULT(3) );

(de cvLaplace (src dst a)
    ((-gptr- "const CvArr *") src)
    ((-gptr- "CvArr *") dst)
    ((-int-) a)
    #{ cvLaplace($src, $dst, $a);  #}
    ())
;; ********************************************************

(dhc-make ()
  dummy_derivative
  cvsobel
  cvlaplace
)
