Package com.openstego.desktop.util
Class ImageUtil
java.lang.Object
com.openstego.desktop.util.ImageUtil
Image utilities
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
DEFAULT_IMAGE_TYPE
Default image type in case not provided
-
-
Method Details
-
generateRandomImage
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
-
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
-
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
-
getRgbFromImage
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
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
Get image from given RGB data- Parameters:
rgb
- List with three elements of two-dimensional int's - R, G and B- Returns:
- Image
-
getImageFromYuv
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
Method to pad an image such that it becomes perfect square. The padding uses black color- Parameters:
image
- Input image
-
cropImage
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
-