This package is a Julia language wrapper for OpenSlide.
OpenSlide is a vendor-neutral library providing a common API to read virtual slide images generated by several different microscope vendors.
Julia is a new language for technical computing with familiar and script-friendly syntax, an extensive mathematical library and array-oriented computing built-in, and a high performance just-in-time compiler (< 2x of C code).
The package may be added by running the following command at the Julia prompt:
julia> Pkg.add("OpenSlide")
Source code for the package is available from: http://github.com/ihnorton/OpenSlide.jl.git
The example image used in this notebook is available from: http://openslide.cs.cmu.edu/download/openslide-testdata/
In [1]:
# load the package
using OpenSlide
# construct path to test file inside of directory
# note: test file is not part of code distribution and must be downloaded separately.
imgfile = Pkg.dir("OpenSlide", "test", "CMU-1-Small-Region.svs")
Out[1]:
In [2]:
# load the slide
@time img = OpenSlide.open_slide(imgfile)
Out[2]:
In [2]:
# read the entire level
@time imgdata = OpenSlide.read_slide(img);
In [3]:
arraysize(imgdata)
Out[3]:
In [13]:
using PyPlot
# Plot a sub-region
# We keep the figure small in order to reduce the size of the notebook, but larger figure size will work fine.
figure(figsize=[2,2])
imshow(imgdata[1200:1500,800:1100,:])
Out[13]:
In [6]:
# read a given extent and level (shown for example, but note that this image has only one level!)
@time imgdata2 = OpenSlide.read_slide(img; origin = [1200,800], extent = [300,300], level = 1);
In [12]:
figure(figsize=[2,2])
imshow(imgdata2)
Out[12]:
In [14]:
# get image properties
props = OpenSlide.properties(img)
props["tiff.ResolutionUnit"]
Out[14]:
get_property_names,
get_property_value,
can_open,
openslide_open,
get_level_count,
close_slide,
get_level0_dimensions,
get_level_dimensions,
get_level_downsample,
get_best_level_for_downsample,
read_region,
get_associated_image_names,
read_associated_image,
get_error,
openslide_version