User Tools

Site Tools


krokodil

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.

http://jenda.hrach.eu/gitweb/?p=krokodil;a=summary

Howto

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
bash convertblack.sh

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.

bash compose.sh

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.

bash cut.sh

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

Tracing the bitmap

We will now convert the bitmap into vectors.

bash trace.sh

potrace has lots of parameters you can fiddle with.

Converting the traces to SCAD

Get https://github.com/l0b0/paths2openscad.

Edit path to paths2openscad.py, layer height etc. in scad.sh.

bash scad.sh

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 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki