Scale the input real array to the integer RGB range [a, b]
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | real_array | ||
integer, | intent(in) | :: | a | |||
integer, | intent(in) | :: | b |
pure function scale_real_int(real_array,a,b) result(int_scaled_array) real(wp), dimension(:), intent(in) :: real_array integer, intent(in) :: a, b real(wp), dimension(size(real_array)) :: normalizedArray integer, dimension(size(real_array)) :: int_scaled_array ! Normalize the real array elements to the range [0, 1] normalizedArray = scale_real_real(real_array, 0.0_wp, 1.0_wp) ! Scale the real array elements between a and b int_scaled_array = a + nint((b - a) * normalizedArray) end function scale_real_int