REPA: Resizing an image

116 views Asked by At

I am trying to, given an image, generate a new one with twice the original width and height.

I am using the haskell's REPA library (https://hackage.haskell.org/package/repa-3.4.1.2/docs/Data-Array-Repa.html), and following this tutorial (https://wiki.haskell.org/Numeric_Haskell:_A_Repa_Tutorial).

main :: IO () 
main = do
    [f, path] <- getArgs
    (RGB v) <- runIL $ readImage f
        let newImage = (computeS $ twiceSize v) :: Array F DIM3 Word8
        runIL $ writeImage (path) (RGB newImage)

twiceSize :: (Source r e) => Array r DIM3 e -> Array D DIM3 e
twiceSize img = something img newImage
   where
      (Z :. originalWidth :. originalHeight  :. k) = extent img
      newImage = (Z :. originalWidth*2 :. originalHeight*2 :. k)
      something a b = ... 

Now, these are my thoughts:

  • 1) Get the original image width an height

  • 2) Generate a new Array with the right size:

  • 3) Fill the new Array with the original, with some function.

The thing is, I don't really know how to achieve points 2) and 3). What does the "something" function need to do in order to fill the new array? Should I use a map on the newImage?

Thanks in advance.

0

There are 0 answers