Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GenericFrame Class Reference

#include <Raster/GenericFrame.H>

Collaboration diagram for GenericFrame:

Collaboration graph
[legend]
List of all members.

Detailed Description

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.

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
}

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< 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< byteasGrayU8 () const
 Get an 8-bit integer grayscale version of the frame, converting as necessary.
Image< byteasGray () const
Image< uint16asGrayU16 () 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< byteasGrayNTSC () 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< MetaDatagetMetaData (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.

Classes

class  MetaData
 MetaData for storing frame spacific information. More...


Member Enumeration Documentation

enum GenericFrame::NativeType
 

Enumerator:
NONE  no image
RGB_U8  rgb color, 8 bits unsigned int per component
RGB_F32  rgb color, 32 bits floating point per component
GRAY_U8  grayscale, 8 bits unsigned int per pixel
GRAY_F32  grayscale, 32 bits floating point per pixel
GRAY_U16  grayscale, 16 bits unsigned uint per pixel
RGB_U16  rgb color, 16 bits unsigned int per componet

Definition at line 63 of file GenericFrame.H.


Constructor & Destructor Documentation

GenericFrame::GenericFrame  ) 
 

Construct an empty frame.

Definition at line 59 of file GenericFrame.C.

GenericFrame::GenericFrame const Image< PixRGB< byte > > &  rgbimg  )  [explicit]
 

Construct an 8-bit integer rgb-native frame.

Definition at line 66 of file GenericFrame.C.

GenericFrame::GenericFrame const Image< PixRGB< uint16 > > &  rgbimg  )  [explicit]
 

Construct an 16-bit integer rgb-native frame.

Definition at line 76 of file GenericFrame.C.

GenericFrame::GenericFrame const Layout< PixRGB< byte > > &  rgbimg  )  [explicit]
 

Construct an 8-bit integer rgb-native frame from a layout.

Definition at line 86 of file GenericFrame.C.

GenericFrame::GenericFrame const Image< PixRGB< float > > &  rgbimg,
const int  flags
[explicit]
 

Construct a 32-bit floating point rgb-native frame.

Parameters:
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 96 of file GenericFrame.C.

GenericFrame::GenericFrame const Image< byte > &  grayimg  )  [explicit]
 

Construct an 8-bit integer grayscale-native frame.

Definition at line 107 of file GenericFrame.C.

GenericFrame::GenericFrame const Image< uint16 > &  grayimg  )  [explicit]
 

Construct an 16-bit integer grayscale-native frame.

Definition at line 117 of file GenericFrame.C.

GenericFrame::GenericFrame const Layout< byte > &  grayimg  )  [explicit]
 

Construct an 8-bit integer grayscale-native frame from a layout.

Definition at line 127 of file GenericFrame.C.

GenericFrame::GenericFrame const Image< float > &  floatimg,
const int  flags
[explicit]
 

Construct a 32-bit floating point grayscale-native frame.

Parameters:
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 137 of file GenericFrame.C.

GenericFrame::GenericFrame const VideoFrame vidframe  )  [explicit]
 

Construct an video-native frame.

Definition at line 148 of file GenericFrame.C.


Member Function Documentation

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 612 of file GenericFrame.C.

References rutz::shared_ptr< T >::get(), and rutz::shared_ptr< T >::reset().

Referenced by XMLInput::readFrame().

Image< float > GenericFrame::asGrayF32  )  const
 

Get a 32-bit float grayscale version of the frame, converting as necessary.

Definition at line 508 of file GenericFrame.C.

References asGray(), GRAY_F32, GRAY_U16, GRAY_U8, Image< T >::initialized(), luminance(), NONE, Layout< T >::render(), RGB_F32, RGB_U16, and RGB_U8.

Referenced by asFloat(), doResizeFrame(), ColorizeOfilt::filterFrame(), main(), operator==(), HashOutputSeries::writeFrame(), RawWriter::writeFrame(), PnmWriter::writeFrame(), PngWriter::writeFrame(), PlaintextWriter::writeFrame(), and CcodeWriter::writeFrame().

Image<byte> GenericFrame::asGrayNTSC  )  const [inline]
 

Convert the image from rgb to luminance in NTSC coordinates.

Definition at line 185 of file GenericFrame.H.

References asGrayU8NTSCLayout(), and Layout< T >::render().

Referenced by Raster::ReadGrayNTSC().

Image<byte> GenericFrame::asGrayU8  )  const [inline]
 

Get an 8-bit integer grayscale version of the frame, converting as necessary.

Definition at line 168 of file GenericFrame.H.

References asGrayU8Layout(), and Layout< T >::render().

Referenced by doRescale(), doResizeFrame(), ColorizeOfilt::filterFrame(), operator==(), HashOutputSeries::writeFrame(), RawWriter::writeFrame(), PnmWriter::writeFrame(), PngWriter::writeFrame(), PlaintextWriter::writeFrame(), CcodeWriter::writeFrame(), and ImageDisplayStream::writeFrame().

