<starttext>xplot2d_setdetector

In this window you define some of the parameters of your measurement. 

They will be used for overplotting diffraction rings of your reference, 
integraton of the image to get the diffractogram, and calibration. 

Wavelength can be entered directly, or as energy of the incident particles 
(photons, relativistic electrons or neutrons). 

Set "Use ellipses=No" when the beam is orthogonal to the detector. This is
always a good starting point, and you may later correct for small
non-orthogonality.

Note that the detector distance must be entered in pixels. 

After changing values, then presse <enter> (or press the Apply button) to
refresh the image with your mnew values. 

<endtext>xplot2d_setdetector

<starttext>xplot2d_calc_warping

In image processing, image warping is used primarily to correct optical
distortions introduced by camera lenses, or to register images acquired
from either different perspectives or different sensors. 

When correcting optical distortions, a reference pattern (grid) is
imaged and the recorded image positions are compared to the original
(exact) ones. A list of corresponding points (control points, selected in 
the input and reference images) control the geometry of the warping 
transformation. 

A file with the control points must be prepared. It should be a 4
columns ASCII file with :

Xfrom Yfrom Xto Yto

being Xfrom: The abscissas points of the image (uncorrected)
      Yfrom: The ordinates points of the image (uncorrected)
      Xto: The abscisas points of the referende pattern or calibrated image
      Yto: The ordinates points of the reference pattern or calibrated image

The warping transforms the uncorrected image into a new corrected one
stretching it to conform to the control point arrays. 

Three methods are proposed: 

1) Thin Plate Spline interpolation, which interpolates a set of
   irregularly sampled data value over a regular two dimensional grid. Thin
   plate splines are ideal for modeling functions with complex local
   distortions, such as warping functions, which are too complex to be fit
   with polynomials.
2) The irregular grid defined by the control points is triangulated, 
   then interpolated to get the locations in the input image
   of each pixel in the output image. 
   Linear interpolation or smooth quintic interpolation are available.
3) Polynomial spatial warping, using least squares estimation

For more details, see IDL documentation of WARP_TRI and POLYWARP routines.

<endtext>xplot2d_calc_warping

<starttext>xplot2d_calc_generic_operation

This option permits to create a new image by performing operation with the
images currently loaded in Xplot2D. 

The syntax is: imgNew = f[img,img1,...]
where imgNew is the new image
      img    is the current image (displayed by Xplot2d)
      img1   is the loaded image number 1
      img2   is the loaded image number 2, etc.

Some examples using the current image

      Create a negative of the current image:  
   imgNew = max(img)-img
      Normalize the current image to 1000:  
   imgNew = (img-min(img))*1000/(max(img)-min(img))
      Flip image horizontally
   imgNew = Reverse(img,1)   
      Flip image vertically
   imgNew = Reverse(img,2)   
      Transpose image 
   imgNew = Transpose(img)   
      Rotate image 10 degrees clockwise around pixel (50,100) (Magnification=1.0)
   imgNew = Rot(img,10,1,50,100)   
      Crop image to the left-bottom quadrant
   imgNew = img[0:N_Elements(img[*,0])/2,0:N_Elements(img[0,*])/2]
   
Some examples using several images
      Substract image (i.e., dark field) loaded in img1 from current image 
     loaded in image 2:
   imgNew = img-img1
     or
   imgNew = img2-img1
   

Important notes: 

1) when using masks, the masked pixels have negative values and they are
also considered in the operations. This may false your results, e.g.,
imgNew = img-min(img) will substract from img the lower pixel value (the
lowest masked pixel value). 

2) Operations with several images may fail if they do not have the same
dimensions. 

<endtext>xplot2d_calc_generic_operation

<starttext>xplot2d_calc_rebin

This option changes the dimension of the image (rebinning)

The new dimensions are either: 
  1) defined directly: newSizeX and newSizeY
  2) calculated from a pixel transformation, i.e.:
       newSizeX = sizeX / (newPixelX/pixelX)
       newSizeY = sizeY / (newPixelY/pixelY)

Note that the pixel values defined and changed here do not affect to the
detector and beam parameters in the Xplot2d/Diffraction menu. 

Therefore, if this option is used in conjunction with diffraction image
analysis, the pixel size(s) must be copied manually  from (to) the detector 
parameters windows. 

<endtext>xplot2d_calc_rebin
