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

DrawOps.H File Reference


Detailed Description

functions for drawing on images

Definition in file DrawOps.H.

#include "Util/Types.H"
#include "Image/SimpleFont.H"
#include "Image/Pixels.H"
#include <string>
#include <vector>

Include dependency graph for DrawOps.H:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MeterInfo
 Simple struct to define a bargraph meter. More...

Enumerations

enum  TextAnchor { ANCHOR_TOP_LEFT, ANCHOR_TOP_RIGHT, ANCHOR_BOTTOM_LEFT, ANCHOR_BOTTOM_RIGHT }

Functions

void drawTraj (Image< PixRGB< byte > > &img, const Point2D< int > *foas_begin, const Point2D< int > *foas_end)
 draw the trajectory for the points in foas onto img
Image< PixRGB< byte > > colGreyCombo (const Image< PixRGB< byte > > &colimg, const Image< float > &bwimg, const bool xcombo, const bool interp=true)
 build a combo between a color and greyscale image
Image< PixRGB< byte > > colColCombo (const Image< PixRGB< byte > > &colimg1, const Image< PixRGB< byte > > &colimg2, const bool xcombo, const bool interp=true)
 build a combo between a color and color image
Image< PixRGB< byte > > highlightRegions (const Image< PixRGB< byte > > &img, const Image< byte > &mask, const int maxval=320)
 highlight an image in the regions given by a mask
Image< PixRGB< byte > > warp3Dmap (const Image< PixRGB< byte > > &img, const Image< float > &hmap, const float pitch, const float yaw, Dims &imdims)
 warp image onto height map
void inplaceSetValMask (Image< float > &dest, const Image< byte > &mask, const float val)
 Set values at all locations where mask is non-zero.
template<class T_or_RGB>
void drawDisk (Image< T_or_RGB > &dst, const Point2D< int > &center, const int radius, const T_or_RGB value)
 Draws a disk with color "value" in image.
template<class T_or_RGB>
void drawLine (Image< T_or_RGB > &dst, const Point2D< int > &p1, const Point2D< int > &p2, const T_or_RGB col, const int rad=1)
 Draw a line from p1 to p2 of color col and pixel radius rad.
template<class T_or_RGB>
void drawLine (Image< T_or_RGB > &dst, const Point2D< int > &pos, float ori, float len, const T_or_RGB col, const int rad=1)
 Draw a line at pos angle ori(rad) and length len.
template<class T_or_RGB>
void drawCorner (Image< T_or_RGB > &dst, const Point2D< int > &pos, float ori, float ang, float len, const T_or_RGB col, const int rad=1)
 Draw a corner at pos and ori with an ang.
template<class T_or_RGB>
void drawRect (Image< T_or_RGB > &dst, const Rectangle &rect, const T_or_RGB col, const int rad=1)
 Draw a rectangle of color col and line width of rad*2, with rounded corners.
template<class T_or_RGB>
void drawRectSquareCorners (Image< T_or_RGB > &dst, const Rectangle &r, const T_or_RGB color, const int linewidth)
 Draw a rectangle of the given color and line width, with square corners.
template<class T_or_RGB>
void drawRectOR (Image< T_or_RGB > &dst, const Rectangle &rect, const T_or_RGB col, const int rad=1, const float ori=0.0F)
 Draw a rectangle of color col and pixel radius rad, rotate by ori.
template<class T_or_RGB>
void drawRectEZ (Image< T_or_RGB > &dst, const Rectangle &rect, const T_or_RGB col, const int rad=1)
 Draw a rectangle of color col and pixel radius rad, no size assertions.
template<class T_or_RGB>
void drawFilledRect (Image< T_or_RGB > &dst, const Rectangle &rect, const T_or_RGB fillVal)
 Draw a filled rectangle with the given fill value.
