The XGrayImg Library

Introduction

Overview

XGrayImg is a library for dealing with HDR (High Dynamic Range) XRay images (as the name supposes). The main processing is done with IEEE 32bit floats (class bildfloat), 16bit integer images delivered by the HIS library can be read by the class bild16. I/O routines exist for several standard and proprietary formats (HIS, PGM, gnuplot) to ease interfacing with standard image processing packages.

Signal processing functions cover standard correction procedures such as linearizing the response function (QRfit), interpolating holes (badpix) and Gain-Correction (bild16::operator /=()), gaussian convolution bildfloat::gaussian(), convolution with arbitrary kernels bildfloat::convolve(), as well as functions specialized for the image processing of ferrofluidic images:

Interfaces

An interface to the TCL scripting language is provided by SWIG. Using SWIG makes it easy to extend this interface to other scripting languages like Perl, Python, Ruby, though this has not been done. Using the TCL interface a simple GUI tool has been written (XRayLab) that allows to look at the images and run simple animations and data plots. Using XRayLab, generally every possible processing can be done, though the buttons cover only a small set.

Exception handling is done by C++ exception. Currently, std::strings are thrown that contain a human readable error message. No effort has been done so far to construct machine readable error objects.

A note about portability

The library has been written for the people at EP5, Bayreuth. It is not yet endian-clean, but portable to at least Linux (including XRayLab). Apart from the endian problems (reading/writing HIS files and gnuplot binary), it should be portable to any reasonable C++ compiler. g++ -Wall -pedantic (version 3.3.3) compiles without any warning. To enable compiling with the crappy, outdated VC++ 6.0 from 1998 that EP5 uses, the special header file vc6compat.h tries to eliminate most of the problems with VC6. It repairs for-scoping, missing nanf(), M_PI, overloading abs() for doubles and wrong namespace of cstdlib. However, it is not possible to correct every bug. Please consider using a modern compiler (gcc, Intel or VC>=7)

Installation

The package consists of a single zip-file you should unzip to some standard location. It contains the sources, Makefiles for both Windows and Linux and a binary distribution of Tcl/Tk (+threads enabled, itcl, itk and iwidgets), SWIG and the compiled library. To compile by hand, you need the beforementioned packages and setup your include and library paths correctly. Then run the correspondig makefile.

To compile a program using XGrayImg, include this file and link against "xgrayimg.lib" (Windows) or "libxgrayimg.a" (Unix) Make sure that Tcl/Tk is in your library path in case you want to use the GUI functions.

Sample program that uses the library

The following program provides a simple skeleton. It only reads one his-file and writes it as a 16bit pgm. No information is lost by this conversion, apart from metadata (exposition time etc.) It does exception handling, so you get a meaningful error message if the program e.g. cannot find the input file.

 #include <iostream>
 #include "../imgclass/xgrayimg.hpp"
 
 using namespace std;
 
 void usage() {
   cerr<<"Usage: his2pgm <image.his> <output.pgm>"<<endl;
   exit(-1);
 }  
   
   
 int main (int argc, char **argv)
 {
   if (argc !=3)
     usage ();
   try { 
     bild16 img(argv[1]);
     img.write_pgm16(argv[2]);
  
     return (0);
   } catch (const string &msg) {  
      cerr << "Error: "<<msg<<endl;
      return -1;
   }   

 }

Generated on Fri Jul 24 12:49:17 2009 for Xgrayimg Library by  doxygen 1.5.5