【问题标题】:Troubles understanding .inr file format难以理解 .inr 文件格式
【发布时间】:2016-04-26 16:20:04
【问题描述】:

我正在尝试为 cgal 库创建灰度 .inr 图像,但文件格式有问题。
This seems to be the best description of the format,但它看起来并不完整,只谈论标题,而不是数据本身。
This seems to have a bit more information about the format,但不幸的是它是法语的。

我想要做的是将一个对象表示为一个用布尔值填充的 3D 数组,因此如果位置在对象内部,则值为 1,如果在对象外部,则值为 0。

如果我理解正确的话,基于第二个链接,我现在所做的是在标题之后写下每个 z 平面在一行上,下一个 z 平面在新行上。
所以我在代表第一行的一行上有列的 x 值,然后在同一行上有第二行的 x 值,直到最后一行。然后我为新的 z 平面跳线并以相同的方式写入数据。

I have created the following .inr file,但是当我尝试对其进行网格划分时,结果是立方体而不是圆柱体,好像 cgal(我使用了 mesh_optimization_lloyd_example)不关心布尔值,只是对整个体积进行了网格划分。

我尝试查看随示例提供的 .inr 文件(如头骨_2.9.inr),但虽然标题非常清晰,但没有文本编辑器可以读取图像数据,这让我认为可能还有更多内容不仅仅是写 0 或 1。

.inr 有什么问题吗?还是我用错了cgal?

【问题讨论】:

    标签: 3d file-format cgal


    【解决方案1】:

    我终于设法让它工作了,这是需要的,以防它对某人有所帮助。

    头部:必须是256字节的倍数,包括头部结束后的回车,这里是一个例子。

    #INRIMAGE-4#{ // format type
    XDIM=150 // x dimension
    YDIM=200 // y dimension
    ZDIM=100 // z dimension
    VDIM=1 // dimension of the data, here 1 for scalar or 3 for thing like RGB values
    VX=5 // voxel size in x
    VY=5 // voxel size in y
    VZ=5 // voxel size in z
    // a higher voxel size results in a more precise 3D mesh
    TYPE=unsigned fixed // type of data written, can float, signed fixed or unsigned fixed, unclear if it makes a difference in my case
    SCALE=2**0 // not used by most programs apparently
    PIXSIZE=8 bits // size of a char, can be 8, 16, 32 or 64
    CPU=pc // the type of cpu for little/big endianness, pc is little endian
    
    // Fill with carriage returns until the header is a multiple of 256 bytes, including the end of the header (4 bytes including the line break)
    
    ##} // the line break is included in the header count
    

    现在是数据本身:
    尽管文档似乎暗示了什么,但其中没有换行符,一切都是连续的。 数据必须以二进制而不是 ASCII 写入(因此在我的情况下,在 C++ 中,这将是 static_cast(space[i][j][k])),将 char 替换为您使用的数据类型)。

    最后一个怪癖,文件似乎是列优先顺序,所以如果你在 C 中有一个 3d 数组(它是行优先的),你需要在写入之前转置 (x,y) 平面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 2013-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多