dicom学习笔记之二:数据元素编码

        VM:value multiply =如果数据类型是字符串,就会用反斜杠把相关的值区分开来;如果是字节流,就需要用长度和当前的类型进行除法运算来获取。

        

        在显式语法中,如果VR值是OB, OW, OF, SQ, UT, UN类型

Tag

VR

Value Length

Value

Group

Number

(16-bit

unsigned

integer)

Element

Number

(16-bit

unsigned

integer)

VR(2 byte character string) of

"OB",

"OW",

“OF”,

“SQ”, “UT”

or "UN"

Reserved

(2 bytes)

set to a

value of

0000H

32-bit unsigned

integer

Even number of bytes containing the Data Element Value(s) encoded according to the VR and negotiated Transfer Syntax. Delimited with

Sequence Delimitation Item if of Undefined

Length.

2 bytes

2 bytes

2 bytes

2 bytes

4 bytes

'Value Length' bytes if of Explicit Length

        否则的话,     

Tag

VR

Value Length

Value

Group

Number

(16-bit

unsigned

integer)

Element

Number

(16-bit

unsigned

integer)

VR

(2 byte character

string)

(16-bit unsigned

integer)

Even number of bytes containing the Data Element Value(s) encoded according to the VR and negotiated Transfer Syntax.

2 bytes

2 bytes

2 bytes

2 bytes

'Value Length' bytes

        在隐式的情况下:

Tag

Value Length

Value

Group

Number

(16-bit

unsigned

integer)

Element

Number

(16-bit

unsigned

integer)

32-bit unsigned integer

Even number of bytes

containing the Data

Elements Value

encoded according to

the VR specified in PS

3.6 and the negotiated

Transfer Syntax.

Delimited with

Sequence Delimitation

Item if of Undefined

Length.

2 bytes

2 bytes

4 bytes

'Value Length' bytes or

Undefined Length

 在dcmtk代码如下:

 /* read the value in the length field. In some cases, it is 4 bytes wide, in other */
    /* cases only 2 bytes (see DICOM standard (year 2000) part 5, section 7.1.1) (or the */
    /* corresponding section in a later version of the standard) */
    if (xferSyn.isImplicitVR() || nxtobj == EVR_na)   //note that delimitation items don't have a VR
    {
        inStream.read(&valueLength, 4);            //length field is 4 bytes wide
        swapIfNecessary(gLocalByteOrder, byteOrder, &valueLength, 4, 4);
        bytesRead += 4;
    } else {                                       //the transfer syntax is explicit VR
        DcmVR vr(newTag.getEVR());
        if (vr.usesExtendedLengthEncoding())
        {
            Uint16 reserved;
            inStream.read(&reserved, 2);           // 2 reserved bytes
            inStream.read(&valueLength, 4);        // length field is 4 bytes wide
            swapIfNecessary(gLocalByteOrder, byteOrder, &valueLength, 4, 4);
            bytesRead += 6;
        } else {
            Uint16 tmpValueLength;
            inStream.read(&tmpValueLength, 2);     // length field is 2 bytes wide
            swapIfNecessary(gLocalByteOrder, byteOrder, &tmpValueLength, 2, 2);
            bytesRead += 2;
            valueLength = tmpValueLength;
        }
    }




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值