A Python module providing Deconvolution class that implements and generalises Ruifrok-Johnston color deconvolution algorithm [RJ], [IJ]. It allows one to split an image into distinct color layers in just a few lines of code:
from deconvolution import Deconvolution
from PIL import Image
img = Image.open("image.jpg")
# Declare an instance of Deconvolution, with image loaded and with color basis defining what layers are interesting
decimg = Deconvolution(image=img, basis=[[1, 0.1, 0.2], [0, 0.1, 0.8]])
# Constructs new PIL Images, with different color layers
layer1, layer2 = decimg.out_images(mode=[1, 2])
You can install the package using pip:
pip install deconvolution
Alternatively, you can clone the repository and run:
make install
Since then you can import use the module in your scripts:
from deconvolution import Deconvolution
d = Deconvolution()
# For Python 3 users
make test
# For Python 2 users
make comp
# Check the code coverage
make coverage
# Check the coverage interactively, using a web browser
make html
For better usage experience we created a script allowing one to deconvolve images from the shell. Copy deconvolve.py file into /usr/local/bin or, if you want to use it locally:
mkdir ~/bin
cp deconvolve.py ~/bin
export PATH=~/bin:$PATH
Since then you can deconvolve images using:
deconvolve.py image1.png image2.png ...
# For help
deconvolve.py -h
Check out our documentation at Read The Docs.
Method developed by Frederic Grabowski generalising Ruifrok-Johnston algorithm [RJ]. and implemented by Frederic Grabowski [FG] and Paweł Czyż [PC]. We are very grateful to prof. Daniel Wójcik and dr Piotr Majka [N1], [N2] who supervised the project. We also would like to thank prof. Gabriel Landini [GL], who implemented the colour deconvolution in ImageJ [IJ] and allowed us to test the algorithm on his data.
[RJ] | (1, 2) Research paper by Ruifrok and Johnston |
[IJ] | (1, 2) ImageJ webpage |
[N1] | Laboratory of Neuroinformatics webpage |
[GL] | Prof. Gabriel Landini's webpage |
[N2] | https://github.com/Neuroinflab/ |
[FG] | https://github.com/grfrederic |
[PC] | https://github.com/pawel-czyz |