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.

dataset_sample_view.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # import libtiff
  2. # import pytiff
  3. import cv2
  4. import tifffile
  5. def show_tif_image(address, name, key=0, w_from=0, h_from=0, size=700, whole_image=False):
  6. import zarr
  7. image_zarr = tifffile.imread(address, aszarr=True, key=key)
  8. zarr = zarr.open(image_zarr, mode='r')
  9. if not whole_image:
  10. image_frag = zarr[w_from:min(w_from + size, zarr.shape[0]), h_from:min(h_from + size, zarr.shape[1])]
  11. else:
  12. image_frag = zarr[0:zarr.shape[0], 0:zarr.shape[1]]
  13. cv2.imshow(f"name:{name} - shape:{image_frag.shape} - page:{key}", image_frag)
  14. print(f"name: {name}, shape: {zarr.shape}")
  15. image_zarr.close()
  16. def show_CAMELYON16_sample_view():
  17. # show_tif_image('data/CAMELYON16/tumor_084.tif', "CAMELYON16", key=7)
  18. show_tif_image('data/CAMELYON16/tumor_084.tif', "CAMELYON16", key=0, w_from=10000, h_from=50000)
  19. def show_CAMELYON17_sample_view():
  20. show_tif_image('data/CAMELYON17/patient_083_node_4.tif', "CAMELYON17", key=7)
  21. def show_Papsociety_sample_view():
  22. image_frag = cv2.imread(
  23. 'data/Papsociety/Follicular_neoplasm2,_low_power,_confirmed_FVPTC_DQ_SM.jpg')
  24. cv2.imshow(f"Papsociety - {image_frag.shape}", image_frag)
  25. def show_test(name, ):
  26. # show_tif_image('data/CAMELYON16/tumor_084.tif', "CAMELYON16", key=7)
  27. show_tif_image('data/test/1272.tiff', name, key=0, w_from=1300, h_from=0, size=1000)
  28. if __name__ == '__main__':
  29. # show_CAMELYON16_sample_view()
  30. # show_CAMELYON17_sample_view()
  31. # show_Papsociety_sample_view()
  32. show_tif_image('data/test/1272.tiff', "1", key=0, w_from=1000, h_from=100, size=1000)
  33. show_tif_image('data/test/1272.tiff', "2", key=0, w_from=1000, h_from=1000, size=1000)
  34. while True:
  35. if cv2.waitKey(1) == ord('q'):
  36. break