filter_im#

The filter_im module contains functions that pre-process XCT images like segmentation and cropping, allowing for pore structure analysis. This is mainly used as a quick method of processing raw XCT scans, but Pore2Chip operates best on already segmented data, as the methods of segmentation used here rely on Otsu’s filtering, which may not capture solid matter of a particular density (ex. plant roots).


filter_single()#

pore2chip.filter_im.filter_single(image, cropx=None, cropy=None, grayMinimum=None, grayMaximum=None, thresh=None, gauss=5, invert=False)#

Filters single image using OpenCV Gaussian Blur and thresholds images using Otsu’s thresholding.

Parameters:
  • image (2D array) – Input image

  • cropx (tuple or similar) – Number of pixels in x-axis to crop image by

  • cropy (tuple or similar) – Number of pixels in y-axis to crop image by

  • grayMinimum (int) – Minimum pixel value to count as solid

  • grayMaximum (int) – Maximum pixel value to count as solid

  • thresh (int) – Threshold value. If not given, then Otsu’s threshold is used

  • gauss (int) – Radius of Gaussian Blur. Default is 5

  • invert (Boolean) – Inverts pixel values of image

Returns:

Filtered image

Return type:

2D numpy array

The coordinates for cropx and cropy begin at the top left.


filter_list()#

pore2chip.filter_im.filter_list(img_list, cropx=None, cropy=None, crop_depth=None, grayMinimum=None, grayMaximum=None, thresh=None, gauss=5, invert=False)#

Filters array of images using OpenCV Gaussian Blur and thresholds images using Otsu’s thresholding.

Parameters:
  • img_list (3D numpy array) – Array of input images

  • cropx (tuple or similar) – Number of pixels in x-axis to crop image by

  • cropy (tuple or similar) – Number of pixels in y-axis to crop image by

  • crop_depth (int) – Number of pixels in z-axis

  • grayMinimum (int) – Minimum pixel value to count as solid

  • grayMaximum (int) – Maximum pixel value to count as solid

  • thresh (int) – Threshold value. If not given, then Otsu’s threshold is used

  • gauss (int) – Radius of Gaussian Blur. Default is 5.

  • invert (Boolean) – Inverts pixel values of image list

Returns:

Array of filtered images

Return type:

3D numpy array

The coordinates for cropx and cropy begin at the top left.


read_and_filter()#

pore2chip.filter_im.read_and_filter(img_path, cropx=None, cropy=None, grayMinimum=None, grayMaximum=None, thresh=None, gauss=5, invert=False)#

Reads and filters a single image using OpenCV Gaussian Blur and thresholds images using Otsu’s thresholding.

Parameters:
  • img_path (str) – Absolute path to image

  • cropx (tuple or similar) – Number of pixels in x-axis to crop image by

  • cropy (tuple or similar) – Number of pixels in y-axis to crop image by

  • grayMinimum (int) – Minimum pixel value to count as solid

  • grayMaximum (int) – Maximum pixel value to count as solid

  • thresh (int) – Threshold value. If not given, then Otsu’s threshold is used

  • gauss (int) – Radius of Gaussian Blur. Default is 5.

  • invert (Boolean) – Inverts pixel values of image list

Returns:

Filtered image

Return type:

2D numpy array

The coordinates for cropx and cropy begin at the top left.


read_and_filter_list()#

pore2chip.filter_im.read_and_filter_list(img_path, cropx=None, cropy=None, crop_depth=None, grayMinimum=None, grayMaximum=None, thresh=None, gauss=5, invert=False)#

Reads and filters array of images using OpenCV Gaussian Blur and thresholds images using Otsu’s thresholding

Parameters:
  • img_path (str) – Absolute path to directory containing images

  • cropx (tuple or similar) – Number of pixels in x-axis to crop image by

  • cropy (tuple or similar) – Number of pixels in y-axis to crop image by

  • crop_depth (int) – Number of pixels in z-axis

  • grayMinimum (int) – Minimum pixel value to count as solid

  • grayMaximum (int) – Maximum pixel value to count as solid

  • thresh (int) – Threshold value. If not given, then Otsu’s threshold is used

  • gauss (int) – Radius of Gaussian Blur. Default is 5.

  • invert (Boolean) – Inverts pixel values of image list

Returns:

Array of filtered images

Return type:

3D numpy array

The coordinates for cropx and cropy begin at the top left.

Leave crop_depth empty to include all files in directory.

Note

This project is under active development.