;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; 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")



#? *** floodfill

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

;; #? * (dummy_floodfill)
;; #? * (cvfloodfill <array> <seedpoint> <newval> <lodiff> <updiff> <comp> <connectivity>)

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

;;  /****************************************************************************************\
;;  *                                     Flood fill                                         *
;;  \****************************************************************************************/

#? (cvFloodFill  <array> <seedpoint> <newval> <lodiff> <updiff> <comp> <connectivity>)
;;.VP
;;  /*F///////////////////////////////////////////////////////////////////////////////////////
;;  //    Name: cvFloodFill, cvFloodFill
;;  //    Purpose: The function fills the connected domain, starting from seed pixel
;;  //             while the pixel values in this domain are not far from each other.
;;  //    Context:
;;  //    Parameters:
;;  //      img        - initial image(in the beginning)
;;  //                   which is "repainted" during the function action,
;;  //      seedPoint  - coordinates of the seed point inside image ROI,
;;  //      newVal     - new value of repainted area pixels,
;;  //      loDiff, upDiff - maximal lower and upper differences of the values of
;;  //                   appurtenant to repainted area pixel and one of its
;;  //                   neighbour,
;;  //      comp       - pointer to connected component structure of the
;;  //                   repainted area
;;  //      flags      - The operation flags. Lower bits contain connectivity value, 
;;  //                   4 (by default) or 8, used within the function. Connectivity 
;;  //                   determines which neighbors of a pixel are considered. Upper
;;  //                   bits can be 0 or combination of the following flags:
;;  //                   * CV_FLOODFILL_FIXED_RANGE - if set the difference between
;;  //                     the current pixel and seed pixel is considered, otherwise
;;  //                     difference between neighbor pixels is considered (the range
;;  //                     is floating).
;;  //                   * CV_FLOODFILL_MASK_ONLY - if set, the function does not fill
;;  //                     the image (new_val is ignored), but the fills mask (that 
;;  //                     must be non-NULL in this case). 
;;  //      mask       - Operation mask, should be singe-channel 8-bit image, 2 pixels
;;  //                   wider and 2 pixels taller than image
;;  //    Notes:
;;  //F*/
;;  OPENCVAPI  void  cvFloodFill( CvArr* image, CvPoint seedPoint,
;;                                double newVal, double loDiff, double upDiff,
;;                                CvConnectedComp* comp, int connectivity CV_DEFAULT(4) );

(de cvFloodFill (image seedpoint newval lodiff updiff comp flags mask)
    ((-gptr- "CvArr *") image mask)
    ((-gptr- "CvPoint *") seedpoint)
    ((-gptr- "CvScalar *") newval lodiff updiff)
    ((-gptr- "CvConnectedComp *") comp)
    ((-int-) flags)
    #{ cvFloodFill($image, *$seedpoint, *$newval, *$lodiff, *$updiff, $comp, $flags, $mask); #}
    ())
;; ********************************************************

(dhc-make ()
  dummy_floodfill
  cvfloodfill
)
