中
CGAL提供了一种通过函数read
实例化Image_3对象的方法,即从磁盘读取现有的图像文件。我想知道我是否可以用height,width,depth
和data pointer
这样的例子:
CGAL::Image_3 im;
int Height = 512;
int Width = 512;
int Depth = 100;
int* dataptr = new int [Height*Width*Depth];
memset(dataptr, 0, sizeof(int)*Height*Width*Depth);
MyCreate(im, Height, Width, Depth, dataptr); // <== my function to instance this object.
那么如何做到这一点呢?
您可以使用以下未记录的代码(未经过真正测试):
// create and fill the _image struct
_image* image = ::_initImage();
image->vectMode = VM_SCALAR;
image->xdim = Height;
image->ydim = Width
image->zdim = Depth;
image->vdim = 1;
image->vx = 1.;
image->vy = 1.;
image->vz = 1.;
image->endianness = ::_getEndianness();
image->wdim = sizeof(int);
image->wordKind = WK_FIXED;
image->sign = SGN_SIGNED;
image->data = dataptr;
// then create the CGAL::Image_3 object:
CGAL::Image_3 im(image);
我修改了函数Image_3::read_vtk_image_data
中的代码(在CGAL-4.5/src/CGAL_ImageIO/Image_3.cpp
.