This file is indexed.

/usr/bin/dcunrgb is in dicom3tools 1.00~20151213160232-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh

# usage: dcunrgb infile outfile
#

TMPROOT=/tmp/`basename $0`.$$

ANCREATE=ancreate
DC=dc
DCCP=dccp
DCDUMP=dcdump
DCTOPNM=dctopnm
DCKEY=dckey
PNMTORAW=pnmtoraw
PPMTOPGM=ppmtopgm

dccpoptions=" -nodisclaimer -noadddicom -ignorereaderrors -ignoreoutofordertags"

if [ ! -f "$1" ]
then
	echo 1>&2 "Input file does not exist - $1"
	exit 1
fi

transfersyntaxuid=`"$DCKEY" -noerror -ignorereaderrors -ignoreoutofordertags -k TransferSyntaxUID "$1" 2>&1 | egrep -v 'Error|Warning'`

if [ "$transfersyntaxuid" != "1.2.840.10008.1.2" -a "$transfersyntaxuid" != "1.2.840.10008.1.2.1" -a "$transfersyntaxuid" != "1.2.840.10008.1.2.2" ]
then
	echo 1>&2 "Only uncompressed RGB 8 bit per pixel input supported"
	exit 1
fi

bits=`"$DCKEY" -noerror -ignorereaderrors -ignoreoutofordertags -decimal -k BitsAllocated "$1" 2>&1 | egrep -v 'Error|Warning'`

if [ $bits -ne 8 ]
then
	echo 1>&2 "Only uncompressed RGB 8 bit per pixel input supported"
	exit 1
fi

samplesperpixel=`"$DCKEY" -noerror -ignorereaderrors -ignoreoutofordertags -decimal -k SamplesPerPixel "$1" 2>&1 | egrep -v 'Error|Warning'`

if [ $samplesperpixel -ne 3 ]
then
	echo 1>&2 "Only uncompressed RGB 8 bit per pixel input supported"
	exit 1
fi

rows=`"$DCKEY" -noerror -ignorereaderrors -ignoreoutofordertags -decimal -k Rows "$1" 2>&1 | egrep -v 'Error|Warning'`
columns=`"$DCKEY" -noerror -ignorereaderrors -ignoreoutofordertags -decimal -k Columns "$1" 2>&1 | egrep -v 'Error|Warning'`
frames=`"$DCKEY" -noerror -ignorereaderrors -ignoreoutofordertags -decimal -k NumberOfFrames "$1" 2>&1 | egrep -v 'Error|Warning'`
if [ -z "$frames" ]; then frames=1; fi

#echo 1>&2 "rows=$rows"
#echo 1>&2 "columns=$columns"
#echo 1>&2 "frames=$frames"

#numberOfPixels may be odd
numberOfPixels=`$DC <<EOF
16
o
$rows
$columns
$frames
*
*
p
EOF`
#echo 1>&2 "numberOfPixels(hex)=$numberOfPixels"

# VL is rounded up to next even number if odd ...
vl=`$DC <<EOF
16
o
$rows
$columns
$frames
*
*
1
+
2
/
2
*
p
EOF`
#echo 1>&2 "vl(hex)=$vl"

#isOdd will be 0 if even, 1 if odd
isOdd=`$DC <<EOF
16
i
$vl
$numberOfPixels
-
p
EOF`
#echo 1>&2 "isOdd=$isOdd"

echo "(0x7fe0,0x0010) OX Pixel Data 	 VR=<OB>   VL=<0x$vl> []" | "$ANCREATE" -e > "$TMPROOT.pixelhead"
 
"$DCTOPNM" -quiet "$1" "$TMPROOT.ppm"

# Note that ppmtopgm is documented (“http://netpbm.sourceforge.net/doc/ppmtopgm.html”) to use “gray = .299 r + .587 g + .114 b” as the conversion formula
# (NTSC luminance weighting “http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC11”), but the net effect
# is to produce the same value of gray when r, g and b are the same value

"$PPMTOPGM" "$TMPROOT.ppm" > "$TMPROOT.pgm"
rm "$TMPROOT.ppm"
"$PNMTORAW" "$TMPROOT.pgm" > "$TMPROOT.raw"
rm "$TMPROOT.pgm"

"$DCCP" "$1" "$TMPROOT.nopixels" -d PixelData -d DataSetTrailingPadding -d DigitalSignaturesSequence $dccpoptions -r PhotometricInterpretation MONOCHROME2 -r SamplesPerPixel 1 -d PlanarConfiguration
cat "$TMPROOT.nopixels" "$TMPROOT.pixelhead" "$TMPROOT.raw" > "$2"

if [ ${isOdd} = 1 ]
then
	# add single padding byte to make even and match VL
	dd if=/dev/zero bs=1 count=1 >>"$2" 2>/dev/null
fi

rm "$TMPROOT.nopixels" "$TMPROOT.pixelhead" "$TMPROOT.raw"

exit 0