User Tools

Site Tools


Krokodil, a DICOM to SCAD converter

Krokodil allows you to convert CT and MRI scans in DICOM to SCAD, so you can 3D-print plastic copies of your internal organs, which is something you secretly wanted since your childhood.;a=summary


You need inkscape, openscad, imagemagick, gcc and maybe something more.

Convert DICOM to PGM

mkdir -p png/
for f in 00000*; do convert -depth 8 -negate -level 33,33% $f png/$f.pgm; done

You will have to adjust the level according to your CT scan and which organ you want to print.

Flood-fill your images

The result of the above should be a black organ with white dots (and maybe some artifacts around it too). First we get rid of the white dots. ppmblack.c loads PGM image file and fills everything that is not connected by white with the [0,0][3,3] rectangle with black.

jcc ppmblack.c

jcc is an alias to gcc with sane parameters, gcc -o ppmblack ppmblack.c should work for you too. See bloutils.

Get rid of artifacts/apparatus

First, we compose all black objects in the images into a single image.


Now open png/out.png in GIMP (or an image editor of your choice). You will see artifacts and maybe other things we don't want to print (pieces of the CT apparatus, hair, …). Make the parts you want to print transparent and all the other parts white. (hint: Image → Mode → RGB). Save the file as png/mask.png.

Now we pass all the images through that mask.


You should now see clean slices in png/cut-*.

Tracing the bitmap

We will now convert the bitmap into vectors.


potrace has lots of parameters you can fiddle with.

Converting the traces to SCAD


Edit path to, layer height etc. in


It will take several minutes to process.

The output code is a valid SCAD code of you!

krokodil.txt · Last modified: 2020-05-18 02:44:23 (external edit)