
(libload "opencv/opencv")
(libload "opencv/aux_dynobject")

(setq  storage  (new cvmemstorage))

(setq image0  (cvimage-read-rgb "lion.jpg"))

(let ((width   (==> image0  get_width))
      (height  (==> image0  get_height))
      (depth   (==> image0  get_depth)))
  (setq  image1 (new cvimage width height depth 3)) )

(setq connectedcomp (new cvseq :storage:p))

(let ((level 4)
      (threshold1 220)
      (threshold2 30))
  (cvPyrSegmentation   :image0:p  :image1:p  
		       :storage:p  :connectedcomp:pp  
		       level  threshold1 threshold2) )

(cvimage-show  image1)

;; the steps below are NOT really necessary, 
;; since the objects will be garbage collected automatically
;; (delete image1)
;; (delete image0)
;; (delete connectedcomp)
;; (delete storage)

