Fyi, HiResScreenCapture module of slicermorph does this fine. You may need s preview version of slicer to run it (current stable lake the features we need)
It would be great if you could share your method here so that other people (and chatbots) can learn : )
Hi @pieper, Sorry for the delay in writing this up.
My quick overview for making scale bars in images for publication. Note that I pay The Adobe Tax and use Photoshop and Illustrator; this is largely because many of the journals I submit to accept these formats natively. In short, this works for me, it is almost certainly not the best way. (Your mileage may vary.)
Method number 1:
- Segment your shell (or whatever). Change slicer to Orthogonal view (NOT perspective).
- in 3D view, position your model as close as possible to how you’re planning on rendering it in Blender.
- Turn on the scale bar in 3D view.
- Take a screen capture and keep it as your “reference”.
- Export your 3D model and then import into a blender scene.
- Change the blender camera to Orthogonal and arrange the view so it is as close as possible to your Slicer reference picture.
- Render out to whatever resolution you like and save this as your “rendered” image. This step is a primary reason why I use Blender to do this - I often render 600 dpi images that are over 30" in a single dimension.
- In photoshop or Illustrator, load in your reference and rendered images in 2 separate layers. Place your rendered image behind the reference.
- Change the opacity of the reference so that you can see the rendered image behind it.
- Uniformly scale the reference image until it matches the rendered image.
- Make a new layer. With the line tool, draw a scale bar over the scale bar present in the reference image.
- make the reference image invisible. You now have a scale bar line that matches the scale. It is arguably not precise, but for most things, it is more than sufficient.
Method 2: probably more precise.
- In Slicer, make a new segment in your segmentation that is a 1x1x1 cube. You’ll have to pick the appropriate units for whatever you’re working on; for me I think I used 1cm on a side. You can do this in code using the python function below; I have this in my .slicerrc.py file.
- Export this as a model along with your segmented item (shell, whatever).
- Import both of these into blender. You now have something that is of perfect known dimensions in Blender, so you can arrange it as needed to make a scale bar either in Blender or in another application.
I generally use method 1 far more often than method 2. I find it to be good enough for my work.
def CubeSegment(volumeName, segmentationName, segmentName, sizeInMillimeters):
volumeNode = getNode(volumeName)
segmentationNode = getNode(segmentationName)
segmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(segmentName)
one_unit = round( sizeInMillimeters / volumeNode.GetSpacing()[0] )
segmentArray = slicer.util.arrayFromSegmentBinaryLabelmap(segmentationNode, segmentId, volumeNode)
segmentArray[:] = 0
segmentArray[0:one_unit, 0:one_unit, 0:one_unit] = 1
slicer.util.updateSegmentBinaryLabelmapFromArray(segmentArray, segmentationNode, segmentId, volumeNode)
Did you try the HiResScreenCapture module in SlicerMorph (you need a preview version)?
It may save you a few steps. I went as far as 9000-10000px, but haven’t tried 18000px.