 
 {#pointer *IplImage as BareImage foreign newtype#}
 
-foreign import ccall "& wrapReleaseImage" releaseImage :: FinalizerPtr BareImage
+freeBareImage ptr = with ptr {#call cvReleaseImage#}
+
+--foreign import ccall "& wrapReleaseImage" releaseImage :: FinalizerPtr BareImage
 
 instance NFData (Image a b) where
     rnf a@(S (BareImage fptr)) = (unsafeForeignPtrToPtr) fptr `seq` a `seq` ()-- This might also need peek?


import Foreign.C.Types
import Foreign.C.String
import Foreign.ForeignPtr
import Foreign.Ptr
import Control.Parallel.Strategies
import Control.DeepSeq

creatingImage fun = do
              iptr <- fun
--              {#call incrImageC#} -- Uncomment this line to get statistics of number of images allocated by ghc
              fptr <- newForeignPtr iptr (freeBareImage iptr) 
              return . S . BareImage $ fptr

creatingBareImage fun = do
              iptr <- fun
--              {#call incrImageC#} -- Uncomment this line to get statistics of number of images allocated by ghc
              fptr <- newForeignPtr iptr (freeBareImage iptr)
              return . BareImage $ fptr

unImage (S (BareImage fptr)) = fptr
