dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #11886
Image to Function data structure conversion
Anders,
Kent and I have discussed connecting itk and dolfin and, following
your advice, one viable way of itk->dolfin data flow can be summarised
in the following c++ snippet:
-------------------------------------
typedef double PixelType
const unsigned int Dim = 3;
typedef itk::Image< PixelType, Dim > ImageType;
class F : public Function
{
public:
SetImageData(ImageType id) {this->ImageData = id;};
void eval(double* values, const double* x) const
{
values[0] = ImageData.GetPixel(x);
}
protected:
ImageType ImageData;
};
--------------------------------------
The problem with the above approach is that direct access of pixel
data with GetPixel() in itk, and generally in a generic image data
structure, is not efficient. Typically, in a 2D or 3D image, this
method is, correspondingly, called 10e4 to 10e6 times leading to slow
data structure conversion. This is even more pronounces when the
conversion has to happen many times.
There are at least 2 alternatives for this:
(1) Passing the image data pointer to a Function class.
(2) Looping in the itk API rather than the dolfin API. The c++
iterator implemented in itk provides a much more efficient interface
for data assignment, however, we need to have access to dolfin
Function data.
In both of the above approaches, we assume that the image data has a
complete rectangular shape with known sizes which provides a simple
look-up rule. Is it currently possible to implement either of the
above methods? If not, how can dolfin be extended to support this?
-Ali
Follow ups