You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is contrast enhancement applied on extracted patches ? #93
I notice a clear difference in patches provided in patch directory to those that are created using dump_patches. Is their any normalization applied on these patches after extraction from WSI ?
for st in iter_hest('data_path', id_list=['TENX99']):
patch_save_dir = 'path_dir'
new_patch_size = 256
st.dump_patches(patch_save_dir, name='demo', target_patch_size=new_patch_size, target_pixel_size=0.5
)
256*256 size at 0.5um/pixel images provided in patches directory of hest data is on left and one extracted from .tif using above method is on right side.
changed the title [-]Is stain normalization applied on extracted patches ?[/-][+]Is contrast enhancement applied on extracted patches ?[/+]on Feb 6, 2025
import h5py
import numpy as np
from PIL import Image
h5_file_path = "/home/demo.h5"
with h5py.File(h5_file_path, "r") as h5f:
barcodes = h5f['barcode'][:]
barcodes = barcodes.astype(str)
if '221x099' in barcodes:
barcode_index = np.where(barcodes == '221x099')[0][0]
img_patch = h5f["img"][barcode_index]
img = Image.fromarray(img_patch)
img.save('/home/TENX99_221x099.png' , format="PNG", compress_level=0)
It could be compression but I don't see why there should be compression. I am doing the same for both the patches/TENX99.h5 and demo.h5 created from TENX99.tif . The picture from patches/TENX99.h5 is far better. Please help !
Hi @abhi1998goyal,
We slightly modified dump_patches after creating the patches in patches/. The variation you see might be due to a small offset/zoom difference between the old and the new implementation, but I don't think it affects the quality
Activity
[-]Is stain normalization applied on extracted patches ?[/-][+]Is contrast enhancement applied on extracted patches ?[/+]guillaumejaume commentedon Feb 7, 2025
No contrast enhancement nor stain norm has been applied. What you show could be compression artifacts.
abhi1998goyal commentedon Feb 7, 2025
It could be compression but I don't see why there should be compression. I am doing the same for both the patches/TENX99.h5 and demo.h5 created from TENX99.tif . The picture from patches/TENX99.h5 is far better. Please help !
guillaumejaume commentedon Feb 7, 2025
tbh, I don't see a huge difference between both images. Could you check the actual difference between both arrays using https://numpy.org/doc/2.1/reference/generated/numpy.allclose.html
abhi1998goyal commentedon Feb 8, 2025
Output: False False False True

pauldoucet commentedon Feb 8, 2025
Hi @abhi1998goyal,
We slightly modified
dump_patchesafter creating the patches inpatches/. The variation you see might be due to a small offset/zoom difference between the old and the new implementation, but I don't think it affects the quality