### Install histolab via pip Source: https://histolab.readthedocs.io/en/latest/quickstart.html Install the histolab package using pip. ```bash pip install histolab ``` -------------------------------- ### Install histolab via conda Source: https://histolab.readthedocs.io/en/latest/quickstart.html Install the histolab package using conda. ```bash conda install -c conda-forge histolab ``` -------------------------------- ### Import example data Source: https://histolab.readthedocs.io/en/latest/quickstart.html Import the prostate and ovarian tissue slides from the histolab data module. ```python from histolab.data import prostate_tissue, ovarian_tissue ``` -------------------------------- ### Local environment setup Source: https://histolab.readthedocs.io/en/latest/contributing.html Commands to set up the local development environment, including installing dependencies and pre-commit hooks. ```bash pip install -e .[testing] pip install -r requirements-dev.txt pre-commit install pytest tests/ ``` -------------------------------- ### Prostate slide info output Source: https://histolab.readthedocs.io/en/latest/quickstart.html Example output for prostate slide information. ```text Slide name: 6b725022-f1d5-4672-8c6c-de8140345210 Levels: [0, 1, 2] Dimensions at level 0: (16000, 15316) Dimensions at level 1: (4000, 3829) Dimensions at level 2: (2000, 1914) ``` -------------------------------- ### Magnification factor output Source: https://histolab.readthedocs.io/en/latest/quickstart.html Example output for magnification factors. ```text Native magnification factor: 20X Magnification factor corresponding to level 1: 5.0X ``` -------------------------------- ### Ovarian slide info output Source: https://histolab.readthedocs.io/en/latest/quickstart.html Example output for ovarian slide information. ```text Slide name: b777ec99-2811-4aa4-9568-13f68e380c86 Levels: [0, 1, 2] Dimensions at level 0: (30001, 33987) Dimensions at level 1: (7500, 8496) Dimensions at level 2: (1875, 2124) ``` -------------------------------- ### Download and get slide paths Source: https://histolab.readthedocs.io/en/latest/quickstart.html Download the WSI from the corresponding repository and save the slide in a cached directory. Each function outputs the corresponding slide and the path where the slide has been saved. ```python prostate_svs, prostate_path = prostate_tissue() ovarian_svs, ovarian_path = ovarian_tissue() ``` -------------------------------- ### Install Pixman 0.40 on Windows (pacman) Source: https://histolab.readthedocs.io/en/latest/installation.html Installs Pixman version 0.40 using pacman, the package manager for MSYS2. ```bash pacman -S mingw-w64-x86_64-pixman ``` -------------------------------- ### Build Pixman from Source Source: https://histolab.readthedocs.io/en/latest/installation.html Downloads, extracts, configures, builds, and installs Pixman from source. ```bash wget https://cairographics.org/releases/pixman-0.40.0.tar.gz tar -xvf pixman-0.40.0.tar.gz cd pixman-0.40.0 ./configure make sudo make install ``` -------------------------------- ### Verify Pixman Installation on macOS Source: https://histolab.readthedocs.io/en/latest/installation.html Lists installed Pixman versions on macOS using brew. ```bash brew list --versions pixman ``` -------------------------------- ### Install histolab via pip Source: https://histolab.readthedocs.io/en/latest/readme.html The histolab package can be installed via pip. ```bash pip install histolab ``` -------------------------------- ### Verify Pixman Installation on Ubuntu Source: https://histolab.readthedocs.io/en/latest/installation.html Checks the installed Pixman library versions on Ubuntu using ldconfig. ```bash ldconfig -v | grep libpixman ``` -------------------------------- ### BinaryOpening Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of BinaryOpening filter. ```python from histolab.filters.morphological_filters import BinaryOpening from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold from PIL import Image image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() uts_threshold = OtsuThreshold() binary_opening = BinaryOpening() image_gray = rgb_to_grayscale(image_rgb) binary_image = otsu_threshold(image_gray) image_opened = binary_opening(binary_image) ``` -------------------------------- ### Install Pixman 0.40 on Ubuntu (Conda) Source: https://histolab.readthedocs.io/en/latest/installation.html Installs Pixman version 0.40 using conda for Ubuntu environments. ```bash conda install -c anaconda pixman==0.40 ``` -------------------------------- ### WhiteTopHat Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of WhiteTopHat filter. ```python from PIL import Image import numpy as np from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold from histolab.filters.morphological_filters import WhiteTopHat image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() uts_threshold = OtsuThreshold() white_that = WhiteTopHat(np.ones((5,5))) image_gray = rgb_to_grayscale(image_rgb) binary_image = otsu_threshold(image_gray) image_out = white_that(binary_image) ``` -------------------------------- ### Install Pooch Source: https://histolab.readthedocs.io/en/latest/api/data.html Pooch is an optional requirement for `histolab` and needs to be installed separately. ```bash pip install pooch ``` -------------------------------- ### Install histolab via conda Source: https://histolab.readthedocs.io/en/latest/readme.html The histolab package can be installed via conda. ```bash conda install -c conda-forge histolab ``` -------------------------------- ### Grid Extraction Source: https://histolab.readthedocs.io/en/latest/quickstart.html To retrieve all available tiles using a grid structure, use the GridTiler extractor. This example demonstrates initializing GridTiler with parameters for tile size, extraction level, and pixel overlap. ```python from histolab.tiler import GridTiler ``` ```python grid_tiles_extractor = GridTiler( tile_size=(512, 512), level=0, check_tissue=True, # default pixel_overlap=0, # default prefix="grid/", # save tiles in the "grid" subdirectory of slide's processed_path suffix=".png" # default ) ``` ```python grid_tiles_extractor.locate_tiles( slide=ovarian_slide, scale_factor=64, alpha=64, outline="#046C4C", ) ``` ```python grid_tiles_extractor.extract(ovarian_slide) ``` -------------------------------- ### RgbToHsv Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example of converting RGB channels to HSV channels. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToHsv >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_hsv = RgbToHsv() >>> image_hsv = rgb_to_hsv(image_rgb) ``` -------------------------------- ### AdaptiveEqualization Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example demonstrating how to use the AdaptiveEqualization filter to enhance image contrast. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import AdaptiveEqualization, RgbToGrayscale >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> adaptive_equalization = AdaptiveEqualization() >>> image_gray = rgb_to_grayscale(image_rgb) >>> image_clahe = adaptive_equalization(image_gray) ``` -------------------------------- ### BinaryDilation Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of BinaryDilation to dilate a binary mask. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold >>> from histolab.filters.morphological_filters import BinaryDilation >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> otsu_threshold = OtsuThreshold() >>> binary_dilation = BinaryDilation() >>> image_gray = rgb_to_grayscale(image_rgb) >>> binary_image = otsu_threshold(image_gray) >>> image_dilated = binary_dilation(binary_image) ``` -------------------------------- ### FiltersComposition Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/compositions.html Example of how to use FiltersComposition with Slide and Tile classes. ```python from histolab.filters.compositions import FiltersComposition from histolab.slide import Slide from histolab.tile import Tile filters_slide = FiltersComposition(Slide).tissue_mask_filters filters_tile = FiltersComposition(Tile).tissue_mask_filters ``` -------------------------------- ### BinaryErosion Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of BinaryErosion to erode a binary mask. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold >>> from histolab.filters.morphological_filters import BinaryErosion >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> otsu_threshold = OtsuThreshold() >>> binary_erosion = BinaryErosion(disk_size=6) >>> image_gray = rgb_to_grayscale(image_rgb) >>> binary_image = otsu_threshold(image_gray) >>> image_eroded = binary_erosion(binary_image) ``` -------------------------------- ### HysteresisThreshold Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/image_filters.html Example of how to use the HysteresisThreshold filter. ```python from PIL import Image from histolab.filters.image_filters import HysteresisThreshold, RgbToGrayscale image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() hyst_threshold = HysteresisThreshold(low=200, high=250) image_gray = rgb_to_grayscale(image_rgb) image_thresholded = hyst_threshold(image_gray) ``` -------------------------------- ### WatershedSegmentation Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of WatershedSegmentation filter. ```python import numpy as np from histolab.filters.morphological_filters import WatershedSegmentation mask = np.array([[0,1],[1,0]]) # or np.load("/path/my_array_mask.npy") watershed_segmentation = WatershedSegmentation() mask_segmented = watershed_segmentation(mask) ``` -------------------------------- ### StretchContrast Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/image_filters.html Example of how to use the StretchContrast filter to increase image contrast. ```python from PIL import Image from histolab.filters.image_filters import RgbToGrayscale, StretchContrast image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() stretch_contrast = StretchContrast() image_gray = rgb_to_grayscale(image_rgb) image_stretched = stretch_contrast(image_gray) ``` -------------------------------- ### LocalOtsuThreshold Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/image_filters.html Example of how to use the LocalOtsuThreshold filter. ```python from PIL import Image from histolab.filters.image_filters import LocalOtsuThreshold, RgbToGrayscale image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() local_otsu = LocalOtsuThreshold() image_gray = rgb_to_grayscale(image_rgb) image_thresholded_locally = local_otsu(image_gray) ``` -------------------------------- ### Verify Pixman Installation on Windows (PowerShell) Source: https://histolab.readthedocs.io/en/latest/installation.html Retrieves the version information of the libpixman-1-0.dll file on Windows using PowerShell. ```powershell (Get-Item "C:\OpenSlide\bin\libpixman-1-0.dll").VersionInfo | format-list ``` -------------------------------- ### BinaryFillHoles Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of BinaryFillHoles to fill holes in binary objects. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold >>> from histolab.filters.morphological_filters import BinaryFillHoles >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> otsu_threshold = OtsuThreshold() >>> binary_fill_holes = BinaryFillHoles() >>> image_gray = rgb_to_grayscale(image_rgb) >>> binary_image = otsu_threshold(image_gray) >>> image_filled_holes = binary_fill_holes(binary_image) ``` -------------------------------- ### RemoveSmallObjects Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of RemoveSmallObjects filter. ```python from PIL import Image from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold from histolab.filters.morphological_filters import RemoveSmallObjects image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() uts_threshold = OtsuThreshold() remove_small_objects = RemoveSmallObjects() image_gray = rgb_to_grayscale(image_rgb) binary_image = otsu_threshold(image_gray) image_no_small_objects = remove_small_objects(binary_image) ``` -------------------------------- ### BlueFilter Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example demonstrating how to use the BlueFilter to filter out blueish colors from an RGB image. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import BlueFilter >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/wsi-blue-pen.png") >>> blue_filter = BlueFilter(30, 20, 105) >>> mask_filtered = blue_filter(image_rgb) ``` -------------------------------- ### K-means Segmentation Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Demonstrates how to use the KmeansSegmentation filter to segment an RGB image. ```python from PIL import Image from histolab.filters.image_filters import KmeansSegmentation image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") kmeans_segmentation = KmeansSegmentation() kmeans_segmented_image = kmeans_segmentation(image_rgb) ``` -------------------------------- ### BlueFilter Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/image_filters.html Example of how to use the BlueFilter to filter out blueish colors in an RGB image. ```python from PIL import Image from histolab.filters.image_filters import BlueFilter image_rgb = Image.open("tests/fixtures/pil-images-rgb/wsi-blue-pen.png") blue_filter = BlueFilter(30, 20, 105) mask_filtered = blue_filter(image_rgb) ``` -------------------------------- ### Local Equalization Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Shows how to apply local equalization to a grayscale image to enhance contrast. ```python from PIL import Image from histolab.filters.image_filters import LocalEqualization image_rgb = Image.open("tests/fixtures/pil-images-gs/diagnostic-slide-thumb-gs.png") local_equ = LocalEqualization() local_equ_image = local_equ(image_rgb) ``` -------------------------------- ### Otsu Threshold Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example of applying Otsu's thresholding to a grayscale image. ```python >>> otsu_threshold = OtsuThreshold() >>> image_gray = rgb_to_grayscale(image_rgb) >>> image_thresholded_array = otsu_threshold(image_gray) ``` -------------------------------- ### RgbToGrayscale Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example of converting an RGB image to grayscale using RgbToGrayscale. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToGrayscale >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> image_gray = rgb_to_grayscale(image_rgb) ``` -------------------------------- ### Hysteresis Threshold Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Shows how to apply hysteresis thresholding to an RGB image after converting it to grayscale. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import HysteresisThreshold, RgbToGrayscale >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> hyst_threshold = HysteresisThreshold(low=200, high=250) >>> image_gray = rgb_to_grayscale(image_rgb) >>> image_thresholded = hyst_threshold(image_gray) ``` -------------------------------- ### BluePenFilter Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example demonstrating how to use the BluePenFilter to filter out blue pen marks from a diagnostic slide. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import BluePenFilter >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/wsi-blue-pen.png") >>> blue_pen_filter = BluePenFilter() >>> image_no_blue = blue_pen_filter(image_rgb) ``` -------------------------------- ### BinaryClosing Example Source: https://histolab.readthedocs.io/en/latest/api/filters/morphological_filters.html Example demonstrating the use of BinaryClosing to close a binary mask, which can remove small holes. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold >>> from histolab.filters.morphological_filters import BinaryClosing >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> otsu_threshold = OtsuThreshold() >>> binary_closing = BinaryClosing() >>> image_gray = rgb_to_grayscale(image_rgb) >>> binary_image = otsu_threshold(image_gray) >>> image_closed = binary_closing(binary_image) ``` -------------------------------- ### BinaryMask Example Source: https://histolab.readthedocs.io/en/latest/api/masks.html This example demonstrates how to create a custom binary mask by subclassing BinaryMask and implementing the _mask method. ```python >>> from histolab.slide import Slide >>> class MyCustomMask(BinaryMask): ... def _mask(self, slide): ... my_mask = np.array([0,1]) ... return my_mask >>> binary_mask = MyCustomMask() >>> slide = Slide("path/to/slide") >>> binary_mask(slide) ``` -------------------------------- ### Otsu Threshold Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Illustrates computing an Otsu threshold on a grayscale image to create a boolean mask. ```python from PIL import Image from histolab.filters.image_filters import OtsuThreshold, RgbToGrayscale image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() ``` -------------------------------- ### Lazy Property Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/util.html Example usage of a lazy property, demonstrating its getter behavior and immutability. ```python class Obj(object): @lazyproperty def fget(self): return 'some result' obj = Obj() ``` -------------------------------- ### Hysteresis Threshold Mask Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Demonstrates creating a boolean mask using hysteresis thresholding on a grayscale image. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import HysteresisThresholdMask, RgbToGrayscale >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> hyst_threshold_mask = HysteresisThresholdMask() >>> image_gray = rgb_to_grayscale(image_rgb) >>> image_thresholded_array = hyst_threshold_mask(image_gray) ``` -------------------------------- ### GreenChannelFilter Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example usage of the GreenChannelFilter to create a binary mask based on the green channel threshold. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import GreenChannelFilter >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> g_channel_filter = GreenChannelFilter(avoid_overmask=True, overmask_thresh=90) >>> image_thresholded_array = g_channel_filter(image_rgb) ``` -------------------------------- ### DABChannel Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/image_filters.html Example of how to use the DABChannel filter to extract the DAB channel from an RGB image. ```python from PIL import Image from histolab.filters.image_filters import DABChannel image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") dab_channel = DABChannel() image_d = dab_channel(image_rgb) ``` -------------------------------- ### BinaryOpening Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/morphological_filters.html Example of using BinaryOpening to remove small objects from a binary mask. ```python from PIL import Image from histolab.filters.image_filters import RgbToGrayscale, OtsuThreshold from histolab.filters.morphological_filters import BinaryOpening image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() otşu_threshold = OtsuThreshold() binary_opening = BinaryOpening() image_gray = rgb_to_grayscale(image_rgb) binary_image = otsu_threshold(image_gray) image_opened = binary_opening(binary_image) ``` -------------------------------- ### Histogram Equalization Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Demonstrates how to apply histogram equalization to an RGB image after converting it to grayscale. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import HistogramEqualization, RgbToGrayscale >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> histogram_equalization = HistogramEqualization() >>> image_gray = rgb_to_grayscale(image_rgb) >>> image_he = histogram_equalization(image_gray) ``` -------------------------------- ### RedFilter Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example of using RedFilter to mask reddish colors in an RGB image. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RedFilter >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-red-pen.png") >>> red_filter = RedFilter(10, 30, 25) >>> mask_filtered = red_filter(image_rgb) ``` -------------------------------- ### Lab to RGB Conversion Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Illustrates the conversion of an image from Lab color space to RGB using the LabToRgb filter. ```python import numpy as np from histolab.filters.image_filters import LabToRgb arr_lab = np.load("tests/fixtures/arrays/diagnostic-slide-thumb-lab.npy") lab_to_rgb = LabToRgb() image_rgb = lab_to_rgb(arr_lab) ``` -------------------------------- ### YenThreshold Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Apply Yen thresholding to create a boolean mask based on pixel values using the YenThreshold filter. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RgbToGrayscale, YenThreshold >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") >>> rgb_to_grayscale = RgbToGrayscale() >>> yen_threshold = YenThreshold() >>> image_gray = rgb_to_grayscale(image_rgb) >>> image_thresholded_array = yen_threshold(image_gray) ``` -------------------------------- ### YenThreshold Example Source: https://histolab.readthedocs.io/en/latest/_modules/histolab/filters/image_filters.html Example of how to use YenThreshold to mask an image based on pixel values relative to the Yen threshold. ```python from PIL import Image from histolab.filters.image_filters import RgbToGrayscale, YenThreshold image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-lung-rgb.png") rgb_to_grayscale = RgbToGrayscale() yen_threshold = YenThreshold() image_gray = rgb_to_grayscale(image_rgb) image_thresholded_array = yen_threshold(image_gray) ``` -------------------------------- ### RedPenFilter Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example of using RedPenFilter to filter out red pen marks on diagnostic slides. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import RedPenFilter >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-red-pen.png") >>> red_pen_filter = RedPenFilter() >>> image_no_red = red_pen_filter(image_rgb) ``` -------------------------------- ### GreenPenFilter Example Source: https://histolab.readthedocs.io/en/latest/api/filters/image_filters.html Example of using GreenPenFilter to filter out green pen marks from a diagnostic slide. ```python >>> from PIL import Image >>> from histolab.filters.image_filters import GreenPenFilter >>> image_rgb = Image.open("tests/fixtures/pil-images-rgb/tcga-green-pen.png") >>> green_pen_filter = GreenPenFilter() >>> image_no_green = green_pen_filter(image_rgb) ```