Package com.openstego.desktop.util
Class ImageUtil
- java.lang.Object
-
- com.openstego.desktop.util.ImageUtil
-
public class ImageUtil extends Object
Image utilities
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_IMAGE_TYPE
Default image type in case not provided
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ImageHolder
byteArrayToImage(byte[] imageData, String imgFileName)
Method to convert byte array to imagestatic void
cropImage(ImageHolder image, int cropWidth, int cropHeight)
Method crop an image to the given dimensions.static ImageHolder
generateRandomImage(int numOfPixels)
Method to generate a random image filled with noise.static ImageHolder
getDiffImage(ImageHolder leftImage, ImageHolder rightImage)
Method generate difference image between two given imagesstatic BufferedImage
getImageFromRgb(List<int[][]> rgb)
Get image from given RGB datastatic BufferedImage
getImageFromYuv(List<int[][]> yuv, int imgType)
Get image (with RGB data) from given YUV datastatic List<int[][]>
getRgbFromImage(BufferedImage image)
Get RGB data array from given imagestatic List<int[][]>
getYuvFromImage(BufferedImage image)
Get YUV data from given image's RGB datastatic byte[]
imageToByteArray(ImageHolder image, String imageFileName, OpenStegoPlugin<?> plugin)
Method to convert BufferedImage to byte arraystatic void
makeImageSquare(ImageHolder image)
Method to pad an image such that it becomes perfect square.static int
pixelRange(double p)
Utility method to limit the value within [0,255] rangestatic int
pixelRange(int p)
Utility method to limit the value within [0,255] range
-
-
-
Field Detail
-
DEFAULT_IMAGE_TYPE
public static final String DEFAULT_IMAGE_TYPE
Default image type in case not provided- See Also:
- Constant Field Values
-
-
Method Detail
-
generateRandomImage
public static ImageHolder generateRandomImage(int numOfPixels) throws OpenStegoException
Method to generate a random image filled with noise.- Parameters:
numOfPixels
- Number of pixels required in the image- Returns:
- Random image filled with noise
- Throws:
OpenStegoException
- Processing issues
-
imageToByteArray
public static byte[] imageToByteArray(ImageHolder image, String imageFileName, OpenStegoPlugin<?> plugin) throws OpenStegoException
Method to convert BufferedImage to byte array- Parameters:
image
- Image dataimageFileName
- Name of the image fileplugin
- Reference to the plugin- Returns:
- Image data as byte array
- Throws:
OpenStegoException
- Processing issues
-
byteArrayToImage
public static ImageHolder byteArrayToImage(byte[] imageData, String imgFileName) throws OpenStegoException
Method to convert byte array to image- Parameters:
imageData
- Image data as byte arrayimgFileName
- Name of the image file- Returns:
- Buffered image
- Throws:
OpenStegoException
- Processing issues
-
getRgbFromImage
public static List<int[][]> getRgbFromImage(BufferedImage image)
Get RGB data array from given image- Parameters:
image
- Image- Returns:
- List with three elements of two-dimensional int's - R, G and B
-
getYuvFromImage
public static List<int[][]> getYuvFromImage(BufferedImage image)
Get YUV data from given image's RGB data- Parameters:
image
- Image- Returns:
- List with three elements of two-dimensional int's - Y, U and V
-
getImageFromRgb
public static BufferedImage getImageFromRgb(List<int[][]> rgb)
Get image from given RGB data- Parameters:
rgb
- List with three elements of two-dimensional int's - R, G and B- Returns:
- Image
-
getImageFromYuv
public static BufferedImage getImageFromYuv(List<int[][]> yuv, int imgType)
Get image (with RGB data) from given YUV data- Parameters:
yuv
- List with three elements of two-dimensional int's - Y, U and VimgType
- Type of image (e.g. BufferedImage.TYPE_INT_RGB)- Returns:
- Image
-
pixelRange
public static int pixelRange(int p)
Utility method to limit the value within [0,255] range- Parameters:
p
- Input value- Returns:
- Limited value
-
pixelRange
public static int pixelRange(double p)
Utility method to limit the value within [0,255] range- Parameters:
p
- Input value- Returns:
- Limited value
-
makeImageSquare
public static void makeImageSquare(ImageHolder image)
Method to pad an image such that it becomes perfect square. The padding uses black color- Parameters:
image
- Input image
-
cropImage
public static void cropImage(ImageHolder image, int cropWidth, int cropHeight)
Method crop an image to the given dimensions. If dimensions are more than the input image size, then the image gets padded with black color- Parameters:
image
- Input imagecropWidth
- Width required for cropped imagecropHeight
- Height required for cropped image
-
getDiffImage
public static ImageHolder getDiffImage(ImageHolder leftImage, ImageHolder rightImage) throws OpenStegoException
Method generate difference image between two given images- Parameters:
leftImage
- Left input imagerightImage
- Right input image- Returns:
- Difference image
- Throws:
OpenStegoException
- Processing issues
-
-