]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Main.hs
Make Main a little more amenable to changes.
[spline3.git] / src / Main.hs
1 module Main
2 where
3
4 import qualified Data.Array.Repa as R (map, force, reshape)
5 import qualified Data.Array.Repa.IO.BMP as R (writeComponentsToBMP)
6 import System.Environment (getArgs)
7
8 import Grid (make_grid, zoom)
9 import MRI
10 import Values (drop_z, zoom_shape)
11
12 main :: IO ()
13 main = main2d
14
15 in_file :: FilePath
16 in_file = "./data/mri.bin"
17
18 main3d :: IO ()
19 main3d = do
20 (s:_) <- getArgs
21 let scale = read s :: Int
22 let zoom_factor = (scale, scale, scale)
23 let out_file = "output.bin"
24 arr <- read_word16s in_file
25 let arr' = swap_bytes arr
26 -- let arrInv = flip_x $ flip_y arr'
27 let arrMRI = R.reshape mri_shape arr'
28 let dbl_data = R.force $ R.map fromIntegral arrMRI
29 let g = make_grid 1 dbl_data
30 let output = zoom g zoom_factor
31 let word16_output = bracket_array output
32 write_word16s out_file word16_output
33
34 main2d :: IO ()
35 main2d = do
36 (s:_) <- getArgs
37 let scale = read s :: Int
38 let zoom_factor = (1, scale, scale)
39 let out_file = "output.bmp"
40 arr <- read_word16s in_file
41 let arr' = swap_bytes arr
42 let arrInv = flip_x $ flip_y arr'
43 let arrSlice = z_slice 50 arrInv
44 let arrSlice' = R.reshape mri_slice3d arrSlice
45 let dbl_data = R.map fromIntegral arrSlice'
46 let g = make_grid 1 dbl_data
47 let output = zoom g zoom_factor
48 let arrBrack = bracket_array output
49 let mri_slice2d = drop_z $ zoom_shape zoom_factor mri_slice3d
50 let colors = values_to_colors $ R.reshape mri_slice2d
51 $ R.map fromIntegral arrBrack
52 let routput = R.map (\(red, _, _) -> red) colors
53 let goutput = R.map (\(_, green, _) -> green) colors
54 let boutput = R.map (\(_, _, blue) -> blue) colors
55 R.writeComponentsToBMP out_file routput goutput boutput