<jupyter_start><jupyter_text>Image preprocessing<jupyter_code>import os
import numpy as np
from scout import io
from scout import preprocess
working_dir = '../images'<jupyter_output><empty_output><jupyter_text>Load TIFF image<jupyter_code>img = np.array([io.imread(os.path.join(working_dir, _)) for _ in os.listdir(working_dir) if _.endswith(".tiff")])

img.shape, img.dtype<jupyter_output><empty_output><jupyter_text>Remove background by thresholding<jupyter_code>threshold = 5000

img = preprocess.remove_background(img, threshold)
img.shape, img.dtype<jupyter_output><empty_output><jupyter_text>Image denoising<jupyter_code>sigma = 20

img = preprocess.denoise(img, sigma)
kernel_size = None
preprocess.clahe(img, kernel_size=kernel_size)<jupyter_output>0%|          | 0/5 [00:00<?, ?it/s][A[A[A[A[A[A[A[A[A[A[A[A[A/home/nijesh/anaconda3/envs/scout/lib/python3.6/site-packages/skimage/exposure/exposure.py:351: RuntimeWarning: invalid value encountered in true_divide
  image = (image - imin) / float(imax - imin)
/home/nijesh/anaconda3/envs/scout/lib/python3.6/site-packages/skimage/exposure/exposure.py:351: RuntimeWarning: invalid value encountered in true_divide
  image = (image - imin) / float(imax - imin)
/home/nijesh/anaconda3/envs/scout/lib/python3.6/site-packages/skimage/exposure/exposure.py:351: RuntimeWarning: invalid value encountered in true_divide
  image = (image - imin) / float(imax - imin)
/home/nijesh/anaconda3/envs/scout/lib/python3.6/site-packages/skimage/exposure/exposure.py:351: RuntimeWarning: invalid value encountered in true_divide
  image = (image - imin) / float(imax - imin)
/home/nijesh/anaconda3/envs/scout/lib/python3.6/site-packages/skimage/exposure/exposure.py:351: RuntimeWarning: inv[...]<jupyter_text>Histogram equalization Convert to Zarr<jupyter_code>zarr_path = os.path.join(working_dir, 'img_0001.zarr')
chunks = (64, 64, 64)

arr = io.new_zarr(zarr_path, 
                  shape=img.shape, 
                  dtype=img.dtype, 
                  chunks=chunks)

arr[:] = img<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13678105364910584, 'fraction_numerical': 0.025616239729337846, 'mean_word_length': 5.197604790419161, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '445833', 'license': 'MIT', 'n_tokens_mistral': 837, 'n_tokens_neox': 769, 'n_words': 115, 'path': 'notebooks/1 - preprocess.ipynb', 'repo_name': 'renardeinside/scout', 'size': '2069'}