Class ImageFileHelper

java.lang.Object
isula.image.util.ImageFileHelper

public class ImageFileHelper extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[][]
    applyFilter(int[][] imageGraph, int[][] backgroundFilterMask)
    Applies a filter to an image.
    static int[][]
    cropImage(ImageSegment imageSegment, int[][] originalImage)
    Crops an image according to a segment.
    static int[][]
    dilateImage(int[][] imageGraph, int[][] structuringElement, int foregroundClass, int backgroundClass)
    Applies the dilation operator of mathematical morphology.
    static int[][]
    erodeImage(int[][] imageGraph, int[][] structuringElement, int foregroundClass, int backgroundClass)
    Applies the erosion operator of mathematical morphology.
    static void
    generateImageFromArray(int[][] imageGraph, String outputImageFile)
    Generates an image file from an integer array.
    static int[][]
    Transforms an image into an array of ints.
    static int[][]
     
    getSegmentWithoutBackground(int[][] originalImage)
    Returns a segment with the background removed.
    static boolean
    isFit(int row, int column, int[][] imageGraph, int[][] structuringElement, int foregroundClass)
    Identifies a pixel as a fit.
    static boolean
    isHit(int row, int column, int[][] imageGraph, int[][] structuringElement, int foregroundClass)
    Identifies a pixel as a hit.
    static int[][]
    openImage(int[][] imageGraph, int repetitionParameter)
    Applies the open operator of mathematical morphology to an image.
    static int[][]
    removeBackgroundPixels(int[][] imageGraph)
    Marks black pixels as background ones.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ImageFileHelper

      public ImageFileHelper()
  • Method Details

    • getImageArrayFromFile

      public static int[][] getImageArrayFromFile(String fileName) throws IOException
      Throws:
      IOException
    • getImageArrayFromFile

      public static int[][] getImageArrayFromFile(File imageFile) throws IOException
      Transforms an image into an array of ints.
      Parameters:
      imageFile - Image file.
      Returns:
      An array of ints.
      Throws:
      IOException - In case file reading fails.
    • generateImageFromArray

      public static void generateImageFromArray(int[][] imageGraph, String outputImageFile) throws IOException
      Generates an image file from an integer array.
      Parameters:
      imageGraph - Array of ints representing the image.
      outputImageFile - Location of the generated file.
      Throws:
      IOException - If file writing/reading fails.
    • openImage

      public static int[][] openImage(int[][] imageGraph, int repetitionParameter)
      Applies the open operator of mathematical morphology to an image.
      Parameters:
      imageGraph - Image as an array on ints.
      repetitionParameter - Number of repetitions.
      Returns:
      A new image after the application of the operator.
    • removeBackgroundPixels

      public static int[][] removeBackgroundPixels(int[][] imageGraph)
      Marks black pixels as background ones.
      Parameters:
      imageGraph - Image as an array of ints.
      Returns:
      A new image, with black pixels marked as missing.
    • erodeImage

      public static int[][] erodeImage(int[][] imageGraph, int[][] structuringElement, int foregroundClass, int backgroundClass)
      Applies the erosion operator of mathematical morphology.
      Parameters:
      imageGraph - Image represented as an array of integers.
      structuringElement - Structuring element.
      foregroundClass - Class for the foreground.
      backgroundClass - Class for the background.
      Returns:
      A new image, after the application of the operator.
    • dilateImage

      public static int[][] dilateImage(int[][] imageGraph, int[][] structuringElement, int foregroundClass, int backgroundClass)
      Applies the dilation operator of mathematical morphology.
      Parameters:
      imageGraph - Image represented as an array of integers.
      structuringElement - Structuring element.
      foregroundClass - Class for the foreground.
      backgroundClass - Class for the background.
      Returns:
      A new image, after the application of the operator.
    • isHit

      public static boolean isHit(int row, int column, int[][] imageGraph, int[][] structuringElement, int foregroundClass)
      Identifies a pixel as a hit.
      Parameters:
      row - Row position
      column - Column position.
      imageGraph - Image as an array of integers.
      structuringElement - Structuring element.
      foregroundClass - Class of the foreground.
      Returns:
      True if is a hit, false otherwise.
    • isFit

      public static boolean isFit(int row, int column, int[][] imageGraph, int[][] structuringElement, int foregroundClass)
      Identifies a pixel as a fit.
      Parameters:
      row - Row position
      column - Column position.
      imageGraph - Image as an array of integers.
      structuringElement - Structuring element.
      foregroundClass - Class of the foreground.
      Returns:
      True if is a hit, false otherwise.
    • getSegmentWithoutBackground

      public static ImageSegment getSegmentWithoutBackground(int[][] originalImage)
      Returns a segment with the background removed.
      Parameters:
      originalImage - Original image.
      Returns:
      An Image Segment.
    • cropImage

      public static int[][] cropImage(ImageSegment imageSegment, int[][] originalImage)
      Crops an image according to a segment.
      Parameters:
      imageSegment - Segment to apply
      originalImage - Original image.
      Returns:
      An image, cropped.
    • applyFilter

      public static int[][] applyFilter(int[][] imageGraph, int[][] backgroundFilterMask) throws Exception
      Applies a filter to an image.
      Parameters:
      imageGraph - Original image.
      backgroundFilterMask - Background filter.
      Returns:
      A new image resulting of the application of the filter.
      Throws:
      Exception - In case of an error.