CLATLAB

Logo

GPU-accelerated image processing in Matlab using CLIJ

View the Project on GitHub clij/clatlab

clatlab

clatlab is a bridge between Matlab and clij.

Image

Right now, this is very preliminary.

Installation

Download the following files, removed the numbers from their file endings and put them all in a folder:

In your matlab script, specify every individual jar file in this folder using `javaaddpath(‘folder/jarfile.jar’). It is recommended to do this in a utility function as demonstrated here.

Example code

Examples are available in the matlab folder.

Clatlab provides two entry points for processing:

clatlab.op.blur(imageIn, imageOut, Float(5), Float(5));
% matlab code:
a = ones(10, 1) * 6 + 8;
b = ones(10, 1) * 67 + 6;
c = a + b

% mocl alternative:
A = mocl.ones(10, 1) * 6 + 8;
B = mocl.ones(10, 1) * 67 + 6;
C = A + B;
c = mocl.pull(C);

MOCL Commands

Following MOCL commands are implemented. Some are not fully tested yet. Work in progress.

Command Matlab expresson mocl expression clij/clatlab counter part
push(a)   c = mocl.push(a) c = clij.push(a);
pull(a)   c = mocl.pull(a) c = clij.pull(a);
plus(a,b) c = a + b c = a + b clij.op().addImages(a, b, c);
minus(a,b) c = a - b c = a - b clij.op().subtractImages(a, b, c);
uminus(a) c = -a c = -a clij.op().invert(a, c);
transpose(a) c = a.’ c = a.’ clij2.op.transposeXY(a, c);
times(a,b) c = a .* b c = a .* b clij.op().multiplyImages(a, b, c);
mtimes(a,b) c = a * b c = a * b clij2.op.multiplyMatrix(a, b, c);
rdivide(a,b) c = a ./ b c = a ./ b clij.op().divideImages(a, b, c);
ldivide(a,b) c = b ./ b c = b ./ b clij.op().divideImages(b, a, c);
power(a,b) c = a .^ b c = a .^ b clij2.op.powerImages(a, b, c);
lt(a,b) c = a < b c = a < b clij2.op.smaller(a, b, c);
gt(a,b) c = a > b c = a > b clij2.op.greater(a, b, c);
le(a,b) c = a <= b c = a <= b clij2.op.smallerOrEqual(a, b, c);
ge(a,b) c = a >= b c = a >= b clij2.op.greaterOrEqual(a, b, c);
ne(a,b) c = a ~= b c = a ~= b clij2.op.notEqual(a, b, c);
eq(a,b) c = a == b c = a == b clij2.op.equal(a, b, c);
and(a,b) c = a & b c = a & b clij.op().binaryAnd(a, b, c);
or(a,b) c = a I b c = a I b clij.op().binaryOr(a, b, c);
not(a) c = ~b c = ~b clij.op().binaryNot(a, c);
imhist(a) [c,x] = imhist(a) c = mocl.imhist(a) clij.op().fillHistogram(a, c);
fliplr(a) c = fliplr(a) c = mocl.fliplr(a) clij.op().flip(a, c, true, false, false);
imRead(a) c = imread(a) c = imread(a)  
min(a) c = min(a) c = mocl.min(a) c = clij.op().minimumOfAllPixels(a);
max(a) c = max(a) c = mocl.max(a) c = clij.op().maximumOfAllPixels(a);
mean(a) c = mean(a) c = mocl.mean(a) c = clij.op().meanOfAllPixels(a);
ones(a) c = ones(a) c = mocl.ones(a)  
zeros(a) c = zeros(a) c = mocl.zeros(a)  
size(a) c = size(a) c = mocl.size(a)  
colon(a,b) c = [a:b] c = mocl.colon(a,b)  

How to develop clatlab

Clone this repository and build it using maven. Afterwards, you find the clatlab.jar in the target directory. Copy it to your clatlab/matlab java classpath.

git clone https://github.com/clij/clatlab
cd clatlab
mvn package
cp target/clatlab*.jar classpath/

Please note

It is recommended to use clij from Fiji. Matlab support is under development.

Back to CLIJ documentation