diff --git a/ACTIVATION.md b/ACTIVATION.md new file mode 100644 index 00000000..c4da2887 --- /dev/null +++ b/ACTIVATION.md @@ -0,0 +1,52 @@ +# β‘ Filter Preview Activation Guide + +This document covers the **Filter Preview** featureβa major contribution designed to enhance real-time interactive segmentation by providing an instantaneous visual response when tuning filters. + +--- + +## π 1. What is Filter Preview? + +The **Filter Preview** allows users to visualize the effects of the **GAUSS** (Gaussian) filter directly on the image before final application. This enables real-time parameter tuning (e.g., scale and sigma) making the segmentation process both intuitive and computationally efficient. + +--- + +## βοΈ 2. How to Activate Preview + +To "activate" the preview mode within the Active Segmentation platform: + +1. **Launch the Plugin**: Go to `Plugins > Segmentation > Active Segmentation`. +2. **Initialize Project**: + - **Project Folder Selection**: Browse and select your working directory. + - **Project Image Selection**: Choose the image you wish to segment. + - **Click Finish**: This initializes the workspace. +3. **Navigate to Filters**: Click the **Select Filters** button on the main dashboard. +4. **Activate Preview**: + - Select the **GAUSS** filter tab. + - Click the **Preview** checkbox. +5. **Real-Time Tuning**: As you adjust parameters (like `initial scale`), the image display will update dynamically based on your contribution! + +--- + +## π 3. Technical Implementation + +The feature is built on a robust, non-destructive architecture located in `activeSegmentation.gui.PreviewManager`: + +### π‘ Snapshot/Restore Pattern +- When preview is activated, a **snapshot** (duplicate) of the original `ImageProcessor` is stored. +- Filter operations are applied to a *copy* of the snapshot, leaving the original data untouched. +- When deactivated, the original snapshot is restored to the `ImagePlus` display. + +### β‘ Performance Optimization +- **Asynchronous Execution**: Filter computations are handled on a background `SwingWorker` thread to keep the user interface responsive. +- **Debouncing**: A `200ms` debounce timer coalesces rapid parameter changes (e.g., while dragging a slider) into a single computation, preventing CPU thrashing. + + +## π Source Reference +- `PreviewManager.java`: Core logic for managing snapshots and background threads. +- `FilterPanel.java`: UI integration and checkbox event handling. + +--- + +> [!NOTE] +> **GSoC 2026 Milestone** +> The **Filter Preview** for the **GAUSS** filter was developed as a key project milestone for **Google Summer of Code 2026**, aimed at enhancing real-time interactivity within the Active Segmentation platform. diff --git a/ACTIVESEGMENTATION.jar b/ACTIVESEGMENTATION.jar new file mode 100644 index 00000000..60328c2d Binary files /dev/null and b/ACTIVESEGMENTATION.jar differ diff --git a/README.md b/README.md index 36bdea48..8d65d1a2 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Active Segmentation is an interactive image segmentation and classification plug ## π Table of Contents - [About](#about) - [Features](#features) +- [β‘ Activation Guide](#-activation-guide) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Usage](#usage) @@ -48,6 +49,18 @@ Originally developed at Zuse Institute Berlin (ZIB) and published in: --- +## β‘ Filter Preview Guide + +> [!IMPORTANT] +> To understand the **Filter Preview** contribution, please refer to our dedicated [Filter Preview Activation Guide](ACTIVATION.md). + +The Filter Preview Guide covers: +1. **Activation Workflow**: Step-by-step instructions to enable the real-time preview. +2. **Technical Architecture**: Details on the **Snapshot/Restore Pattern** and background threading. +3. **Performance**: How the **GAUSS** filter tuning is optimized using debouncing. + +--- + ## π Prerequisites Before setting up the project, make sure you have the following installed: diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 00000000..59686482 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,100 @@ +# Build script for ACTIVESEGMENTATION β excludes test files +$ErrorActionPreference = "Continue" + +$PROJECT_DIR = "$PSScriptRoot" +$FIJI_DIR = "$env:FIJI_DIR" # Set this environment variable or edit here +if (-not $FIJI_DIR) { + if (Test-Path "C:\Fiji.app") { $FIJI_DIR = "C:\Fiji.app" } + elseif (Test-Path "D:\Fiji.app") { $FIJI_DIR = "D:\Fiji.app" } + else { + Write-Host "[WARNING] FIJI_DIR not set. Using default but build may fail if not found." -ForegroundColor Yellow + $FIJI_DIR = "C:\Fiji.app" + } +} + +$JAVA_HOME = "$env:JAVA_HOME" # Use system JAVA_HOME if available +if (-not $JAVA_HOME) { $JAVA_HOME = "$FIJI_DIR\java\win64\jdk-latest" } + +$JAVAC = "javac.exe" # Assume in PATH or JAVA_HOME +if (Test-Path "$JAVA_HOME\bin\javac.exe") { $JAVAC = "$JAVA_HOME\bin\javac.exe" } + +$JAR_TOOL = "jar.exe" +if (Test-Path "$JAVA_HOME\bin\jar.exe") { $JAR_TOOL = "$JAVA_HOME\bin\jar.exe" } + +$SRC_DIR = "$PROJECT_DIR\src" +$RES_DIR = "$PROJECT_DIR\resources" +$JARS_DIR = "$PROJECT_DIR\jars" +$OUT_DIR = "$PROJECT_DIR\build_out" +$OUTPUT_JAR = "$PROJECT_DIR\ACTIVESEGMENTATION.jar" + +Write-Host "=== ACTIVESEGMENTATION Build Script ===" -ForegroundColor Cyan + +# Build classpath with forward slashes +$projectJars = Get-ChildItem "$JARS_DIR" -Filter "*.jar" -Recurse | ForEach-Object { $_.FullName.Replace('\','/') } +$ijJar = (Get-ChildItem "$FIJI_DIR\jars" -Filter "ij-*.jar" | Select-Object -First 1).FullName.Replace('\','/') +$fxJars = Get-ChildItem "$FIJI_DIR\jars" -Filter "javafx*.jar" -Recurse | ForEach-Object { $_.FullName.Replace('\','/') } +$allCpItems = $projectJars + @($ijJar) + $fxJars +$classpath = ($allCpItems -join ";").Replace('\','/') + +Write-Host "Classpath: $($allCpItems.Count) JARs" + +# Clean +if (Test-Path $OUT_DIR) { Remove-Item $OUT_DIR -Recurse -Force } +New-Item $OUT_DIR -ItemType Directory -Force | Out-Null + +# Find sources β EXCLUDE test directory +$javaFiles = Get-ChildItem "$SRC_DIR" -Filter "*.java" -Recurse | Where-Object { $_.FullName -notmatch "\\test\\" } | ForEach-Object { $_.FullName.Replace('\','/') } +Write-Host "Found $($javaFiles.Count) Java source files (excluding tests)" + +# Write argfile +$argFile = "$PROJECT_DIR\javac_args.txt" +$outFwd = $OUT_DIR.Replace('\','/') +$srcFwd = $SRC_DIR.Replace('\','/') + +$lines = @() +$lines += "-d" +$lines += """$outFwd""" +$lines += "-cp" +$lines += """$classpath""" +$lines += "-sourcepath" +$lines += """$srcFwd""" +$lines += "-Xlint:none" +$lines += "-encoding" +$lines += "UTF-8" +foreach ($f in $javaFiles) { + $lines += """$f""" +} +[System.IO.File]::WriteAllLines($argFile, $lines, [System.Text.Encoding]::ASCII) + +Write-Host "Argfile: $($lines.Count) lines" + +# Compile +Write-Host "`nCompiling..." -ForegroundColor Yellow +& $JAVAC "@$argFile" 2>&1 | ForEach-Object { Write-Host $_ } + +if ($LASTEXITCODE -eq 0) { + Write-Host "`n[OK] Compilation successful!" -ForegroundColor Green + + # Copy resources + if (Test-Path $RES_DIR) { + Copy-Item "$RES_DIR\*" $OUT_DIR -Recurse -Force -ErrorAction SilentlyContinue + } + Copy-Item "$PROJECT_DIR\plugins.config" $OUT_DIR -Force -ErrorAction SilentlyContinue + + # Create JAR + Write-Host "Creating JAR..." + & $JAR_TOOL cf $OUTPUT_JAR -C $OUT_DIR . + + $jarSize = [math]::Round((Get-Item $OUTPUT_JAR).Length / 1KB) + Write-Host "[OK] JAR: $OUTPUT_JAR ($jarSize KB)" -ForegroundColor Green + + # Install to Fiji + Copy-Item $OUTPUT_JAR "$FIJI_DIR\plugins\ACTIVESEGMENTATION.jar" -Force + Write-Host "[OK] Installed to Fiji plugins!" -ForegroundColor Green + + Write-Host "`n=== READY TO RUN ===" -ForegroundColor Cyan + Write-Host "Launch Fiji: $FIJI_DIR\ImageJ-win64.exe" + Write-Host "Then go to: Plugins > Segmentation > Active Segmentation" +} else { + Write-Host "`n[FAIL] Compilation failed." -ForegroundColor Red +} diff --git a/build_out/activeSegmentation/feature/download.png b/build_out/activeSegmentation/feature/download.png new file mode 100644 index 00000000..8dccb635 Binary files /dev/null and b/build_out/activeSegmentation/feature/download.png differ diff --git a/build_out/activeSegmentation/feature/upload.png b/build_out/activeSegmentation/feature/upload.png new file mode 100644 index 00000000..2c8adee5 Binary files /dev/null and b/build_out/activeSegmentation/feature/upload.png differ diff --git a/build_out/activeSegmentation/gui/addProject.png b/build_out/activeSegmentation/gui/addProject.png new file mode 100644 index 00000000..e563c603 Binary files /dev/null and b/build_out/activeSegmentation/gui/addProject.png differ diff --git a/build_out/activeSegmentation/gui/download.png b/build_out/activeSegmentation/gui/download.png new file mode 100644 index 00000000..8dccb635 Binary files /dev/null and b/build_out/activeSegmentation/gui/download.png differ diff --git a/build_out/activeSegmentation/gui/filters.png b/build_out/activeSegmentation/gui/filters.png new file mode 100644 index 00000000..618ea3f4 Binary files /dev/null and b/build_out/activeSegmentation/gui/filters.png differ diff --git a/build_out/activeSegmentation/gui/logo.png b/build_out/activeSegmentation/gui/logo.png new file mode 100644 index 00000000..6c0895e3 Binary files /dev/null and b/build_out/activeSegmentation/gui/logo.png differ diff --git a/build_out/activeSegmentation/gui/no-image.jpg b/build_out/activeSegmentation/gui/no-image.jpg new file mode 100644 index 00000000..7bde668f Binary files /dev/null and b/build_out/activeSegmentation/gui/no-image.jpg differ diff --git a/build_out/activeSegmentation/gui/openProject.png b/build_out/activeSegmentation/gui/openProject.png new file mode 100644 index 00000000..0829aebd Binary files /dev/null and b/build_out/activeSegmentation/gui/openProject.png differ diff --git a/build_out/activeSegmentation/gui/upload.png b/build_out/activeSegmentation/gui/upload.png new file mode 100644 index 00000000..2c8adee5 Binary files /dev/null and b/build_out/activeSegmentation/gui/upload.png differ diff --git a/build_out/actsegm.svg b/build_out/actsegm.svg new file mode 100644 index 00000000..7d913bdb --- /dev/null +++ b/build_out/actsegm.svg @@ -0,0 +1,197 @@ + + + + diff --git a/build_out/help.css b/build_out/help.css new file mode 100644 index 00000000..8f25124d --- /dev/null +++ b/build_out/help.css @@ -0,0 +1,74 @@ +/* ===== JavaFX-compatible CSS ===== */ + +img.math { -fx-translate-y: 0; } + +div.par-math-display, div.math-display { -fx-text-alignment: center; } + +li p:first-child { -fx-padding: 0 0 0 0; } +li p:last-child, li div:last-child { -fx-padding: 0 0 0.5em 0; } +li p~ul:last-child, li p~ol:last-child { -fx-padding: 0 0 0.5em 0; } + +div.newtheorem { -fx-padding: 2em 0 2em 0; } +div.newtheorem .head { -fx-font-weight: bold; } + +div.obeylines-v p { -fx-padding: 0 0 0 0; } + +.centerline { -fx-text-alignment: center; } +.rightline { -fx-text-alignment: right; } + +pre.verbatim { -fx-font-family: monospace; -fx-text-alignment: left; } + +.fbox { + -fx-padding: 3px 3px 3px 3px; + -fx-border-color: black; + -fx-border-width: 0.4pt; +} + +.underline { -fx-underline: true; } +.underline img { + -fx-border-color: transparent transparent black transparent; + -fx-border-width: 0 0 1 0; +} + +.framebox-c, .framebox-l, .framebox-r { + -fx-padding: 3px 3px 3px 3px; + -fx-border-color: black; + -fx-border-width: 0.4pt; +} +.framebox-c { -fx-text-alignment: center; } +.framebox-l { -fx-text-alignment: left; } +.framebox-r { -fx-text-alignment: right; } + +span.thank-mark { -fx-translate-y: -0.2em; } +span.footnote-mark { -fx-font-size: 80%; -fx-translate-y: -0.2em; } + +div.tabular { -fx-alignment: center; -fx-padding: 0.5em 0.5em 0.5em 0.5em; } +table.tabular { -fx-alignment: center; } + +td p:first-child { -fx-padding: 0 0 0 0; } +td p:last-child { -fx-padding: 0 0 0 0; } + +.hline { + -fx-border-color: black transparent transparent transparent; + -fx-border-width: 1 0 0 0; +} + +.tabbing-right { -fx-text-alignment: right; } + +div.float, div.figure { -fx-alignment: center; } +div.caption { -fx-padding: 0 1em 0 1em; -fx-text-alignment: left; } + +.qed { -fx-min-width: 2ex; -fx-alignment: center-right; } + +.sectionHead { -fx-text-alignment: center; } +h2.titleHead { -fx-text-alignment: center; } + +div.maketitle { -fx-padding: 0 0 2em 0; -fx-text-alignment: center; } + +div.submaketitle { + -fx-text-alignment: left; + -fx-border-color: black; + -fx-border-width: 1 0 1 0; + -fx-padding: 2em 5% 2em 5%; + -fx-font-size: 85%; +} diff --git a/build_out/help.html b/build_out/help.html new file mode 100644 index 00000000..626e2c77 --- /dev/null +++ b/build_out/help.html @@ -0,0 +1,620 @@ + + +
DIMITER PRODANOV1,2 +
1NERF, IMEC, Leuven, Belgium; 2PAML-LN, IICT, Bulgarian Academy of +Sciences, Sofia, Bulgaria +
Date: March 30, 2025.
Smoothing in the digital domain leads to loss of resolution and, therefore, of some +information. The axiomatic linear scale space theory was formulated in series of works by +Witkin and Koenderink [10, 4]. In its original version, the theory depends on several +properties of the Gaussian filters as solutions of the diffusion equation in the scale-space +generated by the image. That is, the generic smoothing kernel \(G\) is identified with a +radially-symmetric Gaussian kernel of scale \(s=\sigma ^2 \in \mathbb {R}\) \[ G (r)= \frac {e^{-r^2/2s}}{2 \pi s } = \frac {e^{-(x^2+y^2)/2s}}{2 \pi s } \] The Gaussian kernels provide several +advantages: (i) they are rotationally invariant (ii) they do not produce artificial extrema +in the resulting image (iii) successive convolutions with different kernels can be +combined. Mathematically, this imposes a very useful semi-group structure, equivalent +to the heat/diffusion equation. In this sense, the image structures diffuse or +”melt-down”, so that the rate of this diffusion indicates the ”robustness” of the +structure. + +
However, the information loss can be limited if one uses multiple smoothing scales +Pauwels et al. [6] and later Duits et al. [2] introduced the \(\alpha \)-scale spaces for image +processing. The basis of the approach is a generalization the heat equation. The +resulting convolution kernels can be described best by the tools of fractional +calculus. The kernel evolution is governed by two parameters – the scale s and the +order of differentiation \(\alpha \). The approach leads to the fractional heat problem: +\begin {flalign*} u\left (0, \mathbf {x} \right ) &= I\left ( \mathbf {x} \right ) \\ \partial _s u \left ( s, \mathbf {x} \right ) & = - (-\Delta )^{\alpha } u\left ( s, \mathbf {x} \right ) , \quad 0 \leq \alpha \leq 1 \end {flalign*} +
where the Riesz fractional Laplacian operator is defined in the Fourier domain by: \[ (-\Delta )^{\alpha } U ( \mathbf {k} ) := k^{2\alpha } U ( \mathbf {k} ), \quad k= |\mathbf {k}|, \] +where the \(k\) is the modulus of the wave vector \(\mathbf {k} \). Formally, the operator is extended by +continuity for \(\alpha =1\) as \( (-\Delta )^{1} = -\Delta \mapsto k^2 \), which corresponds to the usual Laplacian; and to identity for +\(\alpha =0\), corresponding to invariance in the spatial domain. The Green function of +the differential equation is the stretched exponential kernel \[ G (k, s) = e^{- k^{2\alpha } s} \] in the frequency +domain. +
Weak differentiation operations in distributional sense can be defined in terms of +convolution with the gradient of a smooth kernel function as: \[ \nabla _{G} F: = - F \star \nabla G \] where the symbol \(\nabla \) +represents the of the gradient operator for the Euclidean basis (\(e_1\), \(e_2\)) \[ \nabla = e_1 \frac {\partial }{\partial x} + e_2 \frac {\partial }{\partial y} \] Explicitly, using the +Gaussian kernel \(g = \frac {1}{2 \pi s} e^{-r^2/2s}\) \[ \nabla _{G}= - e_1 \frac {\partial }{\partial x} g - e_2 \frac {\partial }{\partial y} g \equiv - e_1 g_x - e_2 g_y \] +
There are several types of geometric features useful for image segmentation. Typical +interesting image features are blobs, filaments and corners. The normal Laplacian \(\Delta _{ \perp G}\) +presented below is sensitive to blobs, while its complement – the tangential Laplacian \(\Delta _{ || G}\) is +sensitive to filaments. +
Various geometric features computed by the AS/IJ platform are presented in Table 1. +The normal vector field of the image \(F(x,y)\) is defined as \[ \mathbf n : = \frac {\nabla _G F}{||\nabla _G F ||} \] Notable differential invariants are the +amplitude \(|\nabla _{G} F|= A\) and the orientation of the gradient, the Hessian determinant, the Hessian +eigenvalues, as well as the isophote \(\kappa \) and streamline curvatures \(\mu \) [3]. Up to a sign +convention we have \begin {flalign} \kappa & = \nabla _G \cdot \mathbf {n} \\ \mu & = \nabla _G \cdot \mathbf {t}, \quad \mathbf {t}= I_2 \cdot \mathbf {n} \end {flalign} +
where \(I_2\) is the pseudoscalar of the Euclidean image plane. From the perspective of scale +space theory the study of the differential invariants of the image reduce to the +study of the differential invariants of the radially symmetric (generalized) heat +kernel. + +
| Filter | Functionality | Feature order | +
| Gauss2D | Gaussian smoothing | 0 | +
| Gradient | Gradient amplitude and orientation | 1 | +
| Gaussian Structure | Structure tensor | 1 | +
| LoG | Laplacian of Gaussian (LoG) | 2 | +
| ALoG | Anisotropic decomposition of LoG | 2 | +
| Gradient amplitude and orientation | 1 | +|
| Hessian | Eigenvalues of the Hessian | 2 | +
| Determinant of the Hessian | 2 | +|
| Curvature 2D | Line curvatures + Hessian determinant | 2 | +
| Curvature 3D | Mean + Gauss curvature of surfaces | 2 | +
| BoG | Bi-Laplacian of Gaussian | 4 | +
| Gaussian Jet | Gaussian Jet of order n | n | +
| LoGN | n-th order PoL | 2n | +
| FFT Kernel LoG | Riesz Laplacian | \(\alpha \in \mathbb {R}\) | +
The simple representation of the gradient introduced above can be extended to a +coordinate free (!) operator using the tools of the Geometric Algebra and Calculus. +Readers are directed to [5] for an introductory material on the subject. The Laplace +operator can be decomposed in two orthogonal components– on in the direction of the +isophote and the other in the direction normal to the isophotes. The Laplacian of +scalar function F can be decomposed into a normal component and tangential +component, thus breaking the isotropy of the original operator [8]: \[ \nabla ^2 F = \left ( \mathbf {n} \cdot \nabla \right )^2 F + \left ( \mathbf {n} \cdot \nabla F\right ) \nabla \cdot \mathbf {n} = \Delta _{\perp }F + \Delta _{|| } F \] where \(\mathbf {n}\) is +the unit normal vector to the isophote curve \( F (x,y) =c\), and \( \mathbf {n} \cdot \nabla \) denotes the directional +derivative. Then also using the isophote curvature the components are given by +\begin {flalign} \Delta _{\perp } &= \left ( \mathbf {n} \cdot \nabla \right )^2 \\ \Delta _{|| } &= \left ( \nabla \cdot \mathbf {n}\right ) \left ( \mathbf {n} \cdot \nabla \right ) = \kappa \ \mathbf {n} \cdot \nabla \end {flalign} +
This is a coordinate-free definition of \(\Delta _{\perp }\) and \(\Delta _{|| }\), which can be specialized to any smooth +coordinate system. This comes in contrast to the approach of ”gauge coordinates” +employed in [3]. Furthermore, if we specialize to weak Gaussian derivatives +\[ \Delta _{|| G} F= \kappa | A|, \quad |A| =\sqrt {G_x^2+ G_y^2} \] +
6.1. Gauss2D – Gaussian smoothing. + The filter convolves an image with the Gaussian kernel in the spatial domain. +\[ G (x,y) \star F (x,y) \] +
6.2. FFT Gaussian smoothing. + The filter convolves an image with the Riesz/ Gaussian kernel in the Fourier domain. +\[ \mathcal {F}^{-1}\left [ e^{-k^{2 \alpha }} F(k)\right ] \] +
| Gradient amplitude | \( A= \sqrt {G_x^2+ G_y^2} \) | +
| Gradient orientation | \( \sin {\phi }= G_y / \sqrt {G_x^2+ G_y^2} \) | +
| \( \cos {\phi }= G_x / \sqrt {G_x^2+ G_y^2} \) | +|
7.1. Gradient . The filter computes the gradient amplitude and orientation (sine +and cosine). The full output also outputs the elements of the gradient \(G_x\) and +\(G_y\). +
7.2. Gaussian Structure – Structure tensor. + The structure tensor (ST) is an abstract extension of the gradient. The tensor encodes +the predominant directions of the gradient in a specified neighborhood of a point, and +the degree to which those directions are coherent as a function of scale. Suppose that we +have a scale-space representation of the gradient \(\nabla _G \). Then the structure tensor is the +smoothed tensor product of the smoothed gradient vector[1]: \[ S_r (F) := G_r \star \{ \nabla _G \cdot \nabla _G ^T \} \] From this expression it is +apparent that the operator introduces smoothing on two scales. However, because of its +quadratic characters the scales do not compose. \(S_r (I)\) can be represented by a 2x2 +matrix. + +
| Laplacian | \(\Delta _G= \mathrm {Tr} \, \mathbb {H} = G_{xx} + G_{yy}\) | +
| determinant of the Hessian | \( \mathrm {det} \, \mathbb {H}_G = G_{xx} G_{yy} - G_{xy}^2\) | +
8.1. LoG – Laplacian of Gaussian. + The Laplacian operator can be thought of as the square of the gradient \(\nabla \). The analogy +can be made precise using the tools of the Clifford algebra and Geometric Calculus: \( \Delta = \nabla ^2 \). In +Cartesian coordinates, the Laplacian has the representation \[ \Delta _G= G_{xx} + G_{yy} \] The filter convolves and +image with the Laplacian of Gaussian. +
8.2. ALoG – Anisotropic decomposition of LoG. + The theory of the anisotropic decomposition of LoG (ALoG) is given in Sec. 5. In +Cartesian coordinates, the LoG is represented by \begin {flalign} \left ( G_x^2+ G_y^2 \right ) \Delta _{ \perp G} & = \left ( G_x^2 \right ) G_{xx} + \left ( 2 G_x G_y \right ) G_{xy} + \left ( G_y ^2\right ) G_{yy} \label {ed:lapo} \\ \left ( G_x^2+ G_y^2 \right ) \Delta _{|| G} &= \left ( G_x^2\right ) G_{xx} - \left ( 2 G_x G_y \right ) G_{xy} + \left ( G_y ^2\right ) G_{yy} \label {ed:lapt} \end {flalign} +
The plugin computes the anisotropic decomposition. The full output option also +outputs the components of the gradient and the Hessian. +
8.3. Hessian. + The weak Hessian tensor with respect to the 2nd order derivative of the (Gaussian) +kernel G is defined as the tensor product \[ \mathbb {H}_G (F) := \nabla _G \otimes \nabla _G F \] For smooth signals, the Hessian is symmetric +and can be identified as a metric tensor. In Cartesian coordinates, the Hessian can be +specialized to the usual formula \[ \mathbb {H}_G (F)= \left ( \begin {array}{ll} G_{xx} & G_{xy} \\ G_{xy} & G_{yy} \end {array} \right ) \star F \] where subscripts denote differentiation by coordinate +variables. The Hessian generates several differential invariants. These are the trace, +determinant and the eigenvalues. From now on the notation is abbreviated as +\(\mathbb {H}_G (F)\equiv \mathbb {H} \). +
For the trace holds \[ \mathrm {Tr} \,\mathbb {H} = \nabla _G^2 F = \Delta _{G} F \] where \( \Delta _{G}\) denotes the weak Laplacian operator. +
The determinant is \[ \mathrm {det} \mathbb {H} = G_{xx} G_{yy}- G_{xy}^2 \] The eigenvalues \(\lambda _{1,2}\) can be determined locally from the equation \[ \mathrm {det} (\mathbb {H} - \lambda \mathbb {I} )= 0 \] +This gives the quadratic equation \[ \lambda ^2 - \mathrm {Tr} \,\mathbb {H} \lambda + \mathrm {det} \mathbb {H} = 0 \] In an explicit form the eigenvalues are \[ \lambda _{1,2}=\frac {1}{2} \left ( (G_{xx} + G_{yy}) \pm \sqrt {(G_{xx} + G_{yy})^2 - 4 \left ( G_{xx} G_{yy}- G_{xy}^2 \right ) } \right ) \] The plugin +computes the amplitude, sine and cosine of the gradient, the Hessian determinant and its +2 eigenvalues. The full output option also outputs the components of the gradient and +the Hessian. +
8.4. Curvature 2D. The planar image is represented as a set of isophote contours \[ F(x,y) = c \] The +gradient vector n is orthogonal to the isophote contour. + The plugin computes 2 invariants: +
Isophote curvature \[ \kappa = \frac { G_{xx} G_{y}^2 - 2 G_{x} G_{y} G_{xy} + G_{x}^2 G_{yy}} {\left ( G_{x}^2 +G_{y}^2\right )^{3/2}} \] +
Streamline curvature \[ \mu = \frac { G_x G_y \left ( G_{yy} - G_{xx} \right ) +G_{xy}\left ( G_x^2 - G_y^2\right ) } {\left ( G_{x}^2 +G_{y}^2\right )^{3/2}} \]
The full output option outputs the components of the gradient and the Hessian. + +
8.5. Gaussian curvature. There is a second plugin computing the extrinsic linear +curvature \[ \nu = \frac {G_{x} G_{yy}- G_{y} G_{xx}}{\left ( G_{x}^2 + G_{y}^2\right )^{3/2} } \] and the determinant of the Hessian. The full output option outputs the +components of the gradient and the Hessian. +
8.6. Curvature 3D. + The planar image is represented as a surface in the three-dimensional Euclidean space +\( \mathbb {E}^3\), where the elevation z represents the signal intensity. \[ z = F(x,y) \] The plugin computes +
Mean curvature \[ k_m = \frac {1 }{2}\frac {\left ( 1+G_{x}^2\right ) G_{yy} - 2 G_{x} G_{y} G_{xy} +\left (1 +G_{y}^2 \right ) G_{xx} } {\left ( 1 + G_{x}^2 +G_{y}^2\right )^{3/2}} \] +
Gaussian curvature \[ k_g= \frac {G_{xx} G_{yy} - G_{xy}^2} {\left ( 1 + G_{x}^2 +G_{y}^2\right )^2 } \]
Geometrically, the mean curvature is given by the divergence of the unit normal vector in +3D. The full output option outputs the components of the gradient and the +Hessian. +
8.7. Weingarten Map. The surface is represented locally at the point P (x,y) by +the Monge patch \[ \gamma = e_1 x +e_2 y + h (x,y) e_3 \] We define the non-orthogonal un-normalized basis vectors +\[ D_1:= g_x \star \gamma =e_1 + e_3 g_x \star h , \quad D_2:= g_y \star \gamma = e_2 + e_3 g_y \star h, \] + The unit normal to the surface is \[ n = -I_3 \cdot \frac {D_1 \wedge D_2} {||D_1 \wedge D_2 ||} = \frac { e_3 - h_x e_1 - h_y e_2 }{\sqrt { 1+ G_x^2+ G_y^2}} \] The first fundamental form is defined as \[ I = \begin {pmatrix} E & F \\ F & G \end {pmatrix} := \begin {pmatrix} 1+ G_x^2 & G_x G_y \\ G_x G_y & 1+ G_y^2 \end {pmatrix} \] or in +components \[ [I]_{ij} = D_i \cdot D_j \] The determinant is \[ \mathrm {det} I = 1 + G_x^2 + G_y^2 \] It is identified with the coefficients of the arc-length +differential on the surface patch in surface (u, v) coordinate \[ ds^2= [I]_{ij}dx_i dx_j= E du^2+ 2 F du dv + G dv^2 \] The first fundamental form +encodes the intrinsic geometry of a surface, which is the geometry that can be +measured by an inhabitant of the surface without reference to the ambient +space. It allows us to define geometric quantities such as length, angle, and +area on the surface using only intrinsic measurements. The inverse matrix is +\[ I^{-1} = \frac {1}{1 + G_x^2 + G_y^2} \begin {pmatrix} 1+ G_x^2 & -G_x G_y \\ -G_x G_y & 1+ G_y^2 \end {pmatrix} \] +
The second fundamental form is defined as \[ II = \begin {pmatrix} L & M \\ M & N \end {pmatrix} := \frac {1}{\sqrt {1 +G_x^2 + G_y^2}} \begin {pmatrix} G_{xx} & G_{xy} \\ G_{xy} & G_{yy} \end {pmatrix} \] The components are given by \[ [II]_{ij} = n \cdot \partial _{i} D_j = (n \wedge e_i) \cdot \nabla D_j \] The second +fundamental form describes the deviation of the surface from its tangent plane. The +second fundamental form measures the normal component of the directional derivative of +a tangent vector field along another tangent vector. It captures how the surface normal +changes as the base point is moved along the surface in different directions. +The distance from the surface at r+dr to the tangent plane at r is given by \[ 2 ds^2 = L du^2 + 2 M du dv + N dv^2 \] +The Weingarten map (shape operator) is defined as \[ W: = I^{-1} II = \frac {1}{\sqrt {\left ( 1 +h_x^2 + h_y^2 \right )^3 }} \begin {pmatrix} (1+ G_{y}^2) G_{xx} - G_{xy} G_x G_y & (1+ G_{y}^2) G_{xy} - G_{yy} G_x G_y \\ (1+ G_{x}^2) G_{xy} - G_{xx} G_x G_y & (1+ G_{x}^2) G_{yy} - G_{xy} G_x G_y \end {pmatrix} \] The eigenvalues \(\lambda _{1,2}\) can be +determined locally from the equation \[ \mathrm {det} (\mathbb {W} - \lambda \mathbb {I} )= 0 \] This gives the quadratic equation \[ \lambda ^2 - \mathrm {Tr} \,\mathbb {W} \lambda + \mathrm {det} \mathbb {W} = 0 \] The plugin +computes the eignevalues of the Weingarten maps. They are sensitive to ridge +structures. +
9.1. Gaussian Jet. In the spatial domain, the Gaussian derivatives for the one +dimensional case can be computed in closed form as \[ G_n \left (x \right ) = \frac {\partial ^n}{\partial x^n} G \left (x \right ) = \frac {(-1)^n} {\sqrt { 2 \pi s^{n+1}}} \,{He}_{n}\left ( {x}/{\sqrt {s}}\right ) \, e^{-\frac {x^2}{2s}} \] where \(He_n (x)\) is the statistician’s Hermite +polynomial of order n. The sequence of statistician’s Hermite polynomials satisfies the +recursion \[ He_{n+1} (x) =x He_{n} (x) - n He_{n-1} (x) \] starting from \(He_0 (x) = 1\) and \(He_1 (x) = x\). This allows for efficient simultaneous computation of all +derivatives up to an order n in order to populate the the n-jet space. The filter computes +all Gaussian derivatives up to order n. +
9.2. Bi-Laplacian of Gaussian (BoG). The Laplacian operator can be composed +multiple times to give rise to the Power-of-Laplacian (PoL) operator [7]: \( \Delta _G^n I \). The plugin +computes \(\Delta _G^2 I\). This operator enhances high-frequency features of an images given the +scale cut-off. This can be seen easily from the frequency response of the LoG +filter. +
+
+ [1] T. Brox, J. Weickert, B. Burgeth, and P. Mrazek. Nonlinear structure tensors. Technical + report, Universitat des Saarlandes, 2004. +
++ [2] R. Duits, M. Felsberg, L. Florack, and B. Platel. Alpha-scale spaces on a bounded + domain. scale space methods in computer vision. 494- 510. Springer, 2003. +
++ [3] L. M J Florack, B. M ter Haar Romeny, J. J Koenderink, and M. A Viergever. Scale + and the differential structure of images. Image and Vision Computing, 10:376–388, 1992. +
++ [4] J. J. Koenderink. The structure of images. Biological Cybernetics, 50(5):363–370, aug + 1984. +
++ [5] A. Macdonald. A survey of geometric algebra and geometric calculus. Advances in Applied + Clifford Algebras, pages 1–39, 2016. +
++ [6] E. J Pauwels, L. J. Van Gool, P. Fiddelaers, and T. Moons. An extended class of + scale-invariant and recursive scale space filters. Pattern Analysis and Machine Intelligence, + IEEE Transactions on, 17(7):691–701, 1995. +
++ [7] D. Prodanov, T. Konopczynski, and M. Trojnar. Selected applications of scale spaces in + microscopic image analysis. Cybernetics and Information Technologies, 15(7):5–12, dec 2015. +
++ [8] Dimiter Prodanov and Sumit Kumar Vohra. Active segmentation: Differential geometry + meets machine learning. In International Conference on Computer Systems and Technologies + 2022. ACM, jun 2022. +
+ ++ [9] S. K. Vohra and D. Prodanov. The active segmentation platform for microscopic image + classification and segmentation. Brain Sciences, 11(12):1645, dec 2021. +
++[10] A.P. Witkin. Scale-space fltering. In Proc. 8th Int. Joint Conf. Artificial Intelligence + (IJCAI 83), volume 2, 1019-1022, 1983. +
+DIMITER PRODANOV1,2 +
1NERF, IMEC, Kapeldreef 75, 3001 Leuven, Belgium; 2PAML-LN, IICT, +Bulgarian Academy of Sciences, Sofia, Bulgaria +
Date: March 30, 2025.
Spatial and central moments are important statistical properties of an image. +Mathematically, the image moment is generally defined as the inner product of the image +intensity function f(x,y) and a certain basis function \( P_{m,n}\). In the continuous approximation, +the moments of a function are computed by the integral \[ M_{m,n} = \iint \limits _{I} P_{m,n}(x,y) f(x,y) dx dy \] where \( P_{m,n}(x,y)\) is polynomial, +parameterized by the integers m and n. depending on whether the basis functions satisfy +orthogonality, the image moments can be classified into orthogonal moments and +non-orthogonal moments. +
For example, the raw image moments are given by the homogeneous form \(P_{m,n}(x,y)= x^m y^n\). The +moments, can be referred to the center of the image frame or to the center of mass of the +image \((x_c, y_c)\), in which case, \(P_{m,n}(x,y) = (x-x_c)^m (y-y_c)^n\). The two main problems with such a choice is that the moments +contain redundant information because the homogeneous polynomials are not +orthogonal; also the computation loses numerical precision due to cancellation of large +terms. Mathematically, a better choice of polynomials is a polynomial from +an orthogonal family. Such polynomials enjoy an expansion property, that is +\[ f(x,y) = \sum _{m=0}^{\infty } \sum _{n=0}^{\infty } M_{m,n} P_{m,n}(x,y) \] Useful examples of such orthogonal families are the Legendre and Zernike +polynomials. + +
The Legendre polynomials form an orthogonal set on the interval \([-1, 1]\) The Legendre +polynomials enjoy a two term recurrence relation \begin {equation} (n+1)L_{n+1} (x)= (2 n + 1) x L_{n} (x) - n L_{n-1}(x) , \quad L_0(x)=1, \quad L_1(x)= x \end {equation} that was used for their computation in +the present paper. The advantage of the recursion relation is that all Legendre moments +up to a user-defined order can be computed simultaneously. +
The Zernike polynomials are normalized on the unit disk in the complex plane. The +radial Zernike polynomials can be defined for \(n-m\) even as: \begin {equation} R_{n}^{m} (r) = \sum _{l=0}^{ (n-m)/2 } \frac {(-)^l (n-l)! }{l! ( (n+m)/2 -l )! ( (n-m)/2 -l)! } r^{n - 2 l} \end {equation} and 0 otherwise. The present +paper implemented a recursive computation method given by the formula [2] \begin {equation} R^m_n(r)=r \left ( R^{|m-1|}_{n-1} (r) + R^{m+1}_{n-1} (r) \right ) - R^{m}_{n-2} (r), \quad R^0_0=1 \end {equation} The +orthogonal Zernike polynomials then are \begin {equation} V_{mn}(r, \theta ):= R_{n}^{m} (r) e^{-i m \theta } \end {equation} The normalization of the polynomials for +grayscale images is not an issue because they have a fixed dynamic range, so an +image can be always normalized to unit range prior to computation of an image +moment. +
Haralick features [1] are coded as following 0 – Angular 2nd Moment; 1 – Contrast; 2 – +Correlation; 3 – Dissimilarity; 4 – Energy; 5 – Entropy; 6 – Homogeneity. +
The following ImageJ statistics are computed: Area, mean, stdev, min, max, centroid, +center of mass, perimeter, ellipse, shape descriptors, Ferret’s diameter, integrated density, +median, skewness, kurtosis, area fraction. +
+
+[1] R. M. Haralick, K. Shanmugam, and I. Dinstein. Textural features for image + classification. IEEE Transactions on Systems, Man, and Cybernetics, SMC-3(6):610–621, nov + 1973. +
++[2] Barmak Honarvar Shakibaei and Raveendran Paramesran. Recursive formula to compute + zernike radial polynomials. Optics Letters, 38(14):2487, jul 2013. +
+MathJax is a JavaScript library that allows page"," authors to include mathematics within their web pages."," As a reader, you don't need to do anything to make that happen.
","Browsers: MathJax works with all modern browsers including"," Edge, Firefox, Chrome, Safari, Opera, and most mobile browsers.
","Math Menu: MathJax adds a contextual menu to equations."," Right-click or CTRL-click on any mathematics to access the menu.
",'Show Math As: These options allow you to view the formula's"," source markup (as MathML or in its original format).
","Copy to Clipboard: These options copy the formula's source markup,"," as MathML or in its original format, to the clipboard"," (in browsers that support that).
","Math Settings: These give you control over features of MathJax,"," such the size of the mathematics, and the mechanism used"," to display equations.
","Accessibility: MathJax can work with screen"," readers to make mathematics accessible to the visually impaired."," Turn on the explorer to enable generation of speech strings"," and the ability to investigate expressions interactively.
","Language: This menu lets you select the language used by MathJax"," for its menus and warning messages. (Not yet implemented in version 3.)
","Math Zoom: If you are having difficulty reading an"," equation, MathJax can enlarge it to help you see it better, or"," you can scall all the math on the page to make it larger."," Turn these features on in the Math Settings menu.
","Preferences: MathJax uses your browser's localStorage database"," to save the preferences set via this menu locally in your browser. These"," are not used to track you, and are not transferred or used remotely by"," MathJax in any way.
"].join("\n")}),'www.mathjax.org'),this.mathmlCode=new h.SelectableInfo("MathJax MathML Expression",(function(){if(!r.menu.mathItem)return"";var t=r.toMML(r.menu.mathItem);return""+r.formatSource(t)+""}),""),this.originalText=new h.SelectableInfo("MathJax Original Source",(function(){if(!r.menu.mathItem)return"";var t=r.menu.mathItem.math;return'
'+r.formatSource(t)+""}),""),this.annotationText=new h.SelectableInfo("MathJax Annotation Text",(function(){if(!r.menu.mathItem)return"";var t=r.menu.annotation;return'
'+r.formatSource(t)+""}),""),this.zoomBox=new d.Info("MathJax Zoomed Expression",(function(){if(!r.menu.mathItem)return"";var t=r.menu.mathItem.typesetRoot.cloneNode(!0);return t.style.margin="0",'
Uses the snapshot/restore pattern for non-destructive preview: + * the original image data is preserved and restored when preview + * mode is deactivated.
+ * + *Thread-safety: All ImagePlus updates are dispatched to the EDT + * via SwingUtilities.invokeLater. A debounce timer coalesces rapid + * parameter changes (e.g., slider drags) into a single computation.
+ * + * @author [YOUR NAME] + * @see IFilter + * @see FilterPanel + */ +public class PreviewManager { + + /** The image being previewed */ + private final ImagePlus targetImage; + + /** Snapshot of the original image before preview started */ + private ImageProcessor originalSnapshot; + + /** The filter currently being previewed */ + private IFilter activeFilter; + + /** Current settings to apply during preview */ + private Map