Commit 2c032b572bedad1b5daf0ac25e049ae10b6cbf1a

Made background estimator work for color images.

Needs CV version db57bb5e
backgroundEstimator.hs
(5 / 4)
  
1717 print ("Frames",noFrames,"Skip",m)
1818 frames <- replicateM n (replicateM_ m (dropFrame cap)
1919 >> print ("Frame",getFrameNumber cap)
20 >> getFrame cap
21 >>= convertToGrayScale)
20 >> getFrame cap )
21 -- >>= convertToGrayScale)
2222 -- >>= return . drop 10
2323 -- sequence_ [saveImage ("frame_"++show i++".png") img
2424 -- | img <- frames | i<-[1..]]
2929assemble frames = do
3030 let (w,h) = getSize (head frames)
3131 (fw,fh) = (20,20)
32 empty = emptyCopy (head frames)
3332 areas = [(x,y) | x <- ([0,fw..w-fw]++[w-fw])
3433 , y <- ([0,fh..h-fh]++[h-fh])]
34 empty <- createImage32F (w,h) 3
3535 sequence_ [blit empty (fst $ chooseBestTile p (fw,fh) frames)
3636 p
3737 | p <- areas ]
4040chooseBestTile pos size imgs = minimumBy (compare`on`snd)
4141 $ zip tiles dists
4242 where
43 dists = [ median [IM.sum (IM.absDiff a b) | a <- tiles]
43 dists = [ median [distEst a b | a <- tiles]
4444 | b <- tiles]
45 distEst a b = IM.sum (IM.absDiff (convertToGrayScale a) (convertToGrayScale b))
4546 tiles = map (getRegion pos size) imgs
4647
4748