Normalizer.py 700 B

123456789101112131415161718
  1. import numpy
  2. import logging
  3. logger = logging.getLogger(__name__)
  4. def normalize_image(frames, volumeId):
  5. logger.debug('volId: %s, float frames detected, normalize them' % volumeId)
  6. collection_min = frames.min()
  7. collection_max = frames.max()
  8. logger.debug('volId: %s, imagesmin: %d, imagesmax: %d' %(volumeId, collection_min, collection_max))
  9. # due to memory problems, we have to trigger it for each frame
  10. for frame in frames:
  11. for frame_slice in frame:
  12. frame_slice = (frame_slice - collection_min) / (collection_max - collection_min)
  13. logger.debug('volId: %s, after normalization imagesmin: %d, imagesmax: %d' %(volumeId, frames.min(), frames.max()))