User Tools

Site Tools


krokodil

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

krokodil [2020-05-18 02:44:23]
krokodil [2020-05-18 02:44:23] (current)
Line 1: Line 1:
 +====== 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 ====
 +
 +<​code>​
 +mkdir -p png/
 +for f in 00000*; do convert -depth 8 -negate -level 33,33% $f png/$f.pgm; done
 +</​code>​
 +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.
 +
 +<​code>​
 +jcc ppmblack.c
 +bash convertblack.sh
 +</​code>​
 +jcc is an alias to gcc with sane parameters, gcc -o ppmblack ppmblack.c should work for you too. See [[:​blobutils|bloutils]].
 +
 +==== Get rid of artifacts/​apparatus ====
 +
 +First, we compose all black objects in the images into a single image.
 +<​code>​
 +bash compose.sh
 +</​code>​
 +
 +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.
 +
 +<​code>​
 +bash cut.sh
 +</​code>​
 +You should now see clean slices in png/cut-*.
 +
 +==== Tracing the bitmap ====
 +
 +We will now convert the bitmap into vectors.
 +<​code>​
 +bash trace.sh
 +</​code>​
 +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.
 +
 +<​code>​
 +bash scad.sh
 +</​code>​
 +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)