pcam icon indicating copy to clipboard operation
pcam copied to clipboard

Extracted Image from original dataset not the same as image stored in hdf5

Open euwern opened this issue 6 years ago • 0 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)

euwern avatar Feb 26 '19 20:02 euwern