   :: Image channels depth
      -> (Image channels depth -> IO a)
      -> IO a
-withCloneValue img fun = do 
+withCloneValue img fun = do
                 result <- cloneImage img
                 r <- fun result
                 return r
 
 unsafeImageTo32F :: Image c d -> Image c D32
-unsafeImageTo32F img = unsafePerformIO $ withGenImage img $ \image -> 
-                creatingImage 
+unsafeImageTo32F img = unsafePerformIO $ withGenImage img $ \image ->
+                creatingImage
                  ({#call ensure32F #} image)
 
 unsafeImageTo8Bit :: Image cspace a -> Image cspace D8
-unsafeImageTo8Bit img = unsafePerformIO $ withGenImage img $ \image -> 
-                creatingImage 
+unsafeImageTo8Bit img = unsafePerformIO $ withGenImage img $ \image ->
+                creatingImage
                  ({#call ensure8U #} image)
 
-imageTo32F img = withGenBareImage img $ \image -> 
-                creatingBareImage 
+imageTo32F img = withGenBareImage img $ \image ->
+                creatingBareImage
                  ({#call ensure32F #} image)
 
-imageTo8Bit img = withGenBareImage img $ \image -> 
-                creatingBareImage 
+imageTo8Bit img = withGenBareImage img $ \image ->
+                creatingBareImage
                  ({#call ensure8U #} image)
 #c
 enum ImageDepth {
      Depth32F = IPL_DEPTH_32F,
      Depth64F = IPL_DEPTH_64F,
-     Depth8U  = IPL_DEPTH_8U, 
-     Depth8S  = IPL_DEPTH_8S, 
-     Depth16U  = IPL_DEPTH_16U, 
+     Depth8U  = IPL_DEPTH_8U,
+     Depth8S  = IPL_DEPTH_8S,
+     Depth16U  = IPL_DEPTH_16U,
      Depth16S  = IPL_DEPTH_16S,
      Depth32S  = IPL_DEPTH_32S
      };
 #endc
- 
+
 {#enum ImageDepth {}#}
 
 deriving instance Show ImageDepth

import Foreign.C.String
import Foreign.Marshal.Utils
import Foreign.ForeignPtr hiding (newForeignPtr)
import Foreign.Concurrent 
import Foreign.Ptr
import Control.Parallel.Strategies
import Control.DeepSeq

              exists <- fileExist n
              if not exists then return Nothing
                            else do
                              i <- withCString n $ \name ->
                                     creatingBareImage ({#call cvLoadImage #} name 1)
                              bw <- imageTo32F i
                              return . Just . S  $ bw

loadColorImage8 :: FilePath -> IO (Maybe (Image RGB D8))
loadColorImage8 n = do
              exists <- fileExist n
              if not exists then return Nothing
                            else do
                              i <- withCString n $ \name ->
                                     creatingBareImage ({#call cvLoadImage #} name 1)
                              bw <- imageTo8Bit i
                              return . Just . S  $ bw

class Sized a where
