#include <picture.h>
Public Member Functions | |
int | ismonochrome () const |
colour_picture_of_ (const char *pnmname, const int bord=DEFAULT_BORDER) | |
colour_picture_of_ (const int r, const int c, const int bord=DEFAULT_BORDER, const int forcetomono=0) | |
template<typename OTHERPEL> | colour_picture_of_ (const colour_picture_of_< OTHERPEL > &source) |
Conventional copy constructor. | |
template<typename OTHERPEL> | colour_picture_of_ (const picture_of_< OTHERPEL > &source) |
Creates a colour_picture_of_ from a picture_of_, so loads up mono only. | |
colour_picture_of_ (const colour_picture_of_< PEL > &source, PEL(*f)(PEL &, const PEL &)) | |
colour_picture_of_ (colour_picture_of_< PEL > &source, PEL(*f)(PEL &, const PEL **)) | |
int | read (const char *ppmname) |
int | write (const char *ppmname) |
int | aptwrite (const char *aptname, const int quality=100) |
int | bmpwrite (const char *bmpname) |
Write picture in BMP format. If you must. | |
~colour_picture_of_ () | |
Destructor. | |
template<typename OTHERPEL> colour_picture_of_< PEL > & | operator= (const picture_of_< OTHERPEL > &rb) |
PEL | point (PEL(*f)(PEL &)) |
Apply callback point function *f() over picture, modifying itself. | |
PEL | point (const colour_picture_of_ &rb, PEL(*f)(PEL &, const PEL &)) |
PEL | neigh (colour_picture_of_ &rb, PEL(*f)(PEL &, const PEL **)) |
void | dc_pad () |
void | zero_border () |
Set values in the border of the picture to zero. | |
int | nrows () const |
Return number of rows in picture. | |
int | ncols () const |
Return number of columns in picture. | |
int | bordersize () |
Return width of border. | |
PEL | max () const |
Return maximum value in picture. | |
void | max (const PEL clipval) |
Clip picture at given maximum value. | |
PEL | min () const |
Return minimum value in picture. | |
void | min (const PEL clipval) |
Clip picture at given minimum value. | |
PEL | total () const |
Return total of all pel values. | |
int | rerange (const PEL newlow, const PEL newhigh, const bool scale_even_if_inside_range=0) |
void | map (const int myx, const int myy, const colour_picture_of_ &from, const double fromx, const double fromy, const int transparency) |
void | map (const int myx, const int myy, const colour_picture_of_ &from, const int fromx, const int fromy, const int transparency) |
int | wait (const int milliseconds) |
Assignment operators | |
template<typename OTHERPEL> colour_picture_of_ & | operator= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator= (const colour_picture_of_< PEL > &rb) |
Set this picture equal to source picture with same pel data type. | |
colour_picture_of_ & | operator= (PEL newval) |
template<typename OTHERPEL> colour_picture_of_ & | operator+= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator+= (PEL newval) |
Add newval to every pel (in all components). | |
template<typename OTHERPEL> colour_picture_of_ & | operator-= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator-= (PEL newval) |
Subtract newval from every pel (in all components). | |
template<typename OTHERPEL> colour_picture_of_ & | operator *= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator *= (PEL newval) |
Multiple every pel by newval (in all components). | |
template<typename OTHERPEL> colour_picture_of_ & | operator/= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator/= (PEL newval) |
Divide every pel by newval (unless newval == 0). | |
template<typename OTHERPEL> colour_picture_of_ & | operator|= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator|= (PEL newval) |
Replace every pel with its absolute difference from newval. | |
template<typename OTHERPEL> colour_picture_of_ & | operator^= (const colour_picture_of_< OTHERPEL > &rb) |
colour_picture_of_ & | operator^= (PEL newval) |
Replace every pel with its squared difference from newval. | |
template<typename OTHERPEL> colour_picture_of_ & | operator &= (const colour_picture_of_< OTHERPEL > &rb) |
Operators combining pictures to give PEL results | |
PEL | operator+ (const colour_picture_of_ &rb) |
PEL | operator- (const colour_picture_of_ &rb) |
Return the sum of all pelwise subtractions. | |
PEL | operator * (const colour_picture_of_ &rb) |
PEL | operator/ (const colour_picture_of_ &rb) |
PEL | operator| (const colour_picture_of_ &rb) |
Return the sum of all pelwise absolute differences. Can be used for block matching. | |
PEL | operator^ (const colour_picture_of_ &rb) |
Return the sum of all pelwise squared differences. Can be used for block matching. | |
Dereferencing operators | |
The following operator[]s are used to dereference (i.e. index) pictures. They must always be appended to a colour_picture_of_ in pairs, with the first [] specifying a row value or range and the second [] specifying a column value or range. | |
colour_picture_of_ | operator[] (const irange &selector) |
int | paste_centred_on (const picture_of_< PEL > &from, const int x, const int y) |
int | paste_centred_on (const colour_picture_of_< PEL > &from, const int x, const int y) |
As above, for colour_picture_of_ pasting. | |
Picture display functions | |
Use these functions to show or reshow the current picture on the screen | |
int | show (const char *comment, const bool normalize=1) |
int | show (const bool n=1) |
Display picture without a specific title. | |
int | showat (const int Nx, const int Ny, const bool normalize, const picture_of_< PEL > *parent) |
int | showat (const int Nx, const int Ny, const bool normalize, const colour_picture_of_< PEL > *parent) |
Display without decorations, with colour_picture_of_ as parent. | |
int | showat (const int Nx, const int Ny, const bool normalize) |
Display without decorations at screen coords Nx, Ny. | |
int | showat (const int Nx, const int Ny) |
Display without decorations at screen coords Nx, Ny. | |
int | reshow (const char *comment, const bool normalize=1) |
int | reshow (const bool normalize=1) |
Redisplay the picture without altering the title. | |
int | fastreshow (const char *comment) |
Redisplay without normalization. Equivalent to reshow(comment,0);. | |
int | fastreshow () |
Redisplay without normalization. Equivalent to reshow(0);. | |
int | rename (const char *comment) |
Change title of the displayed pic. | |
int | unshow () |
Stop showing the picture. | |
int | closerequested () |
int | pointx () |
Return current pointer (mouse) x coord relative to left of picture window. | |
int | pointy () |
Return current pointer (mouse) y coord relative to top of picture window. | |
int | pointleftbutton () |
Return non-zero if the mouse's left button is pressed within the picture's window. | |
int | pointmiddlebutton () |
Returns non-zero if mid button down. | |
int | pointrightbutton () |
Returns non-zero if right button down. | |
int | pointshiftbutton () |
Returns non-zero if the shift key is held down while a mouse button is down. | |
int | key () |
Returns keycode of any key held down. | |
int | clearkey () |
Clears keystroke so that it will not be reprocessed. | |
int | inspect () |
Sequence processing facilities | |
Sequence processing facilities for "standard" CLIP programs. Many CLIP programs consist of a processing loop that cycles over input pictures from a sequence of named files or from a camera. | |
colour_picture_of_ (int argc, char *argv[], const int def_nrows=240, const int def_ncols=320, const int bord=DEFAULT_BORDER) | |
int | next () |
Functions for interfacing to a local camera | |
int | attach_camera () |
int | request_frame () |
int | request_frame (int shutterspeed, int gain) |
int | frame_delivered () |
int | detach_camera () |
colour_picture_of_ maintains four picture_of_int components called mono, red, green and blue. For any colour_picture_of_ either mono alone is used, or red, green and blue (but not mono) are used. Which of these two cases applies is determined at construction time and can't be changed. colour_picture_of_ has many functions equivalent to picture_of_'s, except that they operate over all three of red, green and blue if the colour_picture_of_ was constructed as colour and over mono if the colour_picture_of_ was constructed as monochrome. Note that colour_picture_of_ omits the following picture_of_int functions: (1) operator[](const int selector), i.e. You can't do something like a[128][128] = 40; where a is a colour_picture_of_. Instead you must do: if (a.ismonochrome()) a.mono[128][128] = 40; else { a.red[128][128] = 40; a.green[128][128] = 40; a.blue[128][128] = 40; }. (2) operator[](const double selector), although map() does work for the the purpose of interpolating one colour_picture_of_ from another. (3) showascolour(const char *comment) and the related reshow functions because a colour_picture_of_ already _is_ colour! (4) mask(const picture_of_& rb,...); if you are masking, you need to do it on monochrome images. (5) operator==(PEL testval) is another operation that only makes sense on monochrome images. (6) bufptr() because colour_picture_of_s have more than one buffer. (7) rowptr(int i) because colour_picture_of_s have more that one row pointer per row. (8) the text constructor, so you must create text via a picture_of_ construction. (9) the matrix functions. (10) The specialized image processing functions for convolutions and the drawing functions (lines, graphs and ramps) are not yet supported. All other functions are supported.
|
Instantiates a colour picture by reading it in to the green, red and blue picture_of_s from a file. If the file is monochrome, it is read in to the mono picture_of_ and all subsequent operations are done in mono only. The bord argument works as in picture_of_. CLIP will read the following file formats: PGM, PPM, JPEG, APT and the most common types of BMP. |
|
Instantiates a zeroed colour picture of given dimensions. Usually sets up red, green and blue picture_of_s but if forcemono is nonzero, sets up mono only. |
|
Modify-source constructor that applies callback point function (*f) over source rb. If rb is mono, then so is this picture. |
|
Modify-source constructor that applies callback region function (*f) over source rb. If rb is mono, then so is this picture. |
|
Sequence processing constructor that interprets main()'s parameters. If the command line had no arguments, tries to attach a camera. If that fails, generates a default picture. If the command line had arguments, interprets these as picture files and sets up for reading these in sequence. See also member function next() |
|
Write picture in APT format 0 <= quality <= 100. When quality is 100, coding is lossless |
|
If a camera exists, attach it to this picture. Returns negative value if the camera doesn't exist, could not be initialized, is already attached to another picture or the current picture is too small to have a camera attached. |
|
Returns non-zero if the user has left-clicked in the close box of the window where the picture is being displayed. |
|
Set values in the border of the picture by copying the values on the edges of the picture outwards. |
|
Call to detach the camera from the picture. You may need to do this in order to attach the camera to a different picture. |
|
Immediately returns 0 if a requested frame is not yet available. If the frame is available does a buffer switch and returns 1. Because of the buffer switch within the function, immediately before the call the picture has its old contents; immediately after it has its the frame. |
|
Inspect a shown picture. Until the right button is clicked inside the picture, the program pauses and allows the user to left-click within the picture and inspect the values at that point. |
|
Returns 1 if this picture was constructed as monochrome (e.g. because it was read it from a PGM file), returns 0 if truly colour. USER FUNCTIONS THAT OPERATE AT THE PEL LEVEL ON colour_picture_of_ OBJECTS must always test this. E.g., to read in a picture then put a white dot in the centre: colour_picture_of_ in(argv[1]); int nr = in.nrows(); int nc = in.ncols(); if (in.ismonochrome()) in.mono[nr/2][nc/2] = 255; else { in.green[nr/2][nc/2] = 255; in.red[nr/2][nc/2] = 255; in.blue[nr/2][nc/2] = 255; } |
|
This map operator is even faster than the double version above. This time fromx and fromy are both 256 times the actual values desired, so dest.map(50,76,source,64,384,0); is the same as dest.map(50,76,source,0.25,1.5,0); but faster. Rarely used. |
|
The map operators provide a fast way of mapping a bilinearly interpolated value from one picture into another. transparency is a number from 0 (overwrite) to 255 (preserve almost all of what was there originally). So with two colour_picture_of_s's source and dest, dest.map(50,76,source,5.3,99.99,0); is exactly equivalent to dest.comp[76][50] = source.comp[99.99][5.3]; for comp = {red, green, blue} or comp = {mono}, but much faster. |
|
Apply callback neigh function *f() over source picture rb, putting result into this. |
|
Loads the next picture in the sequence into this picture that was constructed with the sequence processing constructor. Returns 1 if the picture has been seen before (if cycling back to the start of the argument list) and 0 if it has not. Returns -1 if the picture was not constructed using the sequence processing constructor. |
|
The &= operator does a pelwise conditional replacement, i.e. if (sourcepel < 0) destpel=destpel; else destpel = sourcepel; |
|
Return the sum of all pelwise multiplications. Can convolve a picture with an operator by making the operator into a picture, then multiply operator and a moving block of the picture together. |
|
Multiple source picture with this picture. I.e. each pel value in rb is multiplied with the corresponding pel's value in this. |
|
When a picture is added to a picture the result is a PEL which is the sum of all pelwise additions. |
|
Add source picture to this picture. I.e. each pel value in rb is added to the corresponding pel's value in this. |
|
Subtract source picture from this picture. I.e. each pel value in rb is subtracted from the corresponding pel's value in this. |
|
Return the sum of all pelwise divisions. Uses divisor of 1 for any zero pel in rb. |
|
If a pel in rb is 0, divides the corresponding pel in this by 1, otherwise divides it by rb pel value. |
|
Set every pel to newval. E.g.irange rg(0,8,256-8); picture_of_ a(256,256); a[rg][rg] = 255; sets every eighth pel horizontally and vertically to white. |
|
Set this picture equal to source picture with different pel data type. This and all assignments work with irange-referenced pictures. |
|
Copies picture_of_ into colour_picture_of_. If this object was constructed as colour, will copy the rb value into red, green and blue. |
|
When dereferenced (i.e. indexed) with irange operators, a subimage or block of the picture is returned as a picture. E.g. irange rg(0,1,7); colour_picture_of_ pic(256,256); pic[rg][rg] = 255; sets the top left 8x8 square in pic to white. |
|
The ^= operator does a pelwise squared difference, i.e. destpel = sourcepel-destpel; destpel *= destpel; not a pelwise XOR. |
|
The |= operator does a pelwise absolute difference, i.e. destpel = abs(sourcepel-destpel) not a pelwise OR. |
|
We often want to paste one picture on another, centred at a particular location. Can do this with irange derefencings, but this way is easier. |
|
Apply callback point function *f() over source picture rb, putting result into *this. |
|
Read picture into this object. If this object was constructed as colour and the file is monochrome, will copy the monochrome values to all three of red, green and blue. If this object was constructed as monochrome and the file is colour, read() will refuse to convert. |
|
This version of request_frame() only works with Philips cameras on Linux. Will be extended to other cameras and platforms when possible. |
|
Initiate the request of a frame from the camera attached to this picture. Returns immediately; you must check frame_delivered() for arrival of the frame. |
|
Reranges or normalizes picture values to fall in given range If scale_even_if_inside_range is false (default), then if all values are current between the give newlow and newhigh, they are unaltered. Otherwise, values are scaled so that the new max() will be newhigh and the new min() will be newmin. |
|
Redisplay the picture (presumably because it has changed) and change title to the comment string. |
|
Display the picture on the screen in its own window, with the comment string as title. If normalize is true values are scaled to [0,255] for display. If false, it is assumed they already are in this range. |
|
Display without decorations at Nx,Ny. If parent==0, the coords are screen coordinates, and the window receives events (e.g. pointx()) as normal. If parent is a displayed picture, the coords are relative to that picture and a child window is displayed that does not receive events. |
|
Waits for given number of milliseconds since last call to wait() on any picture_of_ or colour_picture_of_. Returns actual number of milliseconds waited (negative if interval has already passed and therefore wait() returned immediately). |
|
Write picture to PPM file (unless it was constructed as monochrome in which case a PGM file will be written. |