Class Matrix2BufferedImage
- java.lang.Object
-
- edu.gsu.cs.dmlab.imageproc.imageparam.util.Matrix2BufferedImage
-
public abstract class Matrix2BufferedImage extends Object
This is anabstract
class which is designed to convert a given matrix into aBufferedImage
.
The methods below are inspired from Tom Gibara's implementation of Canny Edge Detection > readLuminance().
See his code here.
Note: This class follows the convention of reading/writing matrices in a row-by-row fashion.- Author:
- Azim Ahmadzadeh, Data Mining Lab, Georgia State University
-
-
Constructor Summary
Constructors Constructor Description Matrix2BufferedImage()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImage
getBufferedImage(double[][] matrix)
This method converts a matrix of double values to abufferedImage
, usingsetRGB
method.static BufferedImage
getBufferedImage(double[][] matrix, int imageType)
This method converts a matrix of double values to a BufferedImage, usingsetRGB
method.
-
-
-
Method Detail
-
getBufferedImage
public static BufferedImage getBufferedImage(double[][] matrix) throws org.apache.commons.math3.exception.NullArgumentException
This method converts a matrix of double values to abufferedImage
, usingsetRGB
method. If the give values are outside of the acceptable range (i.e., [0,255]), it throws an exception and returnsnull
.
TheBufferedImage
will be created with the default image typeTYPE_BYTE_GRAY
. If the image type needs to be specified, usegetBufferedImage(double[][])
.- Parameters:
matrix
- to be converted to a BufferedImage object.- Returns:
- The
BufferedImage
constructed based on the given matrix. - Throws:
org.apache.commons.math3.exception.NullArgumentException
-
getBufferedImage
public static BufferedImage getBufferedImage(double[][] matrix, int imageType) throws org.apache.commons.math3.exception.NullArgumentException
This method converts a matrix of double values to a BufferedImage, usingsetRGB
method. If the give values are outside of the acceptable range (i.e., [0,255]), it throws an exception and returns.- Parameters:
matrix
- to be converted to a BufferedImage object.imageType
- type of the bufferedImage. Acceptable choices are:BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_RGB, BufferedImage.TYPE_BYTE_GRAY
.- Returns:
- The
BufferedImage
constructed based on the given matrix. - Throws:
org.apache.commons.math3.exception.NullArgumentException
-
Note: It is recommended to use "TYPE_INT_RGB" in case of jp2 format, and "TYPE_3BYTE_BGR" in case of jpg format.
-
-