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

ColorOps.C File Reference


Detailed Description

Color operations on Image

Definition in file ColorOps.C.

#include "Image/ColorOps.H"
#include "Image/ColorMap.H"
#include "Image/FilterOps.H"
#include "Image/Image.H"
#include "Image/MathOps.H"
#include "Image/Pixels.H"
#include "Image/ShapeOps.H"
#include "Image/Transforms.H"
#include "Util/Assert.H"
#include "Util/MathFunctions.H"
#include "Util/log.H"
#include "rutz/trace.h"
#include <algorithm>
#include <cmath>
#include "inst/Image/ColorOps.I"

Include dependency graph for ColorOps.C:

Go to the source code of this file.

Functions

template<class T>
Image< PixRGB< T > > makeRGB (const Image< T > &red, const Image< T > &green, const Image< T > &blue)
 Set the red, green and blue components from 3 monochromatic images.
Image< PixRGB< byte > > colorize (const Image< byte > &img, const ColorMap &cmap)
void inplaceColorSpeckleNoise (Image< PixRGB< byte > > &dest, const int num)
template<class T>
void getComponents (const Image< PixRGB< T > > &src, Image< T > &red, Image< T > &green, Image< T > &blue)
 Get the red, green and blue components as 3 monochromatic images.
Image< PixRGB< float > > normalizeRGPolar (const Image< float > &src, const float max, const float min)
Image< PixRGB< float > > normalizeRGPolarAuto (const Image< float > &src)
Image< PixRGB< float > > normalizeWithScale (const Image< float > &src, const float min=0.0F, const float max=255.0F, const float clamp=255.0F, const char baseColor=1, const char normColor=3)
Image< PixRGB< float > > normalizeScaleRainbow (const Image< float > &src, const float min=0.0F, const float max=255.0F)
template<class T>
Image< PixRGB< T > > stain (const Image< T > &src, PixRGB< float > color)
Image< PixRGB< float > > stainPosNeg (const Image< float > &src, const float maxval, const PixRGB< float > &background, const PixRGB< float > &pos_stain, const PixRGB< float > &neg_stain)
Image< PixRGB< float > > overlayStain (const Image< float > &top, const Image< float > &bottom, const float trans, const char channel)
template<class T>
void getMinMaxC (const Image< PixRGB< T > > &src, T &mi, T &ma)
 Get min and max of the components.
template<>
Image< byteluminance (const Image< PixRGB< byte > > &src)
template<class T>
Image< T > luminance (const Image< PixRGB< T > > &src)
 Compute luminance of a color image.
template<class T>
Image< T > luminance (const Image< T > &src)
 Compute luminance of a greyscale image (no-op).
template<class T>
Image< T > luminanceNTSC (const Image< PixRGB< T > > &src)
 Compute luminance in NTSC coordinates.
template<class T>
Image< PixRGB< T > > toRGB (const Image< T > &src)
 Convert grayscale image to RGB.
template<class T>
Image< PixRGB< T > > toRGB (const Image< PixRGB< T > > &src)
 Convert RGB image to RGB (no-op).
template<class T>
Image< float > infoMeasure (const Image< PixRGB< T > > &src, const float eps, const int size)
 Compute color information measure based in infoFFT.
template<class T>
void getYIQ (const Image< PixRGB< T > > &src, Image< T > &y, Image< T > &i, Image< T > &q)
 Get YIQ color components.
template<class T>
void getJpegYUV (const Image< PixRGB< T > > &src, Image< T > &y, Image< T > &u, Image< T > &v)
 Get YUV color components from an RGB image.
template<class T>
Image< PixRGB< T > > luminanceNormalize (const Image< PixRGB< T > > &src, const T thresh)
 Normalize my values by those in the lum image.
template<class T>
void getRGBY (const Image< PixRGB< T > > &src, Image< typename promote_trait< T, float >::TP > &rg, Image< typename promote_trait< T, float >::TP > &by, const typename promote_trait< T, float >::TP thresh)
template<class T>
void getRGBYsimple (const Image< PixRGB< T > > &src, Image< typename promote_trait< T, float >::TP > &rg, Image< typename promote_trait< T, float >::TP > &by, const typename promote_trait< T, float >::TP thresh)
template<class T>
void getRGBY (const Image< PixRGB< T > > &src, Image< T > &rr, Image< T > &gg, Image< T > &bb, Image< T > &yy, const T thresh)
 Compute R, G, B, Y channels from a luminanceNormalized color image.
