neutompy.image.image

neutompy.image.image.read_tiff(fname, croi=None, froi=None)[source]

This function reads a 2D TIFF image.

Parameters:
  • fname (str) – String defining the file name or the file path
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI file name or file path.
Returns:

out (ndarray) – The 2D image. If the file specified doesn’t exist, the function returns False.

neutompy.image.image.read_fits(fname, croi=None, froi=None)[source]

This function reads a 2D FITS image.

Parameters:
  • fname (str) – String defining the file name or the file path
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI filename or file path.
Returns:

out (ndarray) – The 2D image. If the file specified doesn’t exist, the function returns False.

neutompy.image.image.read_fits_stack(fname, slices=[], croi=None, froi=None)[source]

Read stack of fits images.

Parameters:
  • fname (str) – One of the file names of the fits stack. File with unknown image extension are skipped automatically. If fname is ‘’ or a folder path, then a dialog box is opened to select one of the file of the stack to read. The initial directory is C:(in windows) or / (in UNIX) if fname==’’, otherwise is the folder path assigned to fname.
  • slices (list of int, optional) – List of the element indexes to read. If it is [] then all fits image files are read.
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI filename or file path.
Returns:

array (ndarray) – The 3D stack of images

neutompy.image.image.read_tiff_stack(fname, slices=[], croi=None, froi=None)[source]

Read stack of tiff images.

Parameters:
  • fname (str) – One of the file names of the tiff stack. File with unknown image extension are skipped automatically. If fname is ‘’ or a folder path, then a dialog box is opened to select one of the file of the stack to read. The initial directory is C:(in windows) or / (in UNIX) if fname==’’, otherwise is the folder path assigned to fname.
  • slices (list of int, optional) – List of the element indexes to read. If it is [] then all tif image files are read.
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI filename or file path.
Returns:

array (ndarray) – The 3D stack of images

neutompy.image.image.get_rect_coordinates_from_roi(fname)[source]

This function returns the coordinates from a rectangular region of interest defined in a .roi file generated by ImageJ / Fiji.

N.B.: indexing starts from 0. Incremet rowmax and col_max + 1 to crop an image, for example: crop = img[rowmin:(rowmax+1), colmin:(colmax+1)]

Parameters:fname (str) – String defining the path or the name of the Image ROI file.
Returns:
  • rowmin (int) – The minimum row coordinate.
  • rowmax (int) – The maximum row coordinate.
  • colmin (int) – The minimum column coordinate.
  • colmax (int) – The maximum column coordinate.
neutompy.image.image.read_image(fname, croi=None, froi=None)[source]

This function reads a 2D TIF or FITS image.

Parameters:
  • fname (str) – String defining the file name or the file path
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI filename or file path.
Returns:

out (ndarray) – The 2D image. If the file specified doesn’t exist, the function returns False.

neutompy.image.image.read_stack_from_list(flist, slices=[], croi=None, froi=None)[source]

Read stack of images from file list.

Parameters:
  • flist (list of str) – List of the file names or file paths to read in the defined order. File with unknown image extension are skipped automatically.
  • slices (list of int, optional) – List of the indexes of flist to read. If it is [] then all image files are read.
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI filename or file path.
Returns:

array (ndarray) – The 3D stack of images

neutompy.image.image.read_dataset(proj_180=True, croi=None, froi=None)[source]

This function reads a dataset which contains dark-field, flat-field, projection images and optionally the projection at 180 degree. The user selects the main folder and the files from a dialog box. A two-dimensional region of interest of each image can be read specifying the coordinates or an ImageJ .roi file.

Parameters:
  • proj_180 (bool, optional) – If True the user must select the projection at 180 degree separately from the stack of projections.
  • croi (tuple, optional) – Tuple defining the ROI indexes for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI file name or file path.
Returns:

  • proj (3d array) – The array containing the stack of projections.
  • dark (3d array) – The array containing the stack of dark-field images.
  • flat (3d array) – The array containing the stack of flat-field images.
  • proj180 (2d array) – Only if proj_180 is True, the 2D array representing the projection at 180 degree is returned separately.

neutompy.image.image.read_image_stack(fname, slices=[], croi=None, froi=None)[source]

Read stack of TIFF or FITS images. This function recognize the file type from the file extension.

Parameters:
  • fname (str) – One of the file names of the tiff stack. File with unknown image extension are skipped automatically.
  • slices (list of int, optional) – List of the element indexes to read. If it is [] then all tif image files are read.
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • froi (str, optional) – String defining the ImageJ ROI filename or file path.
Returns:

array (ndarray) – The 3D stack of images

neutompy.image.image.write_fits(fname, img, overwrite=False)[source]

This function write to the disk an array as fits image.

Parameters:
  • fname (str) – String defining the file name or file path of the image to save. If the extension is not specified, it is automatically appended to fname.
  • img (ndarray) – The array to save as image.
  • overwrite (bool, optional) – If True, overwrites the output file if it exists. Raises an IOError if False and the output file exists. Default is False.
neutompy.image.image.write_tiff(fname, img, overwrite=False)[source]

This function write to the disk an array as tiff image.

Parameters:
  • fname (str) – String defining the file name or file path of the image to save. If the extension is not specified, it is automatically appended to fname.
  • img (ndarray) – The array to save as image.
  • overwrite (bool, optional) – If True, overwrites the output file if it exists. Raises an IOError if False and the output file exists. Default is False.
neutompy.image.image.write_tiff_stack(fname, data, axis=0, start=0, croi=None, digit=4, dtype=None, overwrite=False)[source]

This function writes a 3D array to a stack of 2D TIFF images.

Parameters:
  • fname (str) – String defining the prefix of the file name and the containing folder.
  • data (ndarray) – The 3D stack to write.
  • axis (int, optional) – The axis along which the stacking is performed.
  • start (int, optional) – Index used for saving the first image.
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • digit (int, optional) – Number of digits used for the numbering of the images.
  • dtype (dtype, optional) – Data type of the images to save.
  • overwrite (bool, optional) – If True, overwrites the output file if it exists. Raises an IOError if False and the output file exists. Default is False.
neutompy.image.image.write_fits_stack(fname, data, axis=0, start=0, croi=None, digit=4, dtype=None, overwrite=False)[source]

This function writes a 3D array to a stack of 2D FITS images.

Parameters:
  • fname (str) – String defining the prefix of the file name and the containing folder.
  • data (ndarray) – The 3D stack to write.
  • axis (int, optional) – The axis along which the stacking is performed.
  • start (int, optional) – Index used for saving the first image.
  • croi (tuple, optional) – Tuple defining the indexes range for each axis. It must be follow this notation: ( (row_start, row_end, row_step), (col_start, col_end, col_step) )
  • digit (int, optional) – Number of digits used for the numbering of the images.
  • dtype (dtype, optional) – Data type of the images to save.
  • overwrite (bool, optional) – If True, overwrites the output file if it exists. Raises an IOError if False and the output file exists. Default is False.
neutompy.image.image.get_rect_coordinates_from_roi(fname)[source]

This function returns the coordinates from a rectangular region of interest defined in a .roi file generated by ImageJ / Fiji.

N.B.: indexing starts from 0. Incremet rowmax and col_max + 1 to crop an image, for example: crop = img[rowmin:(rowmax+1), colmin:(colmax+1)]

Parameters:fname (str) – String defining the path or the name of the Image ROI file.
Returns:
  • rowmin (int) – The minimum row coordinate.
  • rowmax (int) – The maximum row coordinate.
  • colmin (int) – The minimum column coordinate.
  • colmax (int) – The maximum column coordinate.
neutompy.image.image.get_filename_pattern(fname)[source]