writeArrayToStorableFile )
import Data.Array.Repa.IO.BMP ( writeImageToBMP )
import Data.Array.Repa.Operators.Traversal ( unsafeTraverse )
-import Data.Array.Repa.Repr.Unboxed ( Unbox )
import Data.Array.Repa.Slice ( All( All ), Any( Any ) )
import Values ( Values, Values2D )
bracket lower_threshold upper_threshold x
| x < lower_threshold = 0
| x > upper_threshold = 255
- | otherwise = truncate (r * 255)
+ | otherwise = truncate (r * 255)
where
numerator = x - lower_threshold
denominator = upper_threshold - lower_threshold
- r = numerator/denominator
+ r = numerator / denominator
flip16 :: Word16 -> Word16
truncate_rgb (r, g, b) =
(r', g', b')
where
- r' = truncate (r * 255)
- g' = truncate (g * 255)
- b' = truncate (b * 255)
+ r' = truncate (r * 255) :: Word8
+ g' = truncate (g * 255) :: Word8
+ b' = truncate (b * 255) :: Word8
write_values_to_bmp :: FilePath -> Values2D -> IO ()
writeImageToBMP path colors
-z_slice :: (Unbox a, Source r a) => Int -> Array r DIM3 a -> Array D DIM2 a
+z_slice :: (Source r a) => Int -> Array r DIM3 a -> Array D DIM2 a
z_slice n arr =
slice arr (Any :. n :. All :. All)