Discriminated union of rgb, grayscale, floating-point, and video-yuv images. More...
#include <Raster/GenericFrame.H>
Classes | |
class | MetaData |
MetaData for storing frame spacific information. More... | |
Public Types | |
enum | NativeType { NONE = 0, RGB_U8 = 1, RGB_F32 = 5, GRAY_U8 = 2, GRAY_F32 = 3, VIDEO = 4, GRAY_U16 = 6, RGB_U16 = 7, RGBD = 8 } |
Public Member Functions | |
GenericFrame () | |
Construct an empty frame. | |
GenericFrame (const Image< PixRGB< byte > > &rgbimg) | |
Construct an 8-bit integer rgb-native frame. | |
GenericFrame (const Image< PixRGB< byte > > &rgbimg, const Image< uint16 > &dimg) | |
Construct an 8-bit integer rgb-native frame plus 16-bit depth image. | |
GenericFrame (const Image< PixRGB< uint16 > > &rgbimg) | |
Construct an 16-bit integer rgb-native frame. | |
GenericFrame (const Layout< PixRGB< byte > > &rgbimg) | |
Construct an 8-bit integer rgb-native frame from a layout. | |
GenericFrame (const Image< PixRGB< float > > &rgbimg, const int flags) | |
Construct a 32-bit floating point rgb-native frame. | |
GenericFrame (const Image< byte > &grayimg) | |
Construct an 8-bit integer grayscale-native frame. | |
GenericFrame (const Image< uint16 > &grayimg) | |
Construct an 16-bit integer grayscale-native frame. | |
GenericFrame (const Layout< byte > &grayimg) | |
Construct an 8-bit integer grayscale-native frame from a layout. | |
GenericFrame (const Image< float > &floatimg, const int flags) | |
Construct a 32-bit floating point grayscale-native frame. | |
GenericFrame (const VideoFrame &vidframe) | |
Construct an video-native frame. | |
bool | initialized () const |
Check if we have a valid non-empty image, regardless of format. | |
GenericFrameSpec | frameSpec () const |
Get the frame's specifications. | |
NativeType | nativeType () const |
Get the frame's native image type. | |
std::string | nativeTypeName () const |
Get the frame's native image typename. | |
Dims | getDims () const |
Get the dimensions of the native image. | |
int | getWidth () const |
Get the width of the native image. | |
int | getHeight () const |
Get the height of the native image. | |
int | floatFlags () const |
Get the float-normalization flags. | |
void | setFloatFlags (int v) |
Change the float-normalization flags. | |
Image< PixRGB< byte > > | asRgbU8 () const |
Get an 8-bit integer rgb version of the frame, converting as necessary. | |
Image< PixRGB< byte > > | asRgb () const |
Image< PixRGB< uint16 > > | asRgbU16 () const |
const Layout< PixRGB< byte > > & | asRgbU8Layout () const |
Get an 8-bit integer rgb layout version of the frame, converting as necessary. | |
Image< PixRGB< float > > | asRgbF32 () const |
Get a 32-bit float rgb version of the frame, converting as necessary. | |
Image< byte > | asGrayU8 () const |
Get an 8-bit integer grayscale version of the frame, converting as necessary. | |
Image< byte > | asGray () const |
Image< uint16 > | asGrayU16 () const |
const Layout< byte > & | asGrayU8Layout () const |
Get an 8-bit integer grayscale layout version of the frame, converting as necessary. | |
const Layout< byte > & | asGrayU8NTSCLayout () const |
Get an 8-bit integer grayscale NTSC layout version of the frame, converting as necessary. | |
Image< float > | asGrayF32 () const |
Get a 32-bit float grayscale version of the frame, converting as necessary. | |
Image< float > | asFloat () const |
Image< byte > | asGrayNTSC () const |
Convert the image from rgb to luminance in NTSC coordinates. | |
VideoFrame | asVideo () const |
Get a video version of the frame, converting as necessary. | |
bool | hasMetaData (const std::string &tag) const |
Check whether we have a given piece of metadata. | |
rutz::shared_ptr< MetaData > | getMetaData (const std::string &tag) |
Get a given piece of metadata or throw an exception if it doesn't exist. | |
void | addMetaData (const std::string &tag, rutz::shared_ptr< MetaData > d) |
Insert a given piece of metadata, overwriting any previous metadata associated with that tag. | |
Static Public Member Functions | |
static GenericFrame | deepCopyOf (const GenericFrame &f) |
Make a new GenericFrame object with an internal private copy of any transient data. |
Discriminated union of rgb, grayscale, floating-point, and video-yuv images.
This class allows frame sources (raster files, movie clips, frame-grabbers, etc.) to return frames in their optimal native representation, while deferring to the caller the ability to subsequently convert the frame to any convenient type. Similarly, GenericFrame objects can be passed to frame destinations (raster files, movie files, onscreen windows) in their native format, incurring as few conversions as possible.
Definition at line 60 of file GenericFrame.H.
Definition at line 63 of file GenericFrame.H.
GenericFrame::GenericFrame | ( | ) |
Construct an empty frame.
Definition at line 59 of file GenericFrame.C.
Construct an 8-bit integer rgb-native frame.
Definition at line 66 of file GenericFrame.C.
GenericFrame::GenericFrame | ( | const Image< PixRGB< byte > > & | rgbimg, | |
const Image< uint16 > & | dimg | |||
) | [explicit] |
Construct an 8-bit integer rgb-native frame plus 16-bit depth image.
Definition at line 76 of file GenericFrame.C.
References ASSERT.
Construct an 16-bit integer rgb-native frame.
Definition at line 89 of file GenericFrame.C.
Construct an 8-bit integer rgb-native frame from a layout.
Definition at line 99 of file GenericFrame.C.
Construct a 32-bit floating point rgb-native frame.
flags | a bitwise-or'ed combination of FLOAT_NORM_0_255, FLOAT_NORM_WITH_SCALE, and FLOAT_NORM_PRESERVE (see Image/Normalize.H). |
Definition at line 109 of file GenericFrame.C.
Construct an 8-bit integer grayscale-native frame.
Definition at line 120 of file GenericFrame.C.
Construct an 16-bit integer grayscale-native frame.
Definition at line 130 of file GenericFrame.C.
Construct an 8-bit integer grayscale-native frame from a layout.
Definition at line 140 of file GenericFrame.C.
GenericFrame::GenericFrame | ( | const Image< float > & | floatimg, | |
const int | flags | |||
) | [explicit] |
Construct a 32-bit floating point grayscale-native frame.
flags | a bitwise-or'ed combination of FLOAT_NORM_0_255, FLOAT_NORM_WITH_SCALE, and FLOAT_NORM_PRESERVE (see Image/Normalize.H). |
Definition at line 150 of file GenericFrame.C.
GenericFrame::GenericFrame | ( | const VideoFrame & | vidframe | ) | [explicit] |
Construct an video-native frame.
Definition at line 161 of file GenericFrame.C.
void GenericFrame::addMetaData | ( | const std::string & | tag, | |
rutz::shared_ptr< MetaData > | d | |||
) |
Insert a given piece of metadata, overwriting any previous metadata associated with that tag.
Definition at line 637 of file GenericFrame.C.
References rutz::shared_ptr< T >::get(), and rutz::shared_ptr< T >::reset().
Referenced by World3DInput::readFrame(), and XMLInput::readFrame().
Image< float > GenericFrame::asGrayF32 | ( | ) | const |
Get a 32-bit float grayscale version of the frame, converting as necessary.
Definition at line 530 of file GenericFrame.C.
References GRAY_F32, GRAY_U16, GRAY_U8, Image< T >::initialized(), NONE, RGB_F32, RGB_U16, RGB_U8, and RGBD.
Referenced by asRgbF32(), ColorizeOfilt::filterFrame(), operator==(), PnmWriter::writeFrame(), PlaintextWriter::writeFrame(), MgzJEncoder::writeFrame(), PngWriter::writeFrame(), CcodeWriter::writeFrame(), HashOutputSeries::writeFrame(), and RawWriter::writeFrame().
Convert the image from rgb to luminance in NTSC coordinates.
Definition at line 189 of file GenericFrame.H.
References asGrayU8NTSCLayout().
Referenced by Raster::ReadGrayNTSC().
Get an 8-bit integer grayscale version of the frame, converting as necessary.
Definition at line 172 of file GenericFrame.H.
References asGrayU8Layout().
Referenced by ColorizeOfilt::filterFrame(), operator==(), PnmWriter::writeFrame(), ImageDisplayStream::writeFrame(), PlaintextWriter::writeFrame(), MgzJEncoder::writeFrame(), PngWriter::writeFrame(), CcodeWriter::writeFrame(), HashOutputSeries::writeFrame(), and RawWriter::writeFrame().
Get an 8-bit integer grayscale layout version of the frame, converting as necessary.
Definition at line 375 of file GenericFrame.C.
References asRgbU8(), VideoFrame::getBuffer(), VideoFrame::getDims(), VideoFrame::getMode(), GRAY_F32, GRAY_U16, GRAY_U8, NONE, normalizeFloat(), RGB_F32, RGB_U16, RGB_U8, and RGBD.
Referenced by asGrayU8(), and ImageDisplayStream::writeFrame().
Get an 8-bit integer grayscale NTSC layout version of the frame, converting as necessary.
Definition at line 434 of file GenericFrame.C.
References asRgbU8(), VideoFrame::getBuffer(), VideoFrame::getDims(), VideoFrame::getMode(), GRAY_F32, GRAY_U16, GRAY_U8, luminanceNTSC(), NONE, normalizeFloat(), RGB_F32, RGB_U16, RGB_U8, and RGBD.
Referenced by asGrayNTSC().
Get a 32-bit float rgb version of the frame, converting as necessary.
Definition at line 333 of file GenericFrame.C.
References asGrayF32(), asRgbU8(), GRAY_F32, GRAY_U16, GRAY_U8, Image< T >::initialized(), NONE, RGB_F32, RGB_U16, RGB_U8, and RGBD.
Referenced by LuminanceOfilt::filterFrame(), mexFunction(), operator==(), MgzEncoder::writeFrame(), PlaintextWriter::writeFrame(), MgzJEncoder::writeFrame(), CcodeWriter::writeFrame(), and HashOutputSeries::writeFrame().
Get an 8-bit integer rgb version of the frame, converting as necessary.
Definition at line 159 of file GenericFrame.H.
References asRgbU8Layout().
Referenced by asGrayU8Layout(), asGrayU8NTSCLayout(), asRgbF32(), asVideo(), main(), operator==(), StatsOutputSeries::writeFrame(), HashOutputSeries::writeFrame(), ImageDisplayStream::writeFrame(), PnmWriter::writeFrame(), PlaintextWriter::writeFrame(), MgzJEncoder::writeFrame(), CcodeWriter::writeFrame(), PngWriter::writeFrame(), and RawWriter::writeFrame().
Get an 8-bit integer rgb layout version of the frame, converting as necessary.
Definition at line 254 of file GenericFrame.C.
References GRAY_F32, GRAY_U16, GRAY_U8, NONE, normalizeFloat(), normalizeFloatRgb(), RGB_F32, RGB_U16, RGB_U8, RGBD, and VideoFrame::toRgb().
Referenced by asRgbU8(), and ImageDisplayStream::writeFrame().
VideoFrame GenericFrame::asVideo | ( | ) | const |
Get a video version of the frame, converting as necessary.
Definition at line 571 of file GenericFrame.C.
References asRgbU8(), GRAY_F32, GRAY_U16, GRAY_U8, VideoFrame::initialized(), NONE, RGB_F32, RGB_U16, RGB_U8, and RGBD.
Referenced by LuminanceOfilt::filterFrame(), ColorizeOfilt::filterFrame(), CoerceVideoFormatOfilt::filterFrame(), operator==(), HalfFieldDeinterlacer< BottomField >::readFrame(), BobDeinterlacer::readFrame(), Raster::ReadVideo(), DisplayController::setBackground(), submain(), HashOutputSeries::writeFrame(), MgzEncoder::writeFrame(), FfmpegEncoder::writeFrame(), MgzJEncoder::writeFrame(), HttpEncoder::writeFrame(), MrawvEncoder::writeFrame(), UcbMpegEncoder::writeFrame(), YuvWriter::writeFrame(), and SDLdisplayStream::writeFrame().
GenericFrame GenericFrame::deepCopyOf | ( | const GenericFrame & | f | ) | [static] |
Make a new GenericFrame object with an internal private copy of any transient data.
Definition at line 182 of file GenericFrame.C.
Referenced by DiskDataStream::writeFrame().
int GenericFrame::floatFlags | ( | ) | const [inline] |
Get the float-normalization flags.
Definition at line 153 of file GenericFrame.H.
Referenced by ColorizeOfilt::filterFrame(), LuminanceOfilt::filterFrame(), PnmWriter::writeFrame(), MgzEncoder::writeFrame(), MgzJEncoder::writeFrame(), MrawvEncoder::writeFrame(), and PngWriter::writeFrame().
GenericFrameSpec GenericFrame::frameSpec | ( | ) | const |
Get the frame's specifications.
Definition at line 198 of file GenericFrame.C.
References VideoFrame::getByteSwap(), getDims(), and VideoFrame::getMode().
Referenced by ColorizeOfilt::filterFrame(), LuminanceOfilt::filterFrame(), nativeTypeName(), SequenceFileStream::peekFrameSpec(), MgzInputStream::peekFrameSpec(), MrawvInputStream::peekFrameSpec(), MgzJInputStream::peekFrameSpec(), LowLevelEncoderMap::writeFrame(), and InfoOutputSeries::writeFrame().
Dims GenericFrame::getDims | ( | ) | const |
Get the dimensions of the native image.
Definition at line 216 of file GenericFrame.C.
References ASSERT, Image< T >::getDims(), VideoFrame::getDims(), GRAY_F32, GRAY_U16, GRAY_U8, NONE, RGB_F32, RGB_U16, RGB_U8, and RGBD.
Referenced by frameSpec(), getHeight(), getWidth(), initialized(), main(), SimEventInputFrame::toString(), ImageDisplayStream::writeFrame(), MgzEncoder::writeFrame(), and SDLdisplayStream::writeFrame().
int GenericFrame::getHeight | ( | void | ) | const [inline] |
Get the height of the native image.
Definition at line 150 of file GenericFrame.H.
References getDims(), and Dims::h().
Referenced by DisplayController::setBackground(), and MgzJEncoder::writeFrame().
rutz::shared_ptr< GenericFrame::MetaData > GenericFrame::getMetaData | ( | const std::string & | tag | ) |
Get a given piece of metadata or throw an exception if it doesn't exist.
Definition at line 621 of file GenericFrame.C.
References rutz::shared_ptr< T >::get().
Referenced by InferoTemporalSalBayes::attentionShift(), and InferoTemporalSIFT::attentionShift().
int GenericFrame::getWidth | ( | void | ) | const [inline] |
Get the width of the native image.
Definition at line 147 of file GenericFrame.H.
References getDims(), and Dims::w().
Referenced by DisplayController::setBackground(), and MgzJEncoder::writeFrame().
bool GenericFrame::hasMetaData | ( | const std::string & | tag | ) | const |
Check whether we have a given piece of metadata.
Definition at line 613 of file GenericFrame.C.
References rutz::shared_ptr< T >::get().
Referenced by InferoTemporalSalBayes::attentionShift(), and InferoTemporalSIFT::attentionShift().
bool GenericFrame::initialized | ( | ) | const |
Check if we have a valid non-empty image, regardless of format.
Definition at line 170 of file GenericFrame.C.
References ASSERT, getDims(), and NONE.
Referenced by main(), SequenceFileStream::peekFrameSpec(), MgzInputStream::peekFrameSpec(), MrawvInputStream::peekFrameSpec(), MgzJInputStream::peekFrameSpec(), FrameIstream::readAndDiscardFrame(), MrawvInputStream::readFrame(), MgzJInputStream::readFrame(), SequenceFileStream::readFrame(), MgzInputStream::readFrame(), submain(), and Raster::WriteFrame().
NativeType GenericFrame::nativeType | ( | ) | const [inline] |
Get the frame's native image type.
Definition at line 138 of file GenericFrame.H.
Referenced by ColorizeOfilt::filterFrame(), LuminanceOfilt::filterFrame(), mexFunction(), operator==(), DisplayController::setBackground(), PnmWriter::writeFrame(), MgzEncoder::writeFrame(), ImageDisplayStream::writeFrame(), StatsOutputSeries::writeFrame(), PfzWriter::writeFrame(), PlaintextWriter::writeFrame(), FfmpegEncoder::writeFrame(), MgzJEncoder::writeFrame(), RasterOutputSeries::writeFrame(), HttpEncoder::writeFrame(), PngWriter::writeFrame(), CcodeWriter::writeFrame(), HashOutputSeries::writeFrame(), RawWriter::writeFrame(), and SDLdisplayStream::writeFrame().
std::string GenericFrame::nativeTypeName | ( | ) | const |
Get the frame's native image typename.
Definition at line 210 of file GenericFrame.C.
References frameSpec(), and GenericFrameSpec::nativeTypeName().
Referenced by SimEventInputFrame::toString(), MgzEncoder::writeFrame(), StatsOutputSeries::writeFrame(), MgzJEncoder::writeFrame(), and HashOutputSeries::writeFrame().
void GenericFrame::setFloatFlags | ( | int | v | ) |
Change the float-normalization flags.
Definition at line 235 of file GenericFrame.C.
References GRAY_F32, and RGB_F32.
Referenced by MrawvEncoder::writeFrame().