Interested in options in drawing 1 bit per pixel images from slice geometry

I am writing code to generate images from slice data at very high resolution. These images will be written to files using a 1 bit per pixel format. I am able to slice the geometry easily but need a good pipeline to solve a few needs:

  1. Take a 2D slice and output to an image
  2. The image is a 1 bit per pixel Tiff format.
  3. The edge pixels need to be on or off based on a percentage inside the outer contour.

I have tried a few options but the 1 BPP is alluding me and how to determine the percentage of each pixel inside the geometry. If anyone has done anything similar any suggestions would be greatly appreciated.

Thanks for any pointers.
Tom

When you say “outer” contour, does this imply there is also an “inner” contour?

I’m not sure if it fits your requirements, but VTK has a class called vtkPolyDataToImageStencil that slices polydata and generates a stack of binary images. However,

  1. It uses a simple inside/outside check: if the pixel is on the “inside” side the contour, it’s on, and if it’s on the “outside” side, it’s off. There is no percentage calculation.
  2. The output data (vtkImageStencilData) isn’t 1 BPP, it’s actually a run-length compression of a 1BPP image. A custom class would be needed to write it out to a TIFF.