template<class T_or_RGB>
void drawCross (Image< T_or_RGB > &dst, const Point2D< int > &p, const T_or_RGB col, const int siz=3, const int rad=1)
 Draw a cross of color col, half-size siz and pixel radius rad.
template<class T_or_RGB>
void drawCrossOR (Image< T_or_RGB > &dst, const Point2D< int > &p, const T_or_RGB col, const int siz=3, const int rad=1, const float ori=0.0F)
 Draw a cross of color col, half-size siz and pixel radius rad.
template<class T_or_RGB>
void drawPatch (Image< T_or_RGB > &dst, const Point2D< int > &p, const int siz, const T_or_RGB col)
 Draw a square patch of color col and size siz.
template<class T_or_RGB>
void drawPatchBB (Image< T_or_RGB > &dst, const Point2D< int > &p, const int siz, const T_or_RGB col, const T_or_RGB bgcol=T_or_RGB())
 Draw a square patch of color col and size siz, with a black border.
template<class T_or_RGB>
void drawCircle (Image< T_or_RGB > &dst, const Point2D< int > &p, const int radius, const T_or_RGB col, const int rad=1)
 Draw a circle of color col and radius radius, with pixel radius rad.
template<class T_or_RGB>
void drawArrow (Image< T_or_RGB > &dst, const Point2D< int > &p1, const Point2D< int > &p2, const T_or_RGB col, const int rad=1)
 Draw an arrow from p1 to p2 with pixel radius rad.
template<class T_or_RGB>
void drawGrid (Image< T_or_RGB > &dst, const int spacingX, const int spacingY, const int thickX, const int thickY, const T_or_RGB col)
 Draw a grid.
template<class T_or_RGB>
void drawGrid (Image< T_or_RGB > &dst, const uint nx, const uint ny, const int thick, const T_or_RGB col)
 Draw an nx * ny grid that exactly partitions the given image.
template<class T, class T_or_RGB>
void drawContour2D (const Image< T > &src, Image< T_or_RGB > &dst, const T_or_RGB &col, const byte rad)
 Draw a 2D contour.
template<class T_or_RGB>
void writeText (Image< T_or_RGB > &dst, const Point2D< int > &pt, const char *text, const T_or_RGB col=T_or_RGB(), const T_or_RGB bgcol=T_or_RGB(255), const SimpleFont &f=SimpleFont::FIXED(10), const bool transparent_bg=false, const TextAnchor anchor=ANCHOR_TOP_LEFT)
 Write some text in normal font; only ASCII chars 32 .. 126 are supported.
template<class T_or_RGB>
Image< T_or_RGB > makeMultilineTextBox (const int w, const std::string *lines, const size_t nlines, const T_or_RGB col, const T_or_RGB bg=T_or_RGB(), const size_t max_chars_per_line=0, const int fontwidth=0)
 Make an image containing one or more lines of text.
template<class T_or_RGB>
void drawPoint (Image< T_or_RGB > &dst, int X, int Y, T_or_RGB pix)
 draw a dot which is a point with 4 connected points
template<class T>
int drawDiskCheckTarget (Image< T > &dst, Image< T > &mask, const Point2D< int > &center, const int radius, const T value, const T targetval, const T floodval)
 Draws a disk in image and check if it hits a target.
template<class T>
Image< PixRGB< T > > warp3D (const Image< PixRGB< T > > &ima, const Image< float > &zmap, const float pitch, const float yaw, const float zMax, Dims &dims)
 Warp image in 3D onto z-map.
Image< PixRGB< byte > > formatMapForDisplay (const Image< float > &img, const float factor, const Dims &newdims, const bool useInterp, const ColorMap &cmap, const bool showColorScale, const char *label)
 Format a feature map for display.
template<typename T, class U>
Image< PixRGB< byte > > linePlot (const U &points, const int w, const int h, T minVal=T(), T maxVal=T(), const char *title="", const char *xLabel="", const char *yLabel="", const PixRGB< byte > &linecol=PixRGB< byte >(0, 0, 0), const PixRGB< byte > &bckcol=PixRGB< byte >(255, 255, 255))
 Generate a plot from a vector of points.
