Extracted Image from original dataset not the same as image stored in hdf5
euwern opened this issue · comments
I grab the image from Camelyon16 dataset according to the provided meta.csv file, but the extracted image isn't the same as the image found in hdf5.
Is there anything wrong with my approach of extracting image from the dataset based on the given meta?
import openslide
import pandas as pd
import h5py
from PIL import Image
img_id = 0
df = pd.read_csv('../../dataset/pcam/camelyonpatch_level_2_split_test_meta.csv')
fn = df['wsi'][img_id][-8:]
slide = openslide.open_slide('/mnt/datasets/CAMELYON16/testing/images/%s.tif' % fn)
x = df['coord_x'][img_id]
y = df['coord_y'][img_id]
img = slide.read_region((x, y), 2, (96, 96))
img.save('pcam_sample/%s_1.tif' % fn)
data = h5py.File('../../dataset/pcam/camelyonpatch_level_2_split_test_x.h5', 'r')
img2 = Image.fromarray(data['x'][img_id])
img2.save('pcam_sample/%s_2.tif' % fn)