template<class T>
void getRGBY (const Image< PixRGB< T > > &src, Image< T > &rg, Image< T > &by, Image< T > &sat, Image< T > &val, const ushort H2SVtype)
 Compute R/G and B/Y via computation of H2SV2 color space.
template<class T>
void getDKL (const Image< PixRGB< T > > &src, Image< typename promote_trait< T, float >::TP > &dimg, Image< typename promote_trait< T, float >::TP > &kimg, Image< typename promote_trait< T, float >::TP > &limg)
 Compute D, K, L color components from an RGB image.
Image< PixRGB< byte > > contrastModulate (const Image< PixRGB< byte > > &img, const Image< float > &mask, float baseContrast, byte baseBright)
template<class T>
double pSNRcolor (const Image< PixRGB< T > > &img1, const Image< PixRGB< T > > &img2)
 Compute peak signal-to-noise ratio between two color images.
template<class T>
double pSNRcolor (const Image< PixRGB< T > > &img1, const Image< PixRGB< T > > &img2, const Image< float > &weight)
template<class T>
Image< PixRGB< T > > normalizeRGB (const Image< PixRGB< T > > &img, PixRGB< T > min, PixRGB< T > max)
 Normalize each component of the RGB image separately.
template<class T>
Image< T > maxRGB (const Image< PixRGB< T > > &img)
 Return the pixel-wise maximum of the r, g and b component.
template<class T>
Image< PixRGB< T > > colorStain (const Image< T > &src, const T &min, const T &max, const PixRGB< T > &color)
 Stain a black and white image with a color.
void RGBtoCIE (const PixRGB< byte > &rgbColor, float &cr, float &cg, float &intens)
Image< float > hueDistance (const Image< PixRGB< byte > > &img, float muR, float muG, float sigR, float sigG, float rho)
template void getMinMaxC (const Image< PixRGB< int > > &src, int &mi, int &ma)
template void getMinMaxC (const Image< PixRGB< double > > &src, double &mi, double &ma)


Function Documentation

template<class T>
Image< PixRGB<T> > colorStain const Image< T > &  src,
const T &  min,
const T &  max,
const PixRGB< T > &  color
 

Stain a black and white image with a color.

Parameters:
src the black and white image to be stained
min This value will be converted to 0 (black)
max This value will be converted to color
color The color used for staining

Definition at line 918 of file ColorOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::end(), Image< T >::getDims(), GVX_TRACE, NO_INIT, and lobot::stop().

Referenced by main().

template<class T>
void getComponents const Image< PixRGB< T > > &  src,
Image< T > &  red,
Image< T > &  green,
Image< T > &  blue
 

Get the red, green and blue components as 3 monochromatic images.

Definition at line 122 of file ColorOps.C.

References ASSERT, Image< T >::beginw(), GVX_TRACE, NO_INIT, src, and lobot::stop().

Referenced by RGBConvolvePyrBuilder< T >::build(), RGBConvolvePyrBuilder< T >::build2(), ImagizeColorChannel::doInput(), SplitRgbOfilt::filterFrame(), main(), maxRGB(), normalizeRGB(), StatsOutputSeries::Impl::printStatsRGB(), pSNRcolor(), Raster_xx_img_gray_write_gray_read_rgb_xx_1(), Raster_xx_img_gray_write_rgb_read_rgb_xx_1(), and rectifyRgb().

template<class T>
void getDKL const Image< PixRGB< T > > &  src,
Image< typename promote_trait< T, float >::TP > &  dimg,
Image< typename promote_trait< T, float >::TP > &  kimg,
Image< typename promote_trait< T, float >::TP > &  limg
 

Compute D, K, L color components from an RGB image.

The DKL color space is motivated by the neurobiology of early vision in primates. D is roughly like luminance (with some neutral grey (RGB=[161 159 154]) at zero, white around 1.0, and black around -1.0), K roughly like Red-Green, and L roughly like Blue-Yellow. The images returned here have signed float values roughly in [-1,1] (but they sometimes are slightly larger that exactly that, so be sure to clamp if you ar egoing to convert).

