]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Main.hs
Make the minimum number of changes necessary to work with repa-3.1.1.1. Unfortunately...
[spline3.git] / src / Main.hs
1 module Main
2 where
3
4 import qualified Data.Array.Repa as R
5 import System.Environment (getArgs)
6
7 import Grid (zoom)
8 import MRI (
9 flip_x,
10 flip_y,
11 mri_shape,
12 mri_slice3d,
13 read_word16s,
14 round_array,
15 swap_bytes,
16 write_values_slice_to_bitmap,
17 write_word16s,
18 z_slice
19 )
20
21 in_file :: FilePath
22 in_file = "./data/mri.bin"
23
24
25 main :: IO ()
26 main = main3d
27
28 main3d :: IO ()
29 main3d = do
30 (s:_) <- getArgs
31 let scale = read s :: Int
32 let zoom_factor = (scale, scale, scale)
33 let out_file = "output.bin"
34 arr <- read_word16s in_file
35 let arr' = swap_bytes arr
36 let arrMRI = R.reshape mri_shape arr'
37 let dbl_data = R.computeS $ R.map fromIntegral arrMRI
38 let output = zoom dbl_data zoom_factor
39 let word16_output = R.computeS $ round_array output
40 write_word16s out_file word16_output
41
42
43 main2d :: IO ()
44 main2d = do
45 (s:_) <- getArgs
46 let scale = read s :: Int
47 let zoom_factor = (1, scale, scale)
48 let out_file = "output.bmp"
49 arr <- read_word16s in_file
50 let arrSlice = R.computeUnboxedS $ z_slice 50 $ flip_x $ flip_y $ swap_bytes arr
51 let arrSlice' = R.reshape mri_slice3d arrSlice
52
53 -- If zoom isn't being inlined we need to extract the slice before hand,
54 -- and convert it to the require formed.
55 let dbl_data = R.computeS $ R.map fromIntegral arrSlice'
56 let output = zoom dbl_data zoom_factor
57 let arrSlice0 = R.computeUnboxedS $ z_slice 0 output
58
59 write_values_slice_to_bitmap arrSlice0 out_file