Documentation of 'boofcv.io.image.ConvertBufferedImage' Java class
ConvertBufferedImage
boofcv.io.image

Class ConvertBufferedImage



  • public class ConvertBufferedImage
    extends java.lang.Object
    Functions for converting to and from BufferedImage.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.awt.image.BufferedImage checkInputs(ImageBase src, java.awt.image.BufferedImage dst)
      If null the dst is declared, otherwise it checks to see if the 'dst' as the same shape as 'src'.
      static <T extends ImageBase>
      T
      convertFrom(java.awt.image.BufferedImage src, boolean orderRgb, ImageType<T> imageType)
      Converts a buffered image into an image of the specified type.
      static <T extends ImageBase>
      T
      convertFrom(java.awt.image.BufferedImage src, boolean orderRgb, T output) 
      static GrayF32 convertFrom(java.awt.image.BufferedImage src, GrayF32 dst)
      Converts the buffered image into an GrayF32.
      static GrayU8 convertFrom(java.awt.image.BufferedImage src, GrayU8 dst)
      Converts the buffered image into an GrayU8.
      static <T extends ImageBase>
      void
      convertFrom(java.awt.image.BufferedImage src, T dst, boolean orderRgb)
      Converts a buffered image into an image of the specified type.
      static <T extends GrayI16>
      T
      convertFrom(java.awt.image.BufferedImage src, T dst, java.lang.Class<T> type)
      Converts the buffered image into an GrayI16.
      static void convertFromInterleaved(java.awt.image.BufferedImage src, ImageInterleaved dst, boolean orderRgb) 
      static <T extends ImageGray>
      Planar<T>
      convertFromMulti(java.awt.image.BufferedImage src, Planar<T> dst, boolean orderRgb, java.lang.Class<T> type)
      Converts the buffered image into an Planar image of the specified type.
      static <T extends ImageGray>
      T
      convertFromSingle(java.awt.image.BufferedImage src, T dst, java.lang.Class<T> type)
      Converts a buffered image into an image of the specified type.
      static java.awt.image.BufferedImage convertTo_F32(Planar<GrayF32> src, java.awt.image.BufferedImage dst, boolean orderRgb)
      Converts a Planar GrayF32 into a BufferedImage.
      static java.awt.image.BufferedImage convertTo_U8(Planar<GrayU8> src, java.awt.image.BufferedImage dst, boolean orderRgb)
      Converts a Planar GrayU8 into a BufferedImage.
      static java.awt.image.BufferedImage convertTo(GrayF32 src, java.awt.image.BufferedImage dst)
      Converts the buffered image into an GrayF32.
      static java.awt.image.BufferedImage convertTo(GrayI16 src, java.awt.image.BufferedImage dst)
      Converts a GrayI16 into a BufferedImage.
      static java.awt.image.BufferedImage convertTo(GrayU8 src, java.awt.image.BufferedImage dst)
      Converts a GrayU8 into a BufferedImage.
      static java.awt.image.BufferedImage convertTo(ImageBase src, java.awt.image.BufferedImage dst, boolean orderRgb)
      Converts an image into a BufferedImage.
      static java.awt.image.BufferedImage convertTo(InterleavedF32 src, java.awt.image.BufferedImage dst, boolean orderRgb) 
      static java.awt.image.BufferedImage convertTo(InterleavedU8 src, java.awt.image.BufferedImage dst, boolean orderRgb) 
      static java.awt.image.BufferedImage convertTo(javax.swing.JComponent comp, java.awt.image.BufferedImage storage)
      Draws the component into a BufferedImage.
      static java.awt.image.BufferedImage extractBuffered(GrayU8 img)
      Creates a new BufferedImage that internally uses the same data as the provided GrayU8.
      static java.awt.image.BufferedImage extractBuffered(InterleavedU8 img)
      Creates a new BufferedImage that internally uses the same data as the provided InterleavedU8.
      static GrayU8 extractGrayU8(java.awt.image.BufferedImage img)
      For BufferedImage stored as a byte array internally it extracts an image.
      static InterleavedU8 extractInterleavedU8(java.awt.image.BufferedImage img)
      For BufferedImage stored as a byte array internally it extracts an interleaved image.
      static boolean isSubImage(java.awt.image.BufferedImage img)
      Checks to see if the input image is a subImage().
      static void orderBandsBufferedFromRGB(sun.awt.image.ByteInterleavedRaster raster, int type)
      The image the BufferedImage was created from had RGB or RGBA color order.
      static void orderBandsBufferedFromRGB(sun.awt.image.IntegerInterleavedRaster raster, int type)
      The image the BufferedImage was created from had RGB or RGBA color order.
      static <T extends ImageGray>
      void
      orderBandsBufferedFromRgb(Planar<T> image, java.awt.image.BufferedImage input) 
      static Planar orderBandsIntoBuffered(Planar src, java.awt.image.BufferedImage dst)
      Returns a new image with the color bands in the appropriate ordering.
      static void orderBandsIntoRGB(ImageInterleaved image, java.awt.image.BufferedImage input) 
      static void orderBandsIntoRGB(InterleavedF32 image, java.awt.image.BufferedImage input) 
      static void orderBandsIntoRGB(InterleavedU8 image, java.awt.image.BufferedImage input) 
      static <T extends ImageGray>
      void
      orderBandsIntoRGB(Planar<T> image, java.awt.image.BufferedImage input)
      If a Planar was created from a BufferedImage its colors might not be in the expected order.
      static java.awt.image.BufferedImage stripAlphaChannel(java.awt.image.BufferedImage image)
      Returns an image which doesn't have an alpha channel.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConvertBufferedImage

        public ConvertBufferedImage()
    • Method Detail

      • stripAlphaChannel

        public static java.awt.image.BufferedImage stripAlphaChannel(java.awt.image.BufferedImage image)
        Returns an image which doesn't have an alpha channel. If the input image doesn't have an alpha channel to start then its returned as is. Otherwise a new image is created and the RGB channels are copied and the new image returned.
        Parameters:
        image - Input image
        Returns:
        Image without an alpha channel
      • extractInterleavedU8

        public static InterleavedU8 extractInterleavedU8(java.awt.image.BufferedImage img)
        For BufferedImage stored as a byte array internally it extracts an interleaved image. The input image and the returned image will both share the same internal data array. Using this function allows unnecessary memory copying to be avoided.
        Parameters:
        img - Image whose internal data is extracted and wrapped.
        Returns:
        An image whose internal data is the same as the input image.
      • extractGrayU8

        public static GrayU8 extractGrayU8(java.awt.image.BufferedImage img)
        For BufferedImage stored as a byte array internally it extracts an image. The input image and the returned image will both share the same internal data array. Using this function allows unnecessary memory copying to be avoided.
        Parameters:
        img - Image whose internal data is extracted and wrapped.
        Returns:
        An image whose internal data is the same as the input image.
      • extractBuffered

        public static java.awt.image.BufferedImage extractBuffered(InterleavedU8 img)
        Creates a new BufferedImage that internally uses the same data as the provided InterleavedU8. If 3 bands then the image will be of type TYPE_3BYTE_BGR or if 1 band TYPE_BYTE_GRAY.
        Parameters:
        img - Input image who's data will be wrapped by the returned BufferedImage.
        Returns:
        BufferedImage which shared data with the input image.
      • extractBuffered

        public static java.awt.image.BufferedImage extractBuffered(GrayU8 img)

        Creates a new BufferedImage that internally uses the same data as the provided GrayU8. The returned BufferedImage will be of type TYPE_BYTE_GRAY.

        NOTE: This only works on images which are not subimages!

        Parameters:
        img - Input image who's data will be wrapped by the returned BufferedImage.
        Returns:
        BufferedImage which shared data with the input image.
      • convertFrom

        public static <T extends ImageBase> void convertFrom(java.awt.image.BufferedImage src,
                                                             T dst,
                                                             boolean orderRgb)
        Converts a buffered image into an image of the specified type.
        Parameters:
        src - Input BufferedImage which is to be converted
        dst - The image which it is being converted into
        orderRgb - If applicable, should it adjust the ordering of each color band to maintain color consistency
      • convertFrom

        public static <T extends ImageBase> T convertFrom(java.awt.image.BufferedImage src,
                                                          boolean orderRgb,
                                                          ImageType<T> imageType)
        Converts a buffered image into an image of the specified type.
        Parameters:
        src - Input BufferedImage which is to be converted
        orderRgb - If applicable, should it adjust the ordering of each color band to maintain color consistency
        imageType - Type of image it is to be converted into
        Returns:
        The image
      • convertFrom

        public static <T extends ImageBase> T convertFrom(java.awt.image.BufferedImage src,
                                                          boolean orderRgb,
                                                          T output)
      • convertFromSingle

        public static <T extends ImageGray> T convertFromSingle(java.awt.image.BufferedImage src,
                                                                T dst,
                                                                java.lang.Class<T> type)
        Converts a buffered image into an image of the specified type. In a 'dst' image is provided it will be used for output, otherwise a new image will be created.
      • convertFrom

        public static GrayU8 convertFrom(java.awt.image.BufferedImage src,
                                         GrayU8 dst)
        Converts the buffered image into an GrayU8. If the buffered image has multiple channels the intensities of each channel are averaged together.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new unsigned image is created.
        Returns:
        Converted image.
      • convertFrom

        public static <T extends GrayI16> T convertFrom(java.awt.image.BufferedImage src,
                                                        T dst,
                                                        java.lang.Class<T> type)
        Converts the buffered image into an GrayI16. If the buffered image has multiple channels the intensities of each channel are averaged together.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new unsigned image is created.
        Returns:
        Converted image.
      • convertFrom

        public static GrayF32 convertFrom(java.awt.image.BufferedImage src,
                                          GrayF32 dst)
        Converts the buffered image into an GrayF32. If the buffered image has multiple channels the intensities of each channel are averaged together.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new unsigned image is created.
        Returns:
        Converted image.
      • convertFromMulti

        public static <T extends ImageGrayPlanar<T> convertFromMulti(java.awt.image.BufferedImage src,
                                                                       Planar<T> dst,
                                                                       boolean orderRgb,
                                                                       java.lang.Class<T> type)
        Converts the buffered image into an Planar image of the specified type.
        Parameters:
        src - Input image. Not modified.
        dst - Output. The converted image is written to. If null a new unsigned image is created.
        orderRgb - If applicable, should it adjust the ordering of each color band to maintain color consistency. Most of the time you want this to be true.
        type - Which type of data structure is each band. (GrayU8 or GrayF32)
        Returns:
        Converted image.
      • convertFromInterleaved

        public static void convertFromInterleaved(java.awt.image.BufferedImage src,
                                                  ImageInterleaved dst,
                                                  boolean orderRgb)
      • convertTo

        public static java.awt.image.BufferedImage convertTo(ImageBase src,
                                                             java.awt.image.BufferedImage dst,
                                                             boolean orderRgb)

        Converts an image into a BufferedImage. The best way to think of this function is that it's a mindless typecast. If you don't provide an output image then it will create one. However there isn't always a direct equivalent between a BoofCV image and BufferedImage internal type. A "reasonable" choice will be made, but for your application it might not be a good choice.

        Parameters:
        src - Input image. Pixels must have a value from 0 to 255.
        dst - Where the converted image is written to. If null a new image is created. See comment above about type.
        orderRgb - If applicable, should it change the order of the color bands (assumed RGB or ARGB) into the order based on BufferedImage.TYPE. Most of the time you want this to be true.
        Returns:
        Converted image.
      • convertTo

        public static java.awt.image.BufferedImage convertTo(GrayU8 src,
                                                             java.awt.image.BufferedImage dst)
        Converts a GrayU8 into a BufferedImage. If the buffered image has multiple channels then the input image is copied into each channel.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new image is created.
        Returns:
        Converted image.
      • convertTo

        public static java.awt.image.BufferedImage convertTo(GrayI16 src,
                                                             java.awt.image.BufferedImage dst)
        Converts a GrayI16 into a BufferedImage. If the buffered image has multiple channels then the input image is copied into each channel.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new image is created.
        Returns:
        Converted image.
      • convertTo

        public static java.awt.image.BufferedImage convertTo(GrayF32 src,
                                                             java.awt.image.BufferedImage dst)
        Converts the buffered image into an GrayF32. If the buffered image has multiple channels then the input image is copied into each channel. The floating point image is assumed to be between 0 and 255.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new image is created.
        Returns:
        Converted image.
      • convertTo_U8

        public static java.awt.image.BufferedImage convertTo_U8(Planar<GrayU8> src,
                                                                java.awt.image.BufferedImage dst,
                                                                boolean orderRgb)
        Converts a Planar GrayU8 into a BufferedImage.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new image is created.
        orderRgb - If applicable, should it change the order of the color bands (assumed RGB or ARGB) into the order based on BufferedImage.TYPE. Most of the time you want this to be true.
        Returns:
        Converted image.
      • convertTo_F32

        public static java.awt.image.BufferedImage convertTo_F32(Planar<GrayF32> src,
                                                                 java.awt.image.BufferedImage dst,
                                                                 boolean orderRgb)
        Converts a Planar GrayF32 into a BufferedImage.
        Parameters:
        src - Input image.
        dst - Where the converted image is written to. If null a new image is created.
        orderRgb - If applicable, should it change the order of the color bands (assumed RGB or ARGB) into the order based on BufferedImage.TYPE. Most of the time you want this to be true.
        Returns:
        Converted image.
      • convertTo

        public static java.awt.image.BufferedImage convertTo(InterleavedU8 src,
                                                             java.awt.image.BufferedImage dst,
                                                             boolean orderRgb)
      • convertTo

        public static java.awt.image.BufferedImage convertTo(InterleavedF32 src,
                                                             java.awt.image.BufferedImage dst,
                                                             boolean orderRgb)
      • checkInputs

        public static java.awt.image.BufferedImage checkInputs(ImageBase src,
                                                               java.awt.image.BufferedImage dst)
        If null the dst is declared, otherwise it checks to see if the 'dst' as the same shape as 'src'.
      • convertTo

        public static java.awt.image.BufferedImage convertTo(javax.swing.JComponent comp,
                                                             java.awt.image.BufferedImage storage)
        Draws the component into a BufferedImage.
        Parameters:
        comp - The component being drawn into an image.
        storage - if not null the component is drawn into it, if null a new BufferedImage is created.
        Returns:
        image of the component
      • orderBandsIntoBuffered

        public static Planar orderBandsIntoBuffered(Planar src,
                                                    java.awt.image.BufferedImage dst)
        Returns a new image with the color bands in the appropriate ordering. The returned image will reference the original image's image arrays.
      • orderBandsBufferedFromRGB

        public static void orderBandsBufferedFromRGB(sun.awt.image.ByteInterleavedRaster raster,
                                                     int type)
        The image the BufferedImage was created from had RGB or RGBA color order. This swaps the bytes around to put it into the expected local format
      • orderBandsBufferedFromRGB

        public static void orderBandsBufferedFromRGB(sun.awt.image.IntegerInterleavedRaster raster,
                                                     int type)
        The image the BufferedImage was created from had RGB or RGBA color order. This swaps the bytes around to put it into the expected local format
      • orderBandsIntoRGB

        public static <T extends ImageGray> void orderBandsIntoRGB(Planar<T> image,
                                                                   java.awt.image.BufferedImage input)
        If a Planar was created from a BufferedImage its colors might not be in the expected order. Invoking this function ensures that the image will have the expected ordering. For images with 3 bands it will be RGB and for 4 bands it will be ARGB.
      • orderBandsBufferedFromRgb

        public static <T extends ImageGray> void orderBandsBufferedFromRgb(Planar<T> image,
                                                                           java.awt.image.BufferedImage input)
      • orderBandsIntoRGB

        public static void orderBandsIntoRGB(ImageInterleaved image,
                                             java.awt.image.BufferedImage input)
      • orderBandsIntoRGB

        public static void orderBandsIntoRGB(InterleavedU8 image,
                                             java.awt.image.BufferedImage input)
      • orderBandsIntoRGB

        public static void orderBandsIntoRGB(InterleavedF32 image,
                                             java.awt.image.BufferedImage input)
      • isSubImage

        public static boolean isSubImage(java.awt.image.BufferedImage img)
        Checks to see if the input image is a subImage().
        Parameters:
        img -
        Returns:

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.