notes 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Save slice indexes at start when cutting up the image, so you can just
  2. use those later when stitching them together.
  3. Use a batch size of 1 on cpu.
  4. Increase number of epochs when using larger batch size on GPU.
  5. I did a few tests and found that increased batch size reduces accuracy on cpu. So I should increase the number of epochs to compensate on GPU. It's fine for GPU because of parallelization.
  6. imread_collection("*.png") seems to be a simple way to read all in a folder?
  7. https://scikit-image.org/docs/dev/user_guide/getting_started.html simpler
  8. >>> mask = camera < 87
  9. >>> # Set to "white" (255) the pixels where mask is True
  10. >>> camera[mask] = 255
  11. img.mean() returns the mean value. could be a better binarization metric?
  12. to fill the whole bitfield.
  13. >>> from skimage import exposure
  14. >>> image = exposure.rescale_intensity(img10bit, in_range=(0, 2**10 - 1))
  15. >>> image = exposure.rescale_intensity(img10bit, in_range='uint10')
  16. https://scikit-image.org/docs/dev/user_guide/data_types.html
  17. "You should never use astype on an image, because it violates these assumptions about the dtype range:"
  18. >>> image = exposure.rescale_intensity(img_int32, out_range=(0, 2**31 - 1))
  19. >>> img_uint8 = img_as_ubyte(image)
  20. Using an image from OpenCV with skimage¶
  21. If cv_image is an array of unsigned bytes, skimage will understand it by default. If you prefer working with floating point images, img_as_float() can be used to convert the image:
  22. >>>
  23. >>> from skimage.util import img_as_float
  24. >>> image = img_as_float(any_opencv_image)
  25. Using an image from skimage with OpenCV
  26. The reverse can be achieved with img_as_ubyte():
  27. These can replace my cutImage functions.
  28. np.pad !!! NOTE: skimage.util.pad is a wrapper for np.pad that appears in ancient code. !!!
  29. skimage.util.view_as_windows(arr_in, window_shape, step=1)
  30. numpy.vstack to take a list of arrays and stack them into one big array!