McXtrace logo

McXtrace - An X-ray ray-trace simulation package

ESRF; SAXSLAB Niels Bohr Institute DTU Physics



Project Status
 Project Partners
 Project People

Mailing list



Minutes of Meetings

McXtrace Art

About McXtrace



McXtrace: Mask Component

[ Identification | Description | Input parameters | Output parameters | Links ]

The Mask Component

A masking image object


  • Author: Erik Knudsen
  • Origin: DTU Physics
  • Date: March 2014
  • Version: 1.0


The Mask component takes an image as input either as an standard image file in png or pnm format, or as an ascii file (see below for format),
and uses the image as a mask. For instance as a manner of measuring resolution for imaging applications.
If the image is supplied as a png or pnm file, they interpretation of the pixels varies depending on the file. If the image is grayscale the pixel values are directly mapped
to opacity (or transparency if invert is set) values in the range [0..1]. If the image has RGB channels the R channel is considered most significant, the B channel least significant.
The resulting number, e.g. R*255^2 + G*255 + B, is then mapped to a real valued opacity.
Additionally png images may have an alpha channel - which is then considered the least significant channel. Palette mapped pngs are as of yet _not_ supported.
A regular ascii file may be supplied - in which case the file is like the one below
#any initial line starting with a hash is silently ignored
0.0 1.0 0.0 1.0 0.0
0.5 0.0 0.5 0.0 0.5  
0.0 0.25 0.0 0.25 0.0
0.75 0.0 0.75 0.0 0.75
1.0 0.0 1.0 0.0 1.0

...which defines a 5x5 mask with a kind of checkerboard pattern-  

N.b. If you want to use the png-option of the component you must have libpng installed _and_ link your compiled instrument to it. Assuming libpng is installed you may do this
by adding "-DUSE_PNG=1 -lpng" to 1) the MCXTRACE_CFLAGS environment variable or 2) to the compiler flags textbox in the GUI. Open File->Configuration and edit the textbox. 

The virtual option of the Mask, is intended as a help to use a png-image as a grayscale distribution. If the virtual flag is set, rays are porpagated to the mask plane
and the pixel value at the intersection point is read, but the rays reamin unaffected. By extracting the output parameter masking it can subsequently be used. 

Input parameters

Parameters in boldface are required; the others are optional.
Name Unit Description Default
xwidth m Width of the masking object  
yheight m Height of the masking object  
invert 1 is fully transmissive [ ] By default the values from the masking image are interepreted as opacity (1 is fully blocking). If invert is nonzero this is inverted and the values are considered as transparency 0
virtual Mask does not affect the x-ray, but does read the pixel value of the pixel hit. Could be useful to have as a packing factor for a crystal . 0

Output parameters

Name Unit Description Default
masking Opacity/transmission value. If virtual==0, each ray is downweighted according to the masking value.  


[ Identification | Description | Input parameters | Output parameters | Links ]

Generated automatically by McDoc, Peter Willendrup <> / Mon Aug 16 15:54:47 2021

Last Modified: Monday, 16-Aug-2021 17:54:47 CEST
Search website mailinglist archive SVN repos McCode Trac