Using OpenCV to calculate the edges of the tissue on a slide
This tutorial applies to Python 2.7.
As shown elsewhere on this site, we can fetch snapshots of any size from PMA.core.lite. Once we have a snapshot we can further process it with OpenCV for example to calculate the boundaries of the tissue.
In order to run this example the following libraries need to be installed along with Python 2.7:
Windows users can download these binaries as .whl files from here: www.lfd.uci.edu/~gohlke/pythonlibs/
Once the correct whl files have been downloaded they can be installed using pip.
The steps to calculate the contours for the tissue in a whole slide image, presented in this example are:
- Fetch an image snapshot from PMA.core.lite (as illustrated in the snapshot example above)
- Convert the image’s color space from RGB to HSV
- Perform a gaussian blur
- Calculate a threshold value to convert the image to black & white using Otsu’s method
- Find the contours using OpenCV
- Plot the contours on top of the image
Here you can download the source code in Python for the image analysis examples.
To run the examples modify the code accordingly to point to a directory in your system that contains whole slide images and issue: