gpt4 book ai didi

c++ - GDCM:获取标签值

转载 作者:搜寻专家 更新时间:2023-10-31 02:18:21 26 4
gpt4 key购买 nike

我正在尝试读取和写入 dicom 文件的属性值。接口(interface)应该是这样的:

// only need to support std::string, int, float, float*, etc.
template<class T>
T getTagValue(const DataSet& ds, const Tag& tag);

template<class T>
void setTagValue(DataSet& ds, const Tag& tag, const T& value);

FAQ of GDCM给出了一些关于如何获取属性值的很好的示例,但这些示例并不像我想的那样工作。

以下是我对这些示例的问题。

  1. 如何将属性值转换为其类型?

    if( header.FindDataElement( Tag(0x2, 0x13 ) )
    DataElement &de = header.GetDataElement( Tag(0x2, 0x13) );
  2. 如果属性值是一个数组呢?

     sf=gdcm.StringFilter()
    sf.SetFile(r.GetFile())
    print sf.ToStringPair(gdcm.Tag(0x0028,0x0010))
  3. 其实我很喜欢下面的解决方案。但这是否意味着我必须为每个属性编写一个接口(interface)?

     const DataSet &ds = file.GetDataSet();
    Attribute<0x0020,0x0032> at;
    at.Set( ds );
    if( at.GetValue() == 0.0 ) exit(1);

如有任何建议,我们将不胜感激。

最佳答案

您已在 GDCM 邮件列表中发布了完全相同的复制/粘贴消息:

我已经在这里回答了你的问题:

为了方便,这里又是:

gdcm::Attribute is really only meant for people dealing with specific attribute. If you do not now the Tag ahead of time and only the underlying type of the Data Element, then have a look at gdcm::Element<>.

关于c++ - GDCM:获取标签值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34585173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com