Export Volume Rendering as stack of PNG's. NOT stl's

By default, number of decimals was set to 2. I’ve updated the pull request.

1 Like

Also now the images default to VTK MultiVolume rendering. For our purposes, we need the GPU RayCasting. It would be nice to be able to control this in the volume rendering. Can this be reset?

nick

I don’t think it is related. You can set default volume rendering method in application settings.

1 Like

Thanks for all the updates. Can you explain what you did to resize the images? The scale is no longer seems to be correct. It seems to be almost filling the image created but not quite. So its not strictly based on ROI. The output that we were getting from the last build created images at the correct scale.

Exactly that. ROI size + a few percent margin, to maximize the details that can be represented in the fixed number of pixels. Resolution was not explicitly set before, so if it was “correct” then it was probably incidental.

Is there a specific pixel size that you would like to have in the output (and image size in pixels would be adjusted accordingly)?
Or, would you prefer specifying image size in pixels and compute the resulting pixel size (DPI) and save it in the png file?

Yes. Typically I take the images into photoshop to further process. This involves setting the scale to have a resolution of x=300 y=600 DPI for the printer (the images are skewed for printing purposes). Then limit the image to 6 colors because the printers can only handle 6 base colors, then a 50% dither is applied.

If we could get the image to print at 300x600 dpi that would be ideal.

@ahmedhosny wrote a python for dithering that could be incorporated to finish the process.

It would be nice to have the full process in slicer.

This works now. I’ve implemented proper physical scaling of the exported image slices. You can specify DPI separately for x and y axes. These DPI values are also encoded in the png file, so they appear correctly in image editing programs or when printed. You can also specify object scale, which allows you to print the object smaller or larger than real physical size.

Are the 6 colors: CMYK + transparent + support material?
In the described workflow, I did not find anything about color separation and colored dithering, do you have a code for it already?

If yes, we should be able to use that code directly in Slicer. If you don’t have code for this (e.g., because you’ve done it so far in Photoshop), then we could implement this, potentially quite easily:

  • Color separation: Basic implementation (that does not use ICC profiles based color matching, just generic approximations) is trivial.
  • Colored dithering: We would need to know if there are any constraints on the generated material images. Is the sum of pixel values among all materials at a specific position must be a specific number (if yes, what is that number 1, 16, …, 256?) or there is a maximum value?

It appears this Add-in is not loading properly in the new build. I’m just seeing the constructor addin come though on loading. Any thoughts?

Can you look in the error log and post anything that looks related?

loadSourceAsModule - Failed to load file "C:/Users/njacobson/AppData/Roaming/NA-MIC/Extensions-27931/SlicerFab/lib/Slicer-4.10/qt-scripted-modules/BitmapGenerator.py" as module "BitmapGenerator" !

Fail to instantiate module "BitmapGenerator"

There should be a little more info in the log file, like a python stack trace - do you see anything like that?

Sure, below are all the errors I am getting, in addition to the previous one sent.

Stream : Traceback (most recent call last):

File “”, line 1, in

File “C:/Users/njacobson/AppData/Roaming/NA-MIC/Extensions-27931/SlicerFab/lib/Slicer-4.10/qt-scripted-modules/BitmapGenerator.py”, line 21

self.parent.contributors = [“Steve Pieper (Isomics, Inc.), Steve Keating (MIT), Ahmed Hosny (Harvard), James Weaver (Harvard)”, Andras Lasso (Queens)] # replace with “Firstname Lastname (Organization)”

^

SyntaxError: invalid syntax

Python : Scripted subject hierarchy plugin registered: Annotations

Python : Scripted subject hierarchy plugin registered: SegmentEditor

Scripted subject hierarchy plugin registered: SegmentStatistics

QT : Scripted subject hierarchy plugin registered: SegmentEditor

Scripted subject hierarchy plugin registered: SegmentStatistics

Probably this simple change will fix it: https://github.com/SlicerFab/SlicerFab/pull/9/files

Thanks. Do I just reload this from the extension manager to try this fix?

It’ll be in the extension manager tomorrow.

If you don’t want to wait then you can update BitmapGenerator.py locally (just a single-line change).

1 Like

That worked! Thank you.

As an aside, there are two approaches for color 3D printing. One uses PNGs for a voxel approach. The other uses a mesh with either colored vertices or a texture map. Shapeways supports the latter approach using the archaic X3D or VRML formats. The image below shows how the mesh can incorporate color for both a statistical map as well as emphasizing ambient occlusion using a curvature map.

@pieper
Just loaded in a .ply file and activated the scalars to show color like tractography. I see in the Models Module under Display >Visibility > Views there is a view tab that includes ‘bitmap generator’. See attached. However, when I run the bitmap generator script I get 2,000 png’s or a flattened image of the .ply and not slices. Any idea how to slice these .ply bundles? Capture slice_0000

Hi @Nick -

Right now the BitmapGenerator code only slices the volume rendering (it iterates through the volume and sets the crop bounds) so models aren’t cropped.

Models have a different cropping infrastructure based on the slice planes. ou can find it further down in the Models module UI under clipping planes. It should be possible to extend the BitmapGenerator to control these as well. It’s not on my todo list, but I could make suggestions if you wanted to try.

HTH,
Steve

Yes. This is a new course of research for us. I’d love to work on it, send any suggestions you have!