Package isula.image.util
Class ImageFileHelper
java.lang.Object
isula.image.util.ImageFileHelper
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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[][]
getImageArrayFromFile
(File imageFile) Transforms an image into an array of ints.static int[][]
getImageArrayFromFile
(String fileName) static ImageSegment
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.
-
Field Details
-
ABSENT_PIXEL_FLAG
public static final int ABSENT_PIXEL_FLAG- See Also:
-
GRAYSCALE_MIN_RANGE
public static final int GRAYSCALE_MIN_RANGE- See Also:
-
GRAYSCALE_MAX_RANGE
public static final int GRAYSCALE_MAX_RANGE- See Also:
-
-
Constructor Details
-
ImageFileHelper
public ImageFileHelper()
-
-
Method Details
-
getImageArrayFromFile
- Throws:
IOException
-
getImageArrayFromFile
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 positioncolumn
- 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 positioncolumn
- 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
Returns a segment with the background removed.- Parameters:
originalImage
- Original image.- Returns:
- An Image Segment.
-
cropImage
Crops an image according to a segment.- Parameters:
imageSegment
- Segment to applyoriginalImage
- 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.
-