]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Main.hs
Add a chunked version of zoom.
[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 (make_grid, zoom, zoom_chunk)
8 import MRI
9
10
11 in_file :: FilePath
12 in_file = "./data/mri.bin"
13
14
15 main :: IO ()
16 main = main2d_chunk
17
18
19 main2d_chunk :: IO ()
20 main2d_chunk = do
21 (s:_) <- getArgs
22 let scale = read s :: Int
23 let zoom_factor = (1, scale, scale)
24 let out_file = "output.bmp"
25 arr <- read_word16s in_file
26 let arr' = swap_bytes arr
27 let arrInv = flip_x $ flip_y arr'
28 let arrSlice = z_slice3 50 arrInv
29 let dbl_data = R.map fromIntegral arrSlice
30 let g = make_grid 1 dbl_data
31 let output = zoom_chunk g zoom_factor
32 write_values_chunk_to_bitmap output out_file
33
34
35
36 main3d :: IO ()
37 main3d = do
38 (s:_) <- getArgs
39 let scale = read s :: Int
40 let zoom_factor = (scale, scale, scale)
41 let out_file = "output.bin"
42 arr <- read_word16s in_file
43 let arr' = swap_bytes arr
44 -- let arrInv = flip_x $ flip_y arr'
45 let arrMRI = R.reshape mri_shape arr'
46 let dbl_data = R.force $ R.map fromIntegral arrMRI
47 let g = make_grid 1 dbl_data
48 let output = zoom g zoom_factor
49 let word16_output = bracket_array output
50 write_word16s out_file word16_output
51
52
53 main2d :: IO ()
54 main2d = do
55 (s:_) <- getArgs
56 let scale = read s :: Int
57 let zoom_factor = (1, scale, scale)
58 let out_file = "output.bmp"
59 arr <- read_word16s in_file
60 let arr' = swap_bytes arr
61 let arrInv = flip_x $ flip_y arr'
62 let arrSlice = z_slice 50 arrInv
63 let arrSlice' = R.reshape mri_slice3d arrSlice
64 let dbl_data = R.map fromIntegral arrSlice'
65 let g = make_grid 1 dbl_data
66 let output = zoom g zoom_factor
67 write_values_slice_to_bitmap (z_slice 0 output) out_file