const Layout< byte > & GenericFrame::asGrayU8Layout  )  const
 

Get an 8-bit integer grayscale layout version of the frame, converting as necessary.

Definition at line 356 of file GenericFrame.C.

References VideoFrame::getBuffer(), VideoFrame::getDims(), VideoFrame::getMode(), GRAY_F32, GRAY_U16, GRAY_U8, Layout< T >::initialized(), luminance(), NONE, normalizeFloat(), Layout< T >::render(), RGB_F32, RGB_U16, and RGB_U8.

Referenced by asGray(), asGrayU8(), and ImageDisplayStream::writeFrame().

const Layout< byte > & GenericFrame::asGrayU8NTSCLayout  )  const
 

Get an 8-bit integer grayscale NTSC layout version of the frame, converting as necessary.

Definition at line 414 of file GenericFrame.C.

References VideoFrame::getBuffer(), VideoFrame::getDims(), VideoFrame::getMode(), GRAY_F32, GRAY_U16, GRAY_U8, Layout< T >::initialized(), luminanceNTSC(), NONE, normalizeFloat(), Layout< T >::render(), RGB_F32, RGB_U16, and RGB_U8.

Referenced by asGrayNTSC().

Image< PixRGB< float > > GenericFrame::asRgbF32  )  const
 

Get a 32-bit float rgb version of the frame, converting as necessary.

Definition at line 315 of file GenericFrame.C.

References asRgbU8(), GRAY_F32, GRAY_U16, GRAY_U8, Image< T >::initialized(), luminance(), NONE, Layout< T >::render(), RGB_F32, RGB_U16, and RGB_U8.

Referenced by buildTitle(), doResizeFrame(), LuminanceOfilt::filterFrame(), main(), mexFunction(), operator==(), HashOutputSeries::writeFrame(), PlaintextWriter::writeFrame(), CcodeWriter::writeFrame(), and MgzEncoder::writeFrame().

Image<PixRGB<byte> > GenericFrame::asRgbU8  )  const [inline]
 

Get an 8-bit integer rgb version of the frame, converting as necessary.

Definition at line 155 of file GenericFrame.H.

References asRgbU8Layout(), and Layout< T >::render().

Referenced by asRgbF32(), doRescale(), doResizeFrame(), operator==(), StatsOutputSeries::writeFrame(), HashOutputSeries::writeFrame(), RawWriter::writeFrame(), PnmWriter::writeFrame(), PngWriter::writeFrame(), PlaintextWriter::writeFrame(), CcodeWriter::writeFrame(), and ImageDisplayStream::writeFrame().

const Layout< PixRGB< byte > > & GenericFrame::asRgbU8Layout  )  const
 

Get an 8-bit integer rgb layout version of the frame, converting as necessary.

Definition at line 238 of file GenericFrame.C.

References GRAY_F32, GRAY_U16, GRAY_U8, Layout< T >::initialized(), NONE, normalizeFloat(), normalizeFloatRgb(), Layout< T >::render(), RGB_F32, RGB_U16, RGB_U8, and VideoFrame::toRgb().

Referenced by asRgb(), asRgbU8(), and ImageDisplayStream::writeFrame().

VideoFrame GenericFrame::asVideo  )  const
 

Get a video version of the frame, converting as necessary.

Definition at line 548 of file GenericFrame.C.

References GRAY_F32, GRAY_U16, GRAY_U8, VideoFrame::initialized(), NONE, Layout< T >::render(), RGB_F32, RGB_U16, and RGB_U8.

Referenced by IntegerInput::decode(), doRescale(), LuminanceOfilt::filterFrame(), ColorizeOfilt::filterFrame(), CoerceVideoFormatOfilt::filterFrame(), operator==(), HalfFieldDeinterlacer< BottomField >::readFrame(), BobDeinterlacer::readFrame(), Raster::ReadVideo(), QuartzQuickTimeDecoder::readVideoFrame(), dummy_namespace_to_avoid_gcc411_bug_DiskDataStream_C::DiskDumpJob::run(), DisplayController::setBackground(), submain(), HashOutputSeries::writeFrame(), YuvWriter::writeFrame(), UcbMpegEncoder::writeFrame(), MrawvEncoder::writeFrame(), MgzEncoder::writeFrame(), FfmpegEncoder::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 169 of file GenericFrame.C.

References VideoFrame::deepCopyOf(), itsFloatFlags, itsGrayF32, itsGrayU8, itsNativeType, itsRgbF32, itsRgbU8, and itsVideo.

Referenced by DiskDataStream::writeFrame().

int GenericFrame::floatFlags  )  const [inline]
 

Get the float-normalization flags.

Definition at line 149 of file GenericFrame.H.

Referenced by doResizeFrame(), LuminanceOfilt::filterFrame(), ColorizeOfilt::filterFrame(), QtImageFrame::setFrame(), PnmWriter::writeFrame(), PngWriter::writeFrame(), MrawvEncoder::writeFrame(), and MgzEncoder::writeFrame().

