[Python] Few questions on a medical dataset

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently working on a medical dataset containing whole slide images (~300 images).

    These images are pretty big (.tif, average of 7k by 7k pixels). I am currently dividing each of these images into patches of size 224x224 and getting rid of the images showing just the background. Here is a code I quickly made for that using the patchify module I found.

    import cv2
    from patchify import patchify
    import numpy as np

    img = cv2.imread('path/to/image.tif')

    patches = patchify(img, (224,224,3), step=(224,224,3))

    def is_blank(img, threashold=1):
    return np.std(img)<threshold

    filtered_patches = []

    for k in range(patches.shape[0]):
    for n in range(patches.shape[1]):
    for m in range(patches.shape[2]):
    # print(np.std(patches[k][n][m]))
    if not is_blank(patches[k][n][m]):
    filtered_patches.append(patches[k][n][m])


    I was wondering if there was a more efficient/optimized way of first divinding each image in patches and then flagging the background images (which are almost completely white).

    These images also come with color-annotated images (see the link below) that I am also going to divide into patches and I was wondering how I could detect which colors (RGB) are in a given image, because these colors correspond to a type of tissue. link to the whole-slide image and the color-annotated image

    Here is the dataset : https://espace.library.uq.edu.au/view/UQ:8be4bd0

    Continue reading...

Compartilhe esta Página