where
import qualified Data.Array.Repa as R
+import qualified Data.Array.Repa.Operators.Traversal as R (unsafeTraverse)
import Test.HUnit (Assertion, assertEqual)
import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
zoom v3d scale_factor
| xsize == 0 || ysize == 0 || zsize == 0 = empty3d
| otherwise =
- R.compute $ R.unsafeTraverse v3d transExtent f
+ R.computeS $ R.unsafeTraverse v3d transExtent f
where
(xsize, ysize, zsize) = dims v3d
transExtent = zoom_shape scale_factor
import Data.Word
import Data.Bits
-import Data.Array.Repa as R
-import Data.Array.Repa.Repr.Unboxed as R
-import Data.Array.Repa.IO.Binary as R
+import Data.Array.Repa as R
+import Data.Array.Repa.Eval as R (now)
+import Data.Array.Repa.Repr.Unboxed as R
+import Data.Array.Repa.IO.Binary as R
import Data.Array.Repa.Algorithms.ColorRamp as R
-import Data.Array.Repa.IO.BMP as R (writeImageToBMP)
+import Data.Array.Repa.Operators.Traversal as R (unsafeTraverse)
+import Data.Array.Repa.IO.BMP as R (writeImageToBMP)
import Values
read_word16s :: FilePath -> IO RawData3D
read_word16s path = do
arr <- R.readArrayFromStorableFile path mri_shape
- now $ R.copy arr
+ now $ R.copyS arr
values_to_colors :: (Shape sh) => (Values sh) -> (ColorData sh)
values_to_colors arr =
- R.compute $ R.map (truncate_rgb . ramp_it) arr
+ R.computeS $ R.map (truncate_rgb . ramp_it) arr
where
ramp_it :: Double -> (Double, Double, Double)
ramp_it x =
R.writeImageToBMP path colors
where
arr_bracketed = bracket_array v3d
- colors = values_to_colors $ R.compute $ R.map fromIntegral arr_bracketed
+ colors = values_to_colors $ R.computeS $ R.map fromIntegral arr_bracketed
arr <- read_word16s in_file
let arr' = swap_bytes arr
let arrMRI = R.reshape mri_shape arr'
- let dbl_data = R.compute $ R.map fromIntegral arrMRI
+ let dbl_data = R.computeS $ R.map fromIntegral arrMRI
let output = zoom dbl_data zoom_factor
- let word16_output = R.compute $ round_array output
+ let word16_output = R.computeS $ round_array output
write_word16s out_file word16_output
let zoom_factor = (1, scale, scale)
let out_file = "output.bmp"
arr <- read_word16s in_file
- let arrSlice = R.computeUnboxed $ z_slice 50 $ flip_x $ flip_y $ swap_bytes arr
+ let arrSlice = R.computeUnboxedS $ z_slice 50 $ flip_x $ flip_y $ swap_bytes arr
let arrSlice' = R.reshape mri_slice3d arrSlice
-- If zoom isn't being inlined we need to extract the slice before hand,
-- and convert it to the require formed.
- let dbl_data = R.compute $ R.map fromIntegral arrSlice'
+ let dbl_data = R.computeS $ R.map fromIntegral arrSlice'
let output = zoom dbl_data zoom_factor
- let arrSlice0 = R.computeUnboxed $ z_slice 0 output
+ let arrSlice0 = R.computeUnboxedS $ z_slice 0 output
write_values_slice_to_bitmap arrSlice0 out_file