ipfml.utils

Utils functions of ipfml package (array normalization)

Functions

integral_area_simps(y_values, dx) Returns area under curves from provided data points using Simpsons rule
integral_area_trapz(y_values, dx) Returns area under curves from provided data points using Trapezium rule
normalize_2D_arr(arr) Return array normalize from its min and max values
normalize_arr(arr) Normalize data of 1D array shape
normalize_arr_with_range(arr, min, max) Normalize data of 1D array shape
ipfml.utils.integral_area_simps(y_values, dx)[source]

Returns area under curves from provided data points using Simpsons rule

Parameters:
  • points – array of point coordinates
  • dx – number of unit for x axis
Returns:

Area under curves obtained from these points

Example:

>>> from ipfml import utils
>>> import numpy as np
>>> y_values = np.array([5, 20, 4, 18, 19, 18, 7, 4])
>>> area = utils.integral_area_simps(y_values, dx=5)
>>> area
460.0
ipfml.utils.integral_area_trapz(y_values, dx)[source]

Returns area under curves from provided data points using Trapezium rule

Parameters:
  • points – array of point coordinates
  • dx – number of unit for x axis
Returns:

Area under curves obtained from these points

Example:

>>> from ipfml import utils
>>> import numpy as np
>>> y_values = np.array([5, 20, 4, 18, 19, 18, 7, 4])
>>> area = utils.integral_area_trapz(y_values, dx=5)
>>> area
452.5
ipfml.utils.normalize_2D_arr(arr)[source]

Return array normalize from its min and max values

Parameters:arr – 2D Numpy array
Returns:Normalized 2D Numpy array

Example:

>>> from PIL import Image
>>> from ipfml import utils, processing
>>> img = Image.open('./images/test_img.png')
>>> img_mscn = processing.rgb_to_mscn(img)
>>> img_normalized = utils.normalize_2D_arr(img_mscn)
>>> img_normalized.shape
(200, 200)
ipfml.utils.normalize_arr(arr)[source]

Normalize data of 1D array shape

Parameters:arr – array data of 1D shape
Returns:Normalized 1D array

Example:

>>> from ipfml import utils
>>> import numpy as np
>>> arr = np.arange(11)
>>> arr_normalized = utils.normalize_arr(arr)
>>> arr_normalized[1]
0.1
ipfml.utils.normalize_arr_with_range(arr, min, max)[source]

Normalize data of 1D array shape

Parameters:arr – array data of 1D shape
Returns:Normalized 1D Numpy array

Example:

>>> from ipfml import utils
>>> import numpy as np
>>> arr = np.arange(11)
>>> arr_normalized = utils.normalize_arr_with_range(arr, 0, 20)
>>> arr_normalized[1]
0.05