Download second_dataset/expansion-microscopy/data/processing/process.py from sdu-chenxin/MDS-Bench-data: direct link, hf CLI and curl.
- Browser
- Download file 675 Bytes
-
https://huggingface.co/datasets/sdu-chenxin/MDS-Bench-data/resolve/main/second_dataset/expansion-microscopy/data/processing/process.py
- Command line
-
hf download hf://datasets/sdu-chenxin/MDS-Bench-data/second_dataset/expansion-microscopy/data/processing/process.py
-
curl -L -o process.py https://huggingface.co/datasets/sdu-chenxin/MDS-Bench-data/resolve/main/second_dataset/expansion-microscopy/data/processing/process.py
675 Bytes
| import cv2 | |
| import numpy as np | |
| import os | |
| from skimage.morphology import remove_small_objects | |
| def read_folder_volume(path): | |
| tiffs = [os.path.join(path, f) for f in os.listdir(path) if f[0] != '.'] | |
| fnames = sorted(tiffs) | |
| vol = [] | |
| for i, fname in enumerate(fnames): | |
| img = cv2.imread(fname, cv2.COLOR_BGR2GRAY) | |
| vol.append(img) | |
| vol = np.array(vol) | |
| return vol | |
| def binarize(array, threshold_value): | |
| return (array > threshold_value) | |
| def process_volume(path): | |
| vol = read_folder_volume(path) | |
| threshold = binarize(vol, 0.7) | |
| filtered = remove_small_objects(threshold, min_size=256, connectivity=3) | |
| return filtered |