template<class T_or_RGB>
void drawFilledPolygon (Image< T_or_RGB > &img, const std::vector< Point2D< int > > &polygon, const T_or_RGB col)
 Draw a filled polygon with color col inside the polygon, no change outside.
Image< PixRGB< byte > > drawMeters (const MeterInfo *infos, const size_t ninfo, const size_t nx, const Dims &meterdims)
 Draw some bargraph meters.


Function Documentation

Image< PixRGB<byte> > colColCombo const Image< PixRGB< byte > > &  colimg1,
const Image< PixRGB< byte > > &  colimg2,
const bool  xcombo,
const bool  interp = true
 

build a combo between a color and color image

Parameters:
colimg1 the color image (e.g., trajectory + saliency map)
colimg2 the second color image (e.g., the scene highlighted by TRM)
xcombo will combine horizontally if true, otherwise vertically
interp use bilinear interpolation for any image rescaling

Image< PixRGB<byte> > colGreyCombo const Image< PixRGB< byte > > &  colimg,
const Image< float > &  bwimg,
const bool  xcombo,
const bool  interp = true
 

build a combo between a color and greyscale image

Parameters:
colimg the color image (e.g., trajectory)
bwimg the greyscale image (e.g., saliency map)
xcombo will combine horizontally if true, otherwise vertically
interp use bilinear interpolation for any image rescaling

template<class T_or_RGB>
void drawArrow Image< T_or_RGB > &  dst,
const Point2D< int > &  p1,
const Point2D< int > &  p2,
const T_or_RGB  col,
const int  rad = 1
 

Draw an arrow from p1 to p2 with pixel radius rad.

template<class T_or_RGB>
void drawCircle Image< T_or_RGB > &  dst,
const Point2D< int > &  p,
const int  radius,
const T_or_RGB  col,
const int  rad = 1
 

Draw a circle of color col and radius radius, with pixel radius rad.

template<class T, class T_or_RGB>
void drawContour2D const Image< T > &  src,
Image< T_or_RGB > &  dst,
const T_or_RGB &  col,
const byte  rad
 

Draw a 2D contour.

Will draw a disk of color col and radius rad in dst at every point where src is on a contour. dst should be initialized ahd have same dims as src. Nothing is drawn for point off contours.

template<class T_or_RGB>
void drawCorner Image< T_or_RGB > &  dst,
const Point2D< int > &  pos,
float  ori,
float  ang,
float  len,
const T_or_RGB  col,
const int  rad = 1
 

Draw a corner at pos and ori with an ang.

template<class T_or_RGB>
void drawCross Image< T_or_RGB > &  dst,
const Point2D< int > &  p,
const T_or_RGB  col,
const int  siz = 3,
const int  rad = 1
 

Draw a cross of color col, half-size siz and pixel radius rad.

template<class T_or_RGB>
void drawCrossOR Image< T_or_RGB > &  dst,
const Point2D< int > &  p,
const T_or_RGB  col,
const int  siz = 3,
const int  rad = 1,
const float  ori = 0.0F
 

Draw a cross of color col, half-size siz and pixel radius rad.

template<class T_or_RGB>
void drawDisk Image< T_or_RGB > &  dst,
const Point2D< int > &  center,
const int  radius,
const T_or_RGB  value
 

Draws a disk with color "value" in image.

template<class T>
int drawDiskCheckTarget Image< T > &  dst,
Image< T > &  mask,
const Point2D< int > &  center,
const int  radius,
const T  value,
const T  targetval,
const T  floodval
 

Draws a disk in image and check if it hits a target.

Parameters:
mask input binary target mask to draw into
center coordinates of disk center
radius radisu of disk, in pixels
value pixel value used to draw the disk
targetval value with which the targets are represented
floodval value to flood target with if target hit
Returns:
number of targets hit and flooded