GenericFrameSpec GenericFrame::frameSpec  )  const
 

Get the frame's specifications.

Definition at line 183 of file GenericFrame.C.

References GenericFrameSpec::dims, GenericFrameSpec::floatFlags, VideoFrame::getByteSwap(), getDims(), VideoFrame::getMode(), GenericFrameSpec::nativeType, GenericFrameSpec::videoByteSwap, and GenericFrameSpec::videoFormat.

Referenced by LuminanceOfilt::filterFrame(), ColorizeOfilt::filterFrame(), QuartzQuickTimeParser::getFrameSpec(), nativeTypeName(), SequenceFileStream::peekFrameSpec(), MrawvInputStream::peekFrameSpec(), MgzInputStream::peekFrameSpec(), RasterlistInputSeries::readFrame(), InputFrameSeries::Impl::readFrame(), LowLevelEncoderMap::writeFrame(), and InfoOutputSeries::writeFrame().

Dims GenericFrame::getDims  )  const
 

Get the dimensions of the native image.

Definition at line 201 of file GenericFrame.C.

References ASSERT, VideoFrame::getDims(), Image< T >::getDims(), Layout< T >::getDims(), GRAY_F32, GRAY_U16, GRAY_U8, NONE, RGB_F32, RGB_U16, and RGB_U8.

Referenced by buildTitle(), doResizeFrame(), frameSpec(), getHeight(), getWidth(), main(), QtImageFrame::Impl::rawDims(), submain(), SimEventInputFrame::toString(), MgzEncoder::writeFrame(), SDLdisplayStream::writeFrame(), and ImageDisplayStream::writeFrame().

int GenericFrame::getHeight void   )  const [inline]
 

Get the height of the native image.

Definition at line 146 of file GenericFrame.H.

References getDims(), and Dims::h().

Referenced by DisplayController::setBackground().

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 597 of file GenericFrame.C.

References rutz::shared_ptr< T >::get(), and LFATAL.

Referenced by InferoTemporalSalBayes::attentionShift().

int GenericFrame::getWidth void   )  const [inline]
 

Get the width of the native image.

Definition at line 143 of file GenericFrame.H.

References getDims(), and Dims::w().

Referenced by DisplayController::setBackground().

bool GenericFrame::hasMetaData const std::string tag  )  const
 

Check whether we have a given piece of metadata.

Definition at line 589 of file GenericFrame.C.

References rutz::shared_ptr< T >::get().

Referenced by InferoTemporalSalBayes::attentionShift().

bool GenericFrame::initialized  )  const
 

Check if we have a valid non-empty image, regardless of format.

Definition at line 157 of file GenericFrame.C.

References ASSERT, and NONE.

Referenced by CT2WSRegionTrainerForm::ChangeFrame(), CT2WSRegionTrainerForm::fileOpen(), RetinaI::getFrame(), SubController::getImage(), main(), SequenceFileStream::peekFrameSpec(), MrawvInputStream::peekFrameSpec(), MgzInputStream::peekFrameSpec(), FrameIstream::readAndDiscardFrame(), SequenceFileStream::readFrame(), QuartzQuickTimeDecoder::readFrame(), MrawvInputStream::readFrame(), MgzInputStream::readFrame(), InputFrameSeries::Impl::readFrame(), submain(), BeoHeadBrain::updateEyesImage(), and Raster::WriteFrame().

NativeType GenericFrame::nativeType  )  const [inline]
 

Get the frame's native image type.

Definition at line 134 of file GenericFrame.H.

Referenced by buildTitle(), doRescale(), doResizeFrame(), LuminanceOfilt::filterFrame(), ColorizeOfilt::filterFrame(), main(), mexFunction(), operator==(), DisplayController::setBackground(), StatsOutputSeries::writeFrame(), RasterOutputSeries::writeFrame(), HashOutputSeries::writeFrame(), RawWriter::writeFrame(), PnmWriter::writeFrame(), PngWriter::writeFrame(), PlaintextWriter::writeFrame(), PfzWriter::writeFrame(), CcodeWriter::writeFrame(), MgzEncoder::writeFrame(), FfmpegEncoder::writeFrame(), SDLdisplayStream::writeFrame(), and ImageDisplayStream::writeFrame().

std::string GenericFrame::nativeTypeName  )  const
 

Get the frame's native image typename.

Definition at line 195 of file GenericFrame.C.

References frameSpec(), and GenericFrameSpec::nativeTypeName().

Referenced by buildTitle(), SimEventInputFrame::toString(), StatsOutputSeries::writeFrame(), HashOutputSeries::writeFrame(), and MgzEncoder::writeFrame().

void GenericFrame::setFloatFlags int  v  ) 
 

Change the float-normalization flags.

Definition at line 219 of file GenericFrame.C.

References GRAY_F32, and RGB_F32.

Referenced by QtImageFrame::setFrame(), and MrawvEncoder::writeFrame().


The documentation for this class was generated from the following files:
Generated on Sun Nov 22 13:45:47 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4