Prima Homepage
Generating C++ Modules
User Manual
The Command Shell
Running Imalab
Plugin Process
Pixels and Images
Interactive selection
Graphics: plots, profiles
Image file I/O
Image display
Connectivity Analysis
Image Processing(1)
Gaussian operators
Technical Documentation
Creating New Modules
Tutorial Download


Image display

There are several functions to display an image on the imalab-screen, to fit the most common needs.

affiche(bmp,[pos,label])displays the image bmp on the imalab-screen. As optional parameters, you may give the screen position, and a string-label, in any order. Default parameters are position 0, empty label. The image may be given in one of several formats, used in the Prima and Orion teams.

affiche-pos(bmp,pos,lab)displays the TBitmapABGR image bmp at position pos with label lab. All parameters are mandatory.

The screen-position pos is an integer in the interval [0..screen-places]. The position at which the label is displayed is given by the lobal variables label-x0, label-y0. See the paragraph on text display if you want the label to be displayed in a particular police or color.

affiche-xy(im,x,y [,lab]) displays the TBitmapABGR image im at screen-coordinates (x,y), with an optional label. This function is useful for images that do not have the size of a screen-place, e.g. images of a pyramid.

show-tif(filename) loads tiff-image form file filename into current-image and displays it on the screen.

Gamma Correction

The functions given above - affiche, affiche-pos, affichixy - apply gamma-correction. gamma is a global variable.

Displaying byte-images

For display, a TBitmapByte image has to be transformed into a TBitmapABGR. There are two very different ways to accomplish this: gray-level image, or false color image.

The global variable une-cmap is a vector to be used as colormap. Default initialization sets up 3 color values only (0-1-2).

Calling colormap-init(une-cmap);initializes the colormap with gray-level values, and the levels 1-2-3 with colors yellow-green-red. To change any value in the colormap, use



Byte Image Display


Default colormap is une-cmap.

Primitive functions:

void PseudoColor(TBitmapByte& src, TBitmapABGR& dst, TIntVector& cmp,float a) translates src into dst, according to a color map cmp. Parameter a is not used.

Displaying float-images

Displaying an image with pixels coded as floating-point numbers needs some transcoding, since only TBitmapABGR images, which are 24-bit encoded, are directly accepted by X11. In the simplest case, you may just want to encode grey levels: you still have to provide a scale factor.

The function affiche-float(iflt,pos,e[,label])displays the TBitmapFloat image iflt at screen position pos with scale factor e, and an optional label. This function uses an intermediate TBitmapABGR image, given by the global variable current-flt.

affiche-float takes into account the floating-point sign, displaying positive values as yellow, negative values as green.

More precisely, the conversion float->(r,g,b) is based on 6 paramters (pR,pG,pB,nR,nG,nB). A value v is transformed as follows:

if v >= 0, the pixel is (v*e*pR,v*e*pG,v*e*pB), if v < 0, the pixel is (v*e*nR,v*e*nG,v*e*nB). (All values are cut off at 255). Initially the parameter values are (pR,pG,pB,nR,nG,nB)=(255,255,0,0,255,0), for positive=yellow, negative=green.

To change these paramters, in particular if you want to display plain grey level images, use the following function:

The function SetColCoeff sets 6 parameters used by the function affiche-float for the conversion

to obtain grey-level pixels for positive numbers, blue pixels for negative numbers.

The function affiche-floatxy(iflt,x,y,e[,string])displays a floating-point image with given xy-coordinates on the imalab-screen.

The function mu-affiche-float(vec,li,pos)displays several floating-point images, given by a vector vec and the list of indices li, starting at screen-position pos. The scale-factor is affi-fact**affi-exp.

Basic methods in the X11TrueColor class

If the above functions don't fit your particular needs, you have to directly use the C++ functions and methods that are available in the basic C++-class.

All display functions use the method DisplayImage of the class X11TrueColor; the Imalab screen is an instance of this class. Some features of this method are not available through the functions described above.

  void DisplayImage(void);
  void DisplayImage(unsigned char *);
  void DisplayImage(unsigned char *,int w,int h);
  void DisplayImage(unsigned char* data,int dst_x,int dst_y,int w,int h);

void DisplayImage(XImage *,int src_x,int src_y,int dst_x,int dst_y, int w,int h);

// copy of complete ximage bool MakeCopy(int,int); // border width XImage* GetCopy(); void DisplayCopy();

For the source code, see the module X!!Win.

Experimental functions

void FloatToABGRq(TBitmapFloat& src,TBitmapABGR& dst,float e);

The following function
void FloatToABGRlog(TBitmapFloat& src,TBitmapABGR& dst,float mul,float plu);
Elle calcule le (r,g,b) selon la formule if(v>0)log(v+plu)*mul; if(v<0)log(plu-v)*mul; puis applique les coefficients de couleur.

La gamma-correction est effectuée par une fonction du même gabarit:
void gamma_correctq(TBitmapABGR& src,TBitmapABGR& dst,float g);