// Normalize image values between 0uy and 255uy.
let normalizeAndConvert (img: Image<Gray, 'TDepth>) : Image<Gray, byte> =
- let min = ref [| 0.0 |]
- let minLocation = ref <| [| Point() |]
- let max = ref [| 0.0 |]
- let maxLocation = ref <| [| Point() |]
- img.MinMax(min, max, minLocation, maxLocation)
- ((img.Convert<Gray, float32>() - (!min).[0]) / ((!max).[0] - (!min).[0]) * 255.0).Convert<Gray, byte>()
+ (normalize (img.Convert<Gray, float32>()) 255.).Convert<Gray, byte>()
let saveImg (img: Image<'TColor, 'TDepth>) (filepath: string) =
img.Save(filepath)