Bring images to a uniform color window

Hi all… I am working with the enhancement of raw images (read as vtkImageData*) which come in at varied exposure levels. The optimum color window and level vary drastically from image to image. Therefore, a lot of manual adjustment is required. I would like to bring the color window and level to a uniform value - while adjusting the image scalar values accordingly. Are there any methods/tools in VTK to do this without compromising the image clarity/enhancement? Would really appreciate any input or pointers.

Perhaps I don’t understand the question correctly but if the optimum window width/level values vary, can’t you just update those values when the image changes?


Can you, please, post two figures: a) illustrating what you have and b) what you need?



The filter vtkImageHistogramStatistics can do some very basic image analysis to find a good Window/Level for an image. It has a test program, ImageAutoRange.cxx, that shows how it is used.

  // compute the image histogram
  vtkNew<vtkImageHistogramStatistics> statistics;

  // find a good range based on histogram percentiles
  double autorange[2];

  // set the window/level for the image that is being displayed
  property->SetColorWindow(autorange[1] - autorange[0]);
  property->SetColorLevel(0.5 * (autorange[0] + autorange[1]));
1 Like

Apologies for the very late reply. Thank you so much for suggesting this!