template<class T_or_RGB>
void drawFilledPolygon Image< T_or_RGB > &  img,
const std::vector< Point2D< int > > &  polygon,
const T_or_RGB  col
 

Draw a filled polygon with color col inside the polygon, no change outside.

template<class T_or_RGB>
void drawFilledRect Image< T_or_RGB > &  dst,
const Rectangle rect,
const T_or_RGB  fillVal
 

Draw a filled rectangle with the given fill value.

template<class T_or_RGB>
void drawGrid Image< T_or_RGB > &  dst,
const uint  nx,
const uint  ny,
const int  thick,
const T_or_RGB  col
 

Draw an nx * ny grid that exactly partitions the given image.

template<class T_or_RGB>
void drawGrid Image< T_or_RGB > &  dst,
const int  spacingX,
const int  spacingY,
const int  thickX,
const int  thickY,
const T_or_RGB  col
 

Draw a grid.

template<class T_or_RGB>
void drawLine Image< T_or_RGB > &  dst,
const Point2D< int > &  pos,
float  ori,
float  len,
const T_or_RGB  col,
const int  rad = 1
 

Draw a line at pos angle ori(rad) and length len.

template<class T_or_RGB>
void drawLine Image< T_or_RGB > &  dst,
const Point2D< int > &  p1,
const Point2D< int > &  p2,
const T_or_RGB  col,
const int  rad = 1
 

Draw a line from p1 to p2 of color col and pixel radius rad.

Image<PixRGB<byte> > drawMeters const MeterInfo infos,
const size_t  ninfo,
const size_t  nx,
const Dims meterdims
 

Draw some bargraph meters.

Definition at line 1156 of file DrawOps.C.

References ASSERT, Image< T >::beginw(), clampValue(), color, SimpleFont::fixedMaxHeight(), Image< T >::getWidth(), Dims::h(), i, MeterInfo::label, sformat(), MeterInfo::thresh, MeterInfo::val, MeterInfo::valmax, SimpleFont::w(), Dims::w(), writeText(), x, y, and ZEROS.

Referenced by Nv2UiJob::makeMeters().

template<class T_or_RGB>
void drawPatch Image< T_or_RGB > &  dst,
const Point2D< int > &  p,
const int  siz,
const T_or_RGB  col
 

Draw a square patch of color col and size siz.

template<class T_or_RGB>
void drawPatchBB Image< T_or_RGB > &  dst,
const Point2D< int > &  p,
const int  siz,
const T_or_RGB  col,
const T_or_RGB  bgcol = T_or_RGB()
 

Draw a square patch of color col and size siz, with a black border.

template<class T_or_RGB>
void drawPoint Image< T_or_RGB > &  dst,
int  X,
int  Y,
T_or_RGB  pix
 

draw a dot which is a point with 4 connected points

this is between the setVal method and drawCircle method for illustrating points

template<class T_or_RGB>
void drawRect Image< T_or_RGB > &  dst,
const Rectangle rect,
const T_or_RGB  col,
const int  rad = 1
 

Draw a rectangle of color col and line width of rad*2, with rounded corners.

template<class T_or_RGB>
void drawRectEZ Image< T_or_RGB > &  dst,
const Rectangle rect,
const T_or_RGB  col,
const int  rad = 1
 

Draw a rectangle of color col and pixel radius rad, no size assertions.

template<class T_or_RGB>
void drawRectOR Image< T_or_RGB > &  dst,
const Rectangle rect,
const T_or_RGB  col,
const int  rad = 1,
const float  ori = 0.0F
 

Draw a rectangle of color col and pixel radius rad, rotate by ori.

template<class T_or_RGB>
void drawRectSquareCorners Image< T_or_RGB > &  dst,
const Rectangle r,
const T_or_RGB  color,
const int  linewidth
 

