You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5 KiB

10 years ago
10 years ago
10 years ago
  1. import numpy as np
  2. import skimage.io
  3. class Channel(object):
  4. def __init__(self, name, camera, exposure_time):
  5. self._name = name
  6. self._camera = camera
  7. self._exposure_time = exposure_time
  8. @property
  9. def name(self):
  10. if self._name is not None and self._name != "":
  11. return self._name
  12. return "UnnamedChannel"
  13. @property
  14. def camera(self):
  15. return self._camera
  16. @property
  17. def exposure_time(self):
  18. return self._exposure_time
  19. class ImageSet(object):
  20. """
  21. A group of images that share the same timestamp. NIS Elements doesn't store a unique timestamp for every
  22. image, rather, it stores one for each set of images that share the same field of view and z-axis level.
  23. """
  24. def __init__(self):
  25. self._images = []
  26. def add(self, image):
  27. """
  28. :type image: nd2reader.model.Image()
  29. """
  30. self._images.append(image)
  31. def __iter__(self):
  32. for image in self._images:
  33. yield image
  34. class Image(object):
  35. def __init__(self, timestamp, raw_array, height, width):
  36. self._timestamp = timestamp
  37. self._raw_data = raw_array
  38. self._height = height
  39. self._width = width
  40. @property
  41. def timestamp(self):
  42. # TODO: Convert to datetime object
  43. return self._timestamp
  44. @property
  45. def data(self):
  46. return np.reshape(self._raw_data, (self._height, self._width))
  47. def show(self):
  48. skimage.io.imshow(self.data)
  49. skimage.io.show()