Skip to Content
go-dicom(3)
Command line

share

Renders a DICOM image as a PNG or JPEG that holds pixels only, refusing an image that may carry burned-in text until you say where the text is or that there is none.

When to use it

Use share when a picture is all the other side needs: a slide, an email, a chat message, a ticket. The picture is what a viewer shows (rescaled, windowed, at 8 bits), and no name, date or identifier from the file's attributes goes into it.

A name drawn into the pixels is another matter, and ultrasound, endoscopy, secondary captures and screen captures often have one. share refuses such an image unless -redact says where the text is, -redact auto fills what a detector finds, or -allow-burned-in says there is none.

It does not write DICOM: to hand on a DICOM file, use anonymize. For a picture with no burned-in check, as a viewer would export it, use convert. No dcmtk or pydicom tool does this job.

Examples

A CT slice, with a window

go-dicom share ct.dcm ct.png --window 40,400
Wrote ct.png
The picture holds pixels only: no name, date or identifier from the file is in it.
Nothing looked at the picture itself. Text drawn into it is still there unless you redacted it.

The output's extension is its format: .png, .jpg or .jpeg.

An ultrasound image is refused

go-dicom share us.dcm us.png
Error: share: us.dcm may hold text burned into the pixels: its modality is US (ultrasound), and Burned In Annotation (0028,0301) does not say there is none. Give -redact x,y,width,height for where the text is, -redact auto to fill what a detector finds, -preview to see what it finds, or -allow-burned-in if there is none

See what the detector finds, then fill it

go-dicom share -preview us.dcm check.png
go-dicom share -redact auto us.dcm us.png
Wrote check.png
The picture holds pixels only: no name, date or identifier from the file is in it.
This is a preview: 10 region(s) a detector found are outlined and nothing is redacted. Do not hand it on.
Wrote us.png
The picture holds pixels only: no name, date or identifier from the file is in it.
10 region(s) a detector found were filled. A detector can miss text. Look at the image before it leaves your hands.

-preview outlines the regions and redacts nothing: it is for checking, not for handing on. -detect prints the same regions as x,y,w,h lines and writes nothing.

Fill a rectangle you chose

go-dicom share -redact 0,0,320,60 us.dcm us-top.jpg

The rectangle is counted in pixels from the top left and filled with black in every frame. Repeat -redact for more rectangles. --quality sets the JPEG quality (default 90).

Every frame of a multi-frame image

go-dicom share -allow-burned-in cine.dcm frame.jpg --frame all
Wrote frame-0001.jpg
Wrote frame-0002.jpg
…

--frame counts from 1 (default 1); with all, frames are written beside the output name.

Notes

  • The input is never changed.
  • When what -redact auto finds covers more than a quarter of the picture, nothing is written: that is more than text.
  • An ICC profile in the image is embedded in the picture as it is.
  • Exit status is 0 when the picture was written and 1 when it was refused or failed.

Warning

-redact auto can miss faint, very small or handwritten text, or text over a busy part of the picture. Look at the picture before you send it.

See also

Options

Render a DICOM image as a picture that is safe to hand on

USAGE:
  go-dicom share [options] <input.dcm> <output.png|.jpg|.jpeg>

  Writes the image as a viewer shows it: rescaled, windowed and at 8 bits.
  The output's extension is its format. The picture holds pixels only, so no
  name, date or identifier from the file is in it, and the input is never
  changed.

OPTIONS:
  -redact x,y,w,h    Fill a rectangle with black in every frame, counted in
                     pixels from the top left. Repeat it for more rectangles.
  -redact auto       Fill the regions in which a detector finds text. It can
                     miss: look at the picture before you hand it on. When
                     what is found covers more than a quarter of the
                     picture, more than text does, nothing is written.
  -preview           Write the picture with those regions outlined and
                     nothing redacted, to see what auto would fill. Not for
                     handing on: the text is all still in it.
  -detect            Print those regions, as -redact takes them, and write
                     nothing: go-dicom share -detect ultrasound.dcm
  -allow-burned-in   Render an image that may hold burned-in text as it is.
  --window <c,w>     Window center and width (default: the file's own, or
                     the full range of the data when it has none).
  --frame <n|all>    The frame to write, counted from 1 (default: 1). With
                     "all", frames go to name-0001.png, name-0002.png, ...
  --quality <1-100>  JPEG quality (default: 90). PNG is lossless.
  -h, -help          Show this help message

BURNED-IN TEXT:
  Removing the attributes does nothing for a name drawn into the picture,
  which ultrasound, endoscopy, secondary captures and screen captures often
  have. An image whose Burned In Annotation is YES, or that is of such a kind
  and does not say NO, is refused unless -redact says where the text is or
  -allow-burned-in says there is none. -redact auto finds text for you and is
  not a promise: a detector misses text that is faint, very small, hand
  written or drawn over a busy part of the picture. Look at the picture
  before you send it.

EXAMPLES:
  go-dicom share ct.dcm ct.png --window 40,400
  go-dicom share -redact 0,0,640,40 ultrasound.dcm ultrasound.png
  go-dicom share -preview ultrasound.dcm check.png
  go-dicom share -redact auto ultrasound.dcm ultrasound.png
  go-dicom share cine.dcm frame.jpg --frame all

On this page