Draw a rectangle of the given color and line width, with square corners.

void drawTraj Image< PixRGB< byte > > &  img,
const Point2D< int > *  foas_begin,
const Point2D< int > *  foas_end
 

draw the trajectory for the points in foas onto img

Yellow circles and red arrows are drawn, connecting the points in foas.

Parameters:
foas a vector with the foci of attention ised for drawing

Image< PixRGB<byte> > formatMapForDisplay const Image< float > &  img,
const float  factor,
const Dims newdims,
const bool  useInterp,
const ColorMap cmap,
const bool  showColorScale,
const char *  label
 

Format a feature map for display.

Take an Image<float> feature map as input and convert it to PixRGB<byte> by either multiplying the values by a factor or by normalizing them to 0 .. 255 (if factor is 0.0), and then using a given color map (which will also be displayed if showColorScale is true). Then rescale to the specified dims, using interpolation if desired. Then write a descriptor label in the top-left corner using a large font, and finally show the original range of values in the bottom-right corner uing a tiny font.

Image< PixRGB<byte> > highlightRegions const Image< PixRGB< byte > > &  img,
const Image< byte > &  mask,
const int  maxval = 320
 

highlight an image in the regions given by a mask

void inplaceSetValMask Image< float > &  dest,
const Image< byte > &  mask,
const float  val
 

Set values at all locations where mask is non-zero.

template<typename T, class U>
Image< PixRGB<byte> > linePlot const U &  points,
const int  w,
const int  h,
minVal = T(),
maxVal = T(),
const char *  title = "",
const char *  xLabel = "",
const char *  yLabel = "",
const PixRGB< byte > &  linecol = PixRGBbyte >(0, 0, 0),
const PixRGB< byte > &  bckcol = PixRGBbyte >(255, 255, 255)
 

Generate a plot from a vector of points.

template<class T_or_RGB>
Image<T_or_RGB> makeMultilineTextBox const int  w,
const std::string lines,
const size_t  nlines,
const T_or_RGB  col,
const T_or_RGB  bg = T_or_RGB(),
const size_t  max_chars_per_line = 0,
const int  fontwidth = 0
 

Make an image containing one or more lines of text.

The function will choose a font width that fits the desired image size.

Parameters:
w the desired width (in pixels) of the resulting image
lines an array of strings to be written in the result, one line per string
nlines the number of strings in the string array
col the foreground color for the written text
bg the background color for the written text
max_chars_per_line if non-zero, then each line of text will be truncated at this many characters
fontwidth the max font width unless it is zero, in which case it will be determined automatically to fit the text in the box.

template<class T>
Image<PixRGB<T> > warp3D const Image< PixRGB< T > > &  ima,
const Image< float > &  zmap,
const float  pitch,
const float  yaw,
const float  zMax,
Dims dims
 

Warp image in 3D onto z-map.

Parameters:
ima Input image
zmap Height map of same size as ima
pitch 3D pitch angle, in degrees
yaw 3D yaw angle, in degrees
dims The result will have these dimensions, unless the dimensions are empty (i.e. 0-by-0), in which case the result will be the best size computed from ima's size and the pitch and yaw angles.

Image< PixRGB<byte> > warp3Dmap const Image< PixRGB< byte > > &  img,
const Image< float > &  hmap,
const float  pitch,
const float  yaw,
Dims imdims
 

warp image onto height map

template<class T_or_RGB>
void writeText Image< T_or_RGB > &  dst,
const Point2D< int > &  pt,
const char *  text,
const T_or_RGB  col = T_or_RGB(),
const T_or_RGB  bgcol = T_or_RGB(255),
const SimpleFont f = SimpleFont::FIXED(10),
const bool  transparent_bg = false,
const TextAnchor  anchor = ANCHOR_TOP_LEFT
 

Write some text in normal font; only ASCII chars 32 .. 126 are supported.

See Image/SimpleFont.H for font choices.


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