FRAT/Library
__NOTITLE__
|
FRAT as a LibraryIn addition to command line executables, FRAT provides a C++ library that can be used in external projects. Since FRAT is currently only available as source code, you must first follow the instructions in the Installation Guide to build FRAT. Using libFRAT in an External ProjectOnce built, the steps for using FRAT in your own CMake project are:
find_package(FRAT REQUIRED) if(FRAT_FOUND) include(${FRAT_USE_FILE}) else(FRAT_FOUND) message(FATAL_ERROR "FRAT not found. Please set FRAT_DIR.") endif(FRAT_FOUND)
add_library(bar bar.cxx) target_link_libraries(bar ${FRAT_LIBRARIES}) add_executable(foo foo.cxx) target_link_libraries(foo bar ${FRAT_LIBRARIES})
Basic Concepts in FRATThis section outlines some of the basics of the FRAT project so you can learn how to use libFRAT in your own project. Data StructuresFRAT provides libraries for working with both 2D and 3D vector-valued images. Most functions and algorithms are implemented for both 2D and 3D, so for the sake of brevity, we'll use XD in place of 2D or 3D. At this time, FRAT is not generalized to arbitrary dimensionality. The base data classes in FRAT are the VectorArrayXD classes. These templated classes store XD vector-valued data of any type. Throughout the code, they are used only as the superclass for the float-based VectorImageXD and VectorFieldXD classes. VectorImageXDThe VectorImage2D and VectorImage3D classes offer basic vector-value XD image functionality with float type pixels. The following trivial example shows a simple operation using the VectorImage2D type and then deletes the image. In this case it simply sets the value of each pixel to the value of the x index times the value of the y index. unsigned int szX = 100; unsigned int szY = 50; unsigned int dim = 1; VectorImage2D* im = new VectorImage2D(szX, szY, dim); for (unsigned int y = 0; y < szY; y++) { for (unsigned int x = 0; x < szX; x++) { for (unsigned int d = 0; d < dim; d++) { im->setValue(x,y,d, x*y); } } } delete im;
unsigned int szX = 100; unsigned int szY = 50; unsigned int dim = 1; float spX = 0.1; float spY = 0.2; float spFct = 0.01; VectorImage2D* im = new VectorImage2D(szX, szY, dim, spX, spY, spFct);
VectorFieldXDThe other primary data type used in FRAT is vector fields, implemented in the VectorField2D and VectorField3D classes. In practice these classes are simply subclasses of the VectorImageXD classes where the vector size is specified as 2 for 2D fields and 3 for 3D fields. In theory, however, these classes should be thought of as separate entities from the VectorImageXD classes. To access vector components, these classes provide axis specific get and set methods such as getX(x,y,d) and setX(x,y,d, val). Since the dimensionality is fixed for vector fields, a dim value cannot be included when instantiating a field. For example: unsigned int szX = 100; unsigned int szY = 50; float spX = 0.1; float spY = 0.2; float spFct = 0.01; VectorField2D* fld = new VectorField2D(szX, szY, spX, spY, spFct); When using VectorFieldXD objects in conjunction with VectorImageXD objects, it is important that the fields use the same spacings and space factor as the images.
|