{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ImageJ Ops\n", "\n", "[ImageJ Ops](https://imagej.net/ImageJ_Ops) is a library for N-dimensional image processing. The primary design goals of Ops are:\n", "\n", "1. __Ease of use.__ Ops provides a wealth of easy-to-use image processing operations (\"ops\").\n", "2. __Reusability.__ Ops extends Java's mantra of \"[write once, run anywhere](https://en.wikipedia.org/wiki/Write_once,_run_anywhere)\" to image processing algorithms. Algorithms written in the Ops framework are usable as-is from any [SciJava](https://imagej.net/SciJava)-compatible software project, such as [ImageJ](https://imagej.net/ImageJ), [CellProfiler](https://imagej.net/CellProfiler), [KNIME](https://imagej.net/KNIME), [OMERO](https://imagej.net/OMERO) and [Alida](https://imagej.net/Alida).\n", "3. __Reproducibility.__ Ops are deterministic: calling the same op twice with the same arguments yields the same result, always. And all ops are versioned.\n", "4. __Power.__ An op may consist of any number of typed input and output parameters. Ops may operate on arbitrary data structures, including images of N dimensions stored in a myriad of different ways: as files on disk, programmatically generated in memory, or in remote databases.\n", "5. __Extensibility.__ Ops provides a robust framework for writing new ops, and for extending existing ops in new directions. See the \"Extending ImageJ - Ops\" tutorial notebook for details.\n", "6. __Speed.__ The Ops framework provides a means to override any general-but-slow op with a faster-but-more-specific alternative, fully transparently to the user." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quick Start Guide" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Getting started" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Added new repo: imagej.public\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "method": "display_data" }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "29b9b0dd-d6c0-4f63-9627-988362f2c53d", "version_major": 2, "version_minor": 0 }, "method": "display_data" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "ImageJ 2.0.0-rc-71 is ready to go." ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%classpath config resolver imagej.public https://maven.imagej.net/content/groups/public\n", "%classpath add mvn net.imagej imagej 2.0.0-rc-71\n", "ij = new net.imagej.ImageJ()\n", "\"ImageJ ${ij.getVersion()} is ready to go.\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's open up the friendly Clown image to use for our experiments. (For the [coulrophobic](https://en.wikipedia.org/wiki/Coulrophobia), feel free to use the [Fluorescent Cells](https://imagej.net/images/FluorescentCells.jpg) instead.)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "clown = ij.io().open(\"https://imagej.net/images/clown.png\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It's a bit large, so let's scale it down. We'll use the `transform.scaleView` op. For succinctness, we'll write only `scaleView` rather than the fully qualified op name `transform.scaleView`. We'll use N-linear interpolation, since it tends to look pretty nice." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory\n", "scaleFactors = [0.5, 0.5, 1] // Reduce X and Y to 50%; leave C dimension alone.\n", "interpolationStrategy = new NLinearInterpolatorFactory()\n", "image = ij.op().run(\"scaleView\", clown, scaleFactors, interpolationStrategy)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's also make a single-channel 32-bit floating point version:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import net.imglib2.FinalInterval\n", "w = image.dimension(0); h = image.dimension(1)\n", "slice = FinalInterval.createMinSize(0, 0, 0, w, h, 1)\n", "grayImage = ij.op().run(\"crop\", image, slice, true)\n", "image32 = ij.op().convert().float32(grayImage)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, let's define a function for showing multiple uniformly scaled images:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "script1547140967863$_run_closure1@24f40593" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import net.imglib2.RandomAccessibleInterval\n", "tile = { images ->\n", " int[] gridLayout = images[0] in List ?\n", " [images[0].size, images.size] : // 2D images list\n", " [images.size] // 1D images list\n", " RandomAccessibleInterval[] rais = images.flatten()\n", " ij.notebook().mosaic(gridLayout, rais)\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Learning about available ops" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can get a complete list of available ops using the `ops()` method. But it is a bit overwhelming, so here is a structured version organized by namespace:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
coloc | icq, kendallTau, maxTKendallTau, pValue, pearsons |
convert | bit, cfloat32, cfloat64, clip, copy, float32, float64, imageType, int16, int32, int64, int8, normalizeScale, scale, uint12, uint128, uint16, uint2, uint32, uint4, uint64, uint8 |
copy | img, imgLabeling, iterableInterval, labelingMapping, rai, type |
create | img, imgFactory, imgLabeling, imgPlus, integerType, kernel, kernel2ndDerivBiGauss, kernelBiGauss, kernelDiffraction, kernelGabor, kernelGaborComplexDouble, kernelGaborDouble, kernelGauss, kernelLog, kernelSobel, labelingMapping, nativeType, object |
deconvolve | accelerate, firstGuess, normalizationFactor, richardsonLucy, richardsonLucyCorrection, richardsonLucyTV, richardsonLucyUpdate |
filter | addNoise, addPoissonNoise, allPartialDerivatives, bilateral, convolve, correlate, createFFTOutput, derivativeGauss, dog, fft, fftSize, frangiVesselness, gauss, hessian, ifft, linearFilter, max, mean, median, min, padFFTInput, padInput, padShiftFFTKernel, paddingIntervalCentered, paddingIntervalOrigin, partialDerivative, sigma, sobel, tubeness, variance |
geom | boundarySize, boundarySizeConvexHull, boundingBox, boxivity, centerOfGravity, centroid, circularity, compactness, contour, convexHull, convexity, eccentricity, feretsAngle, feretsDiameter, mainElongation, majorAxis, marchingCubes, maximumFeret, maximumFeretsAngle, maximumFeretsDiameter, medianElongation, minimumFeret, minimumFeretsAngle, minimumFeretsDiameter, minorAxis, roundness, secondMoment, size, sizeConvexHull, smallestEnclosingBoundingBox, solidity, spareness, sphericity, vertexInterpolator, verticesCount, verticesCountConvexHull, voxelization |
haralick | asm, clusterPromenence, clusterShade, contrast, correlation, differenceEntropy, differenceVariance, entropy, icm1, icm2, ifdm, maxProbability, sumAverage, sumEntropy, sumVariance, textureHomogeneity, variance |
hog | hog |
image | ascii, cooccurrenceMatrix, distancetransform, equation, fill, histogram, integral, invert, normalize, squareIntegral, watershed |
imagemoments | centralMoment00, centralMoment01, centralMoment02, centralMoment03, centralMoment10, centralMoment11, centralMoment12, centralMoment20, centralMoment21, centralMoment30, huMoment1, huMoment2, huMoment3, huMoment4, huMoment5, huMoment6, huMoment7, moment00, moment01, moment10, moment11, normalizedCentralMoment02, normalizedCentralMoment03, normalizedCentralMoment11, normalizedCentralMoment12, normalizedCentralMoment20, normalizedCentralMoment21, normalizedCentralMoment30 |
labeling | cca, merge |
lbp | lbp2D |
linalg | rotate |
logic | and, conditional, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, not, notEqual, or, xor |
math | abs, add, and, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, assign, ceil, complement, complexConjugateMultiply, cos, cosh, cot, coth, csc, csch, cubeRoot, divide, exp, expMinusOne, floor, gamma, invert, leftShift, log, log10, log2, logOnePlusX, max, min, multiply, nearestInt, negate, or, power, randomGaussian, randomUniform, reciprocal, remainder, rightShift, round, sec, sech, signum, sin, sinc, sincPi, sinh, sqr, sqrt, step, subtract, tan, tanh, ulp, unsignedRightShift, xor, zero |
morphology | blackTopHat, close, dilate, erode, extractHoles, fillHoles, floodFill, open, outline, thinGuoHall, thinHilditch, thinMorphological, thinZhangSuen, topHat |
segment | detectJunctions, detectRidges |
stats | geometricMean, harmonicMean, integralMean, integralSum, integralVariance, kurtosis, leastSquares, max, mean, median, min, minMax, moment1AboutMean, moment2AboutMean, moment3AboutMean, moment4AboutMean, percentile, quantile, size, skewness, stdDev, sum, sumOfInverses, sumOfLogs, sumOfSquares, variance |
tamura | coarseness, contrast, directionality |
thread | chunker |
threshold | apply, huang, ij1, intermodes, isoData, li, localBernsenThreshold, localContrastThreshold, localMeanThreshold, localMedianThreshold, localMidGreyThreshold, localNiblackThreshold, localPhansalkarThreshold, localSauvolaThreshold, maxEntropy, maxLikelihood, mean, minError, minimum, moments, otsu, percentile, renyiEntropy, rosin, shanbhag, triangle, yen |
topology | boxCount, eulerCharacteristic26N, eulerCharacteristic26NFloating, eulerCorrection |
transform | addDimensionView, collapseNumericView, collapseRealView, collapseView, concatenateView, crop, dropSingletonDimensionsView, extendBorderView, extendMirrorDoubleView, extendMirrorSingleView, extendPeriodicView, extendRandomView, extendValueView, extendView, extendZeroView, flatIterableView, hyperSliceView, interpolateView, intervalView, invertAxisView, offsetView, permuteCoordinatesInverseView, permuteCoordinatesView, permuteView, project, rasterView, rotateView, scaleView, shearView, stackView, subsampleView, translateView, unshearView, zeroMinView |
zernike | magnitude, phase |
<global> | eval, help, identity, join, loop, map, op, run, slice |
image | horizontal blur | vertical blur | channel blur |
---|---|---|---|
geometricMean | 106.86402515788897 |
harmonicMean | 60.81451530914875 |
kurtosis | 2.250389182944452 |
max | 252.9996057999923 |
mean | 130.35596075261444 |
median | 129.34019425677636 |
min | 1.293813403205192 |
moment1AboutMean | -2.877214910768089E-13 |
moment2AboutMean | 3982.1563522625042 |
moment3AboutMean | -10221.960619118927 |
moment4AboutMean | 3.569046079615442E7 |
size | 15000.0 |
skewness | -0.04067366532821499 |
stdDev | 63.106432691542885 |
sum | 1955339.4112892165 |
sumOfInverses | 246.65164103911627 |
sumOfLogs | 70073.35850104403 |
sumOfSquares | 3.146224928399938E8 |
variance | 3982.4218470523483 |
image1 | image2 |
---|---|
Operator | Op name |
---|---|
|| | logic.or |
>>> | math.unsignedRightShift |
+ | math.add |
== | logic.equal |
&& | logic.and |
> | logic.greaterThan |
>= | logic.greaterThanOrEqual |
<< | math.leftShift |
!= | logic.notEqual |
- | math.negate |
+ | identity |
% | math.remainder |
/ | math.divide |
& | math.and |
| | math.or |
- | math.subtract |
>> | math.rightShift |
^ | math.power |
* | math.multiply |
< | logic.lessThan |
<= | logic.lessThanOrEqual |
dogWrong | dogConverted |
---|---|
image | poissonNoise | gauss | Sobel |
---|---|---|---|
median | min | max |
---|---|---|
dog | evalDoG |
---|---|
Scale 2 | Scale 5 | Scale 8 | Scale 13 | Scale 21 |
---|---|---|---|---|
base | small kernel | big kernel | small convolved | big convolved |
---|---|---|---|---|
small kernel | big kernel |
---|---|
real | imaginary |
---|---|
eye | view |
---|---|
nearest neighbor | N-linear | Lanczos |
---|---|---|
border | mirror double | mirror single | periodic | random | value | zero |
---|---|---|---|---|---|---|
Derivative #0 | Derivative #1 | Derivative #2 | Derivative #3 |
---|---|---|---|
huang | ij1 | intermodes | isodata | li | max entropy |
---|---|---|---|---|---|
max likelihood | mean | min error | minimum | moments | otsu |
---|---|---|---|---|---|
percentile | renyi entropy | rosin | shanbhag | triangle | yen |
---|---|---|---|---|---|
radius 1 | radius 3 | radius 5 | radius 8 | radius 12 | radius 15 |
---|---|---|---|---|---|
gray | binary |
---|---|
erode | dilate | open | close | manual open | manual close |
---|---|---|---|---|---|
erode | dilate | open | close | black top-hat | white top-hat |
---|---|---|---|---|---|
GuoHall | Hilditch | Morphological | zhangSuen |
---|---|---|---|
|
|
|
|
|
\"\n",
" for (ns in col) {\n",
" // Nested tables! Great plan? Or the greatest plan?\n",
" s += \"
\"\n", " }\n", " s += \" | \"\n",
"}\n",
"s += \"