Definition at line 809 of file ColorOps.C.

References ASSERT, PixDKL< T >::D(), GVX_TRACE, PixDKL< T >::K(), PixDKL< T >::L(), NO_INIT, p, src, and lobot::stop().

Referenced by DKLcolorChannel::doInput().

template<class T>
void getJpegYUV const Image< PixRGB< T > > &  src,
Image< T > &  y,
Image< T > &  u,
Image< T > &  v
[inline]
 

Get YUV color components from an RGB image.

Definition at line 545 of file ColorOps.C.

References ASSERT, Image< T >::beginw(), GVX_TRACE, NO_INIT, src, lobot::stop(), PixJpegYUV< T >::U(), PixJpegYUV< T >::V(), and PixJpegYUV< T >::Y().

template<class T>
void getMinMaxC const Image< PixRGB< T > > &  src,
T &  mi,
T &  ma
 

Get min and max of the components.

Definition at line 352 of file ColorOps.C.

References ASSERT, GVX_TRACE, src, lobot::stop(), and x.

Referenced by buildTitle(), normalizeC(), normalizeFloatRgb(), and Raster::VisuRGB().

template<class T>
void getRGBY const Image< PixRGB< T > > &  src,
Image< T > &  rg,
Image< T > &  by,
Image< T > &  sat,
Image< T > &  val,
const ushort  H2SVtype = 2
 

Compute R/G and B/Y via computation of H2SV2 color space.

In addition to returning R/G and B/Y this basically returns the full H2SV color space. the original RGB can be obtained later via conversion of rg,by, sat and val using a PixH2SV2 to RGB

Definition at line 769 of file ColorOps.C.

References ASSERT, Image< T >::beginw(), GVX_TRACE, PixH2SV1< T >::H1(), PixH2SV2< T >::H1(), PixH2SV1< T >::H2(), PixH2SV2< T >::H2(), LFATAL, NO_INIT, PixH2SV1< T >::S(), PixH2SV2< T >::S(), src, PixH2SV1< T >::V(), and PixH2SV2< T >::V().

template<class T>
void getRGBY const Image< PixRGB< T > > &  src,
Image< T > &  r,
Image< T > &  g,
Image< T > &  b,
Image< T > &  y,
const T  thresh
 

Compute R, G, B, Y channels from a luminanceNormalized color image.

This version keeps the four channels separate so that correct results can be obtained without requiring promotion even if the input is of type PixRGB<byte>

Definition at line 709 of file ColorOps.C.

template<class T>
void getYIQ const Image< PixRGB< T > > &  src,
Image< T > &  y,
Image< T > &  i,
Image< T > &  q
[inline]
 

Get YIQ color components.

Definition at line 517 of file ColorOps.C.

References ASSERT, Image< T >::beginw(), GVX_TRACE, iptr, NO_INIT, src, and lobot::stop().

Referenced by infoMeasure().

template<class T>
Image<float> infoMeasure const Image< PixRGB< T > > &  src,
const float  eps,
const int  size
 

Compute color information measure based in infoFFT.

Definition at line 477 of file ColorOps.C.

References ASSERT, countThresh(), dct(), decXY(), getYIQ(), GVX_TRACE, i, lowPass3(), NO_INIT, Image< T >::setVal(), src, and y.

Referenced by InformationChannel::doInput().

template<class T>
Image<T> luminance const Image< T > &  src  ) 
 

Compute luminance of a greyscale image (no-op).

This no-op overload is provided so that luminance() can be applied to template images where it is not known whether the template argument is scalar or PixRGB.

Definition at line 421 of file ColorOps.C.

template<class T>
Image<T> luminance const Image< PixRGB< T > > &  src  ) 
 

Compute luminance of a color image.

Definition at line 401 of file ColorOps.C.

template<class T>
Image<PixRGB<T> > luminanceNormalize const Image< PixRGB< T > > &  src,
const T  thresh
 

Normalize my values by those in the lum image.

Definition at line 572 of file ColorOps.C.

References ASSERT, Image< T >::beginw(), GVX_TRACE, NO_INIT, src, and lobot::stop().

template<class T>
Image<T> luminanceNTSC const Image< PixRGB< T > > &  src  ) 
 

Compute luminance in NTSC coordinates.

This version performs the same function as rgb2gray() in matlab

Definition at line 427 of file ColorOps.C.

References ASSERT, Image< T >::beginw(), Image< T >::endw(), GVX_TRACE, NO_INIT, lobot::round(), src, and lobot::stop().

Referenced by GenericFrame::asGrayU8NTSCLayout(), and InferoTemporalHmax::attentionShift().

template<class T>
Image<PixRGB<T> > makeRGB const Image< T > &  red,
const Image< T > &  green,
const Image< T > &  blue
 

Set the red, green and blue components from 3 monochromatic images.

Definition at line 61 of file ColorOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::endw(), Image< T >::getDims(), GVX_TRACE, Image< T >::isSameSize(), NO_INIT, and lobot::stop().

Referenced by RGBConvolvePyrBuilder< T >::build2(), colGreyCombo(), SimulationViewerStd::drawMegaCombo(), SimulationViewerNerdCam::drawMegaCombo(), getImage(), getSalDispImg(), greyWorldNormalize(), main(), normalizeRGB(), rectifyRgb(), and submain().

template<class T>
Image<T> maxRGB const Image< PixRGB< T > > &  img  ) 
 

Return the pixel-wise maximum of the r, g and b component.

Definition at line 908 of file ColorOps.C.

References getComponents(), GVX_TRACE, and takeMax().

Referenced by main().

template<class T>
Image< PixRGB<T> > normalizeRGB const Image< PixRGB< T > > &  img,
PixRGB< T >  min,
PixRGB< T >  max
 

Normalize each component of the RGB image separately.

Normalize the red component with min.red() and max.red() etc.

Definition at line 893 of file ColorOps.C.

References PixRGB< T >::blue(), getComponents(), PixRGB< T >::green(), GVX_TRACE, inplaceNormalize(), makeRGB(), and PixRGB< T >::red().

Referenced by ScaleSurpriseControl< FLOAT >::SSCgetDiffImage(), and ScaleSurpriseControl< FLOAT >::SSCgetSeperableParts().

template<class T>
double pSNRcolor const Image< PixRGB< T > > &  img1,
const Image< PixRGB< T > > &  img2
 

Compute peak signal-to-noise ratio between two color images.

For color images, pSNR computed from the average mean-squared-error from the red, green and blue channels

Definition at line 856 of file ColorOps.C.

Referenced by main().

template<class T>
Image< PixRGB<T> > toRGB const Image< PixRGB< T > > &  src  ) 
 

Convert RGB image to RGB (no-op).

This no-op function is provided so that toRGB() can be applied to template images where it is not known whether the template argument is scalar or PixRGB.

Definition at line 472 of file ColorOps.C.

References src.

template<class T>
Image< PixRGB<T> > toRGB const Image< T > &  src  ) 
 

Convert grayscale image to RGB.

Definition at line 455 of file ColorOps.C.

Referenced by MotionEnergyPyrBuilder< T >::buildVerticalMotionLevel(), ShapeModel::calcDist(), HippocampusI::displayMap(), dispResults(), BeoSubBin::getBinSceneMass(), V4d::getDebugImage(), V4::getDebugImage(), V2::getDebugImage(), V1::getDebugImage(), SMap::getDebugImage(), Regions::getDebugImage(), PCamera::getDebugImage(), LGN::getDebugImage(), IT::getDebugImage(), Geons2D::getDebugImage(), Ganglion::getDebugImage(), Contour::getDebugImage(), BeoSubPipe::getHoughLines(), BeoSubBin::getHoughLines(), SimulationViewerStd::getTraj(), SimulationViewerEyeMvt::getTraj(), SimulationViewerCompress::getTraj(), main(), BeoSubPipe::pipeOrientation(), LateralGeniculateNucleusI::run(), SimulationViewerI::run(), MissileLauncher::run(), ImageCanvas::setImage(), V4d::showParticles(), BiasImageForm::showSMap(), submain(), updateDisplay(), and StraightEdgeFinder::updateFrame().


Generated on Sun Nov 22 13:44:03 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4