PatternToolkit

PatternToolkit

This is an image processing application, load images and then process them. Use File > Open image directory to browse a local folder as cached thumbnails, or File > Open for individual files. To save any processed images right click on them and choose the save option. Select multiple images with Ctrl/Cmd-click or long-press; a blue border and number show gallery multi-selection order. Use Select > Select Region for a rectangular image selection. The optional green current-image outline is in Settings > Global. Use Image > Measurements for the grid, line measurement and object measurements. GIF export still uses gallery order.

PatternToolkit help

PatternToolkit is a free browser-based image processing and pattern-making application. It combines ordinary raster editing with thresholding, morphology, segmentation, spectral transforms, shape drawing and data-reduction tools. Images are read and processed locally in your browser; they are not uploaded for analysis.

App overview

The application has five main areas: the menu bar and toolbar at the top, the image workspace, the gallery strip, the settings panel on the right, and this help section. Menu commands that have options open their controls in the settings panel rather than in a pop-up dialog.

Quick start

  1. Choose File → Open, or drag an image file onto the workspace.
  2. Click a gallery tile to make that image current.
  3. Choose a tool from the menu. If a settings panel opens, adjust it and use its action button (Apply, Run PCA, Compute FFT and so on).
  4. Use Edit → Undo if a result is not what you wanted.
  5. Right-click the processed gallery image and choose Save Image As.

How the workspace behaves

  • Current image – the image shown on the main canvas. Most menu commands act on it.
  • Gallery selection – Ctrl/Cmd-click tiles, or long-press on touch, to select several images. A blue border and number show the selection order.
  • Settings panel – shows the options for the last tool chosen. Most tool panels have a Settings tab for values and a Help tab for the relevant section of this page. The Tile editor is a special panel without these tabs.
  • About tool – a collapsed explanation at the top of most tool settings panels. Open it for a short reminder of what the tool does. The Tile editor does not provide this block.
  • Messages – status and error messages appear below the workspace. If a command does nothing, check there first.

Undo, multiple images and saving

Image edits are stored in the gallery with undo and redo states. Copy, cut, paste and delete can act on gallery images or on selected objects, depending on what is selected. The gallery keeps the working images; use the right-click Save Image As command to download the current image source. GIF export uses gallery tile order, not selection-click order.

What stays in your browser

Loaded files, working pixels, macro definitions and settings stay in the browser session. The application may download model weights for the DINO and SAM tools the first time they are used, but the image data itself remains local. Very large images, clustering runs and model-based segmentation can take time and memory.

Menu tooltips

Menu tooltips

Every executable menu item and toolbar button has a short tooltip for new users. Hover over an item for one second to see it. Submenu headings do not show tooltips, so hovering them does not interfere with opening the submenu. The wording of every menu tooltip is listed below, and the individual tool help gives more detail.

Menu and toolbar tooltips
  • File → Open – Opens image files from your computer.
  • File → Open image directory – Shows images from a folder on your computer in the gallery.
  • File → New Image – Creates a blank image or canvas.
  • File → Save – Saves the current image to your computer.
  • File → Save images as GIF animation – Creates an animated GIF from the selected images.
  • File → Webcam → Capture Image – Takes a still picture from the webcam.
  • File → Webcam → Capture Video – Records video from the webcam.
  • File → Record Macro → Record – Starts recording menu commands as a macro.
  • File → Record Macro → Play – Repeats the recorded macro.
  • File → Record Macro → Edit Macros – Reviews, edits or deletes saved macros.
  • Edit → Undo – Goes back one editing step.
  • Edit → Redo – Repeats the last undone step.
  • Edit → Cut – Removes the selection and puts it on the clipboard.
  • Edit → Copy – Copies the selection to the clipboard.
  • Edit → Paste – Pastes the clipboard into a new transparent gallery image.
  • Edit → Delete – Deletes the selected image or object.
  • Edit → Close All – Closes all images in the gallery.
  • Edit → Replace Image – When checked, results replace the current image instead of adding a new one.
  • Image → Scale Image – Changes the image size.
  • Image → Canvas Size – Changes the canvas around the image.
  • Image → Size image to canvas – Stretches the image to fill the canvas.
  • Image → Flatten image – Combines all layers into one image.
  • Image → To Greyscale – Converts the image to greyscale using a standard luminance or channel mapping.
  • Image → Transparent background – Makes the image background transparent.
  • Image → Crop to Selection – Crops the image to the selected area.
  • Image → Transform – Resizes, rotates or flips the selection.
  • Image → Measurements → Show Grid – Shows a grid over the image.
  • Image → Measurements → Measure Line – Turns on the measuring line.
  • Image → Measurements → Measure Settings – Changes how the measuring line works.
  • Select → Select Region – Drag to select part of the image.
  • Select → Select by Colour – Selects pixels by hue, saturation and value tolerance and flashes them for copying.
  • Select → Select All – Selects the whole image.
  • Select → Deselect All – Clears the current selection.
  • Tools → Intensity segmentation → Threshold – Turns an image into black and white using brightness limits.
  • Tools → Intensity segmentation → Threshold from Background – Finds objects by comparing them with a background sample.
  • Binary → Binary Regions → Connected Components – Finds and labels separate objects in a binary image.
  • Binary → Binary Regions → Distance Transform – Shows how far each object pixel is from the background.
  • Binary → Binary Regions → Separate Components – Splits touching objects into separate regions.
  • Binary → Binary Regions → Get Objects – Turns labelled regions into selectable image objects.
  • Binary → Binary Regions → Show Objects – shows detected objects in image
  • Binary → Morphology → Erode – Shrinks object edges.
  • Binary → Morphology → Open – Removes small bright specks.
  • Binary → Morphology → Close – Fills small gaps in objects.
  • Binary → Morphology → Dilate – Grows object edges.
  • Tools → Invert – Swaps light and dark areas.
  • Tools → Region Detection → DINO segmentation – Finds regions using a learned image model.
  • Tools → Region Detection → SAM Segments – Creates detailed masks from selected points or regions.
  • Tools → Region Detection → QT Segmentation – Splits the image into similar quadtree regions.
  • Tools → Region Detection → Cross Correlation – Finds where a pattern appears in another image.
  • Tools → Filters → Fit background – Removes uneven background lighting.
  • Tools → Filters → Quadtree – Divides the image into square regions of similar colour.
  • Tools → Spectral Analysis → Steerable Filter – Highlights edges in different directions.
  • Tools → Spectral Analysis → Complex Wavelet Decomposition – Breaks the image into directional detail layers.
  • Tools → Spectral Analysis → Wavelet Denoising – Reduces noise while keeping edges.
  • Tools → Spectral Analysis → Laplacian Pyramid – Shows image detail at several scales.
  • Tools → Spectral Analysis → Hadamard – Shows repeating patterns using a fast transform.
  • Tools → Spectral Analysis → FFT – Shows the image in frequency space to reveal repeating patterns.
  • Tools → Drawing → Drawing Tools – Opens the drawing and painting tools.
  • Tools → Drawing → Add Shapes – Adds editable shapes to the image.
  • Tools → Data Reduction → PCA – Uses PCA to highlight information in images.
  • Tools → Data Reduction → HDBSCAN – Groups similar colours or regions automatically.
  • Tools → Data Reduction → K-Means – Groups pixels into a chosen number of colours.
  • Tools → Data Reduction → SOM – Organises similar colours into a map.
  • Tools → Mathematical → Subtract – Subtracts one image from another.
  • Tools → Mathematical → Add – Adds two images together.
  • Tools → Mathematical → Multiply – Multiplies two images together.
  • Tools → Custom – Runs your own code on the image.
  • Colours → Palette – Chooses the colours used for objects and regions.
  • Patterns → Tile – Opens the pattern tile designer.
  • Patterns → Design – Opens the pattern design tools.
  • Settings → Manage saved data & model cache – Clears stored settings and downloaded model files.
  • Settings → Image Library – Manages your local image folder and saved results.
  • Settings → Global – Changes app-wide display and behaviour settings.
  • Settings → Show Settings – Shows or hides the settings panel.
  • Settings → Help – Opens the help guide.

File

Open

Open loads one or more image files into the gallery. Files are decoded by the browser and become local working images; nothing is uploaded.

How to use
  1. Choose File → Open, or drag files onto the workspace.
  2. Select one or more image files in the file picker.
  3. Click a gallery tile to make it the current image.

Open image directory

Open image directory connects PatternToolkit to a local folder through the browser’s File System Access API. The folder is read-only. PatternToolkit stores a catalogue, small thumbnails and processed results in browser-managed storage, but it never uploads or modifies the source images.

How to use
  1. Choose File → Open image directory.
  2. Choose a folder when the browser asks. Chromium-based browsers provide the directory picker; unsupported browsers should use File → Open.
  3. Wait while the folder is scanned. Gallery tiles appear as thumbnails without decoding every full-resolution original.
  4. Click a tile to load its original for inspection or processing. Later visits reuse stored thumbnails and catalogued metadata.
  5. Use Settings → Manage saved data & model cache to view or delete generated image cache data.
Storage behaviour
  • Desktop Chromium browsers provide the native folder-handle picker. Embedded app browsers, Firefox, Safari and Chrome Android use a folder file picker; those imported files remain available for the current session only.
  • Source images are read-only and are never changed or deleted.
  • Thumbnails and processed results live in the browser’s origin-private storage; the catalogue lives in IndexedDB.
  • Memory eviction only releases decoded images. It does not delete stored thumbnails or results.
  • If the browser cannot restore folder permission, choose File → Open image directory again.

New Image

New Image creates a blank raster image. By default its size matches the current viewable workspace. A preset paper size and DPI calculate exact pixel dimensions and give the image a page-style canvas with a white surround, shadow and dashed page edge. Custom/viewport images do not get that page presentation.

How to use
  1. Choose File → New Image.
  2. Pick a preset paper size for a page canvas, or Custom / viewport for a normal image that fills the workspace.
  3. Set orientation and DPI, and choose transparent or filled background.
  4. Press Create image or Apply to add the blank image to the gallery.
Controls
  • Paper size – Custom / viewport, A0–A5, Letter or Legal.
  • Orientation – portrait or landscape for preset paper sizes.
  • DPI – pixels per inch used to convert millimetres to pixels.
  • Width and Height (px) – exact pixel dimensions. Editing either switches the paper size back to Custom.
  • The report line shows the active paper, DPI, pixel size and physical millimetre size.
  • Transparent background – creates alpha transparency. When off, the Palette background colour fills the image.
  • Preset paper only – the white page surround, shadow and dashed page edge appear only when a preset paper size is chosen. Custom/viewport images use the full workspace without a page frame.

Save

PatternToolkit keeps working images in the gallery. Saving downloads a copy to your device; it does not replace the gallery image or save a project file.

How to use

Right-click a gallery tile and choose Save Image As. The browser downloads the tile’s current image source with the filename image.png. Edited images are normally re-encoded as PNG; an unedited opened JPEG or GIF can retain its original encoded bytes despite the .png filename.

Save images as GIF animation

GIF export turns selected gallery images into an animation. Frame order is gallery/DOM tile order, not the order in which you selected them. The encoder scales large frames down to a practical maximum so the animation remains usable.

How to use
  1. Ctrl/Cmd-click at least two gallery images.
  2. Choose File → Save images as GIF animation.
  3. Frames play in gallery tile order, not click order.
  4. Wait for the progress overlay to finish; the GIF downloads automatically.

Webcam → Capture Image

Capture Image takes a webcam frame and runs it through the Steerable Filter; it does not add the raw camera frame. The browser asks for camera permission the first time.

How to use
  1. Choose File → Webcam → Capture Image.
  2. Allow camera access when the browser asks.
  3. The filtered captured frame appears in the gallery.

Webcam → Capture Video

Capture Video repeatedly grabs webcam frames and runs the live steerable-filter preview. It is intended for experimenting with a filter on a live camera feed, not for recording a video file.

How to use
  1. Choose File → Webcam → Capture Video.
  2. Allow camera access and wait for the preview to start.
  3. Untick Capture Video to stop the live capture.

Open last image

Open last image is a shortcut menu built from recently opened files. Recent image data is kept locally so a previous file can be restored quickly.

How to use

Open File → Open last image and choose an entry from the submenu. The list is rebuilt from the recent images stored in this browser.

Record Macro → Record

Macro recording captures processing commands and their settings so they can be replayed on another image. The current recorder only captures commands in the Binary and Tools menus. File, Edit, Image, Select and Data Reduction commands are not recorded.

How to use
  1. Choose File → Record Macro → Record.
  2. Run Binary or Tools processing commands.
  3. Untick Record when finished.
  4. Use Record Macro → Play to replay the captured list.

Record Macro → Play

Play re-runs the recorded Binary and Tools commands using their saved settings. Data Reduction commands can be recorded but cannot currently be replayed by the worker.

How to use
  1. Select the image to process.
  2. Choose File → Record Macro → Play.
  3. Wait for the commands to finish, then undo if the result is not wanted.

Record Macro → Edit Macros

Edit Macros is a registered panel for the recorded macro list. In the current build it is a legacy placeholder: its textarea is empty, its select has no options, and its Delete buttons are not connected. Recorded macros still live in browser settings and can be replayed with Play.

Current behaviour
  • This panel is a legacy placeholder and is not connected to the stored macro list.
  • Recording appends command entries to settings.macroCommands.
  • Play reads that stored list; it does not read edits made in the Edit Macros panel.
  • Delete Macro, Delete All Macros, the select box and the textarea are not currently wired to the stored list.
  • Use the browser’s saved-data tools or clear site data if you need to reset recorded macros.

Edit

Undo

Undo restores the previous image state from the gallery history.

How to use

Choose Edit → Undo or press the Undo toolbar button. Repeat to step further back through the available states.

Redo

Redo re-applies an edit that was undone.

How to use

Choose Edit → Redo or press the Redo toolbar button.

Cut

Cut copies the current selection or selected objects to the internal clipboard and removes them from the image. Cut pixels can be made transparent or filled with the palette background colour.

How to use
  1. Select a region or select objects on the canvas.
  2. Choose Edit → Cut.
  3. When an image-region selection is cut, the cut pixels are also added as a new gallery image named *-cut.
  4. Paste the clipboard or use Undo to restore the cut area.
Selection behaviour
  • With no image-region selection, Cut clears the whole canvas area; it does not silently do nothing.
  • With selected objects, Cut removes those objects instead of image pixels.
  • The Leave transparency on cut/delete option in the Selection panel controls whether cleared pixels become transparent or take the Palette background colour.

Copy

Copy places the current image, an image selection or selected objects on the internal clipboard without changing the source. A copied whole image can also be attached to shapes as a porthole source when it is pasted.

How to use
  1. Choose what to copy: the whole current image, an image-region selection, or selected objects on the canvas.
  2. Choose Edit → Copy.
  3. Use Paste to create the copy or attach the copied image to selected shapes.
What gets copied
  • Selected objects – copies the selected image objects or shapes. The object clipboard takes priority over an image copy.
  • Image-region selection – copies only the selected image pixels.
  • Whole image – with no image selection and no selected objects, Copy captures the entire current image. This is the form used as a full-canvas shape porthole.
  • Gallery image – selecting gallery thumbnails and copying captures those whole gallery images.
Shape porthole workflow
  1. Copy a whole image first.
  2. Select one or more shapes on the canvas.
  3. Choose Edit → Paste. Each shape receives a reference to the copied image and the image point under its centroid.
  4. Use Fix copied image to shape in Add Shapes or Get Objects to lock or release the image.

Paste

Paste always creates a new gallery image for copied image pixels. The new image uses a transparent background, keeps the copied pixels in their original relative positions, and becomes the current gallery image.

How to use
  1. Copy or cut something first.
  2. Choose Edit → Paste or press Ctrl+V.
  3. The new transparent image is added to the gallery and selected automatically.
Behaviour
  • Image pixel paste no longer uses Paste in place or the selected shape as a destination.
  • If the clipboard contains objects, Paste creates copies of those objects in the current image.
  • FFT mask paste remains a separate operation in the FFT panel.

Delete

Delete acts on selected objects, an image-region selection, or selected gallery tiles, depending on what is selected.

How to use
  • Selected objects – deletes those object records.
  • Image-region selection – clears or fills the selected pixels according to the Selection panel’s cut/delete transparency option.
  • Selected gallery tiles – asks for confirmation and deletes those gallery images.
  • Nothing selected – logs “Nothing selected” and deletes nothing. It does not delete the current image automatically.

Close All

Close All clears the gallery and starts again with a blank image.

How to use

Choose Edit → Close All and confirm. Save anything you need first; closing is not a substitute for downloading a copy.

Replace Image

Replace Image controls what happens to processing results. When it is off, each result is added as a new gallery image. When it is on, the result replaces the pixels of the current image instead.

How to use
  • Use the Replace Image toolbar toggle or the matching Edit → Replace Image checkbox.
  • Leave it off to preserve the current image and its distance-transform data.
  • Turn it on when you want to work on the result in place; Undo restores the previous image.

Image

Scale Image

Scale Image resamples the current image to a new pixel size. Downscaling reduces detail and memory use; upscaling cannot create genuinely new detail.

How to use
  1. Choose Image → Scale Image.
  2. Enter the scale factor or target dimensions.
  3. Press Apply.
Controls
  • Width and Height (px) – target pixel dimensions.
  • Lock aspect ratio – changing one dimension updates the other to preserve the original proportions.
  • Scale factor – multiplies the current image size and fills the width/height fields.
  • Use image size – resets both dimensions and the factor to the current image.

Canvas Size

Canvas Size changes the image pixel canvas without resampling the existing pixels. It is useful for adding a margin or cropping by reducing the canvas. It does not create the paper-style page frame; that presentation is set by choosing a preset paper size in File → New Image.

How to use
  1. Choose Image → Canvas Size.
  2. Set the new width and height and choose how the existing image is anchored.
  3. Press Apply.
Controls
  • Width and Height (px) – new canvas dimensions.
  • Offset X and Offset Y (px) – where the existing image is placed inside the new canvas. Positive values move right/down.
  • Use image size – resets the canvas to the current image size and zero offsets.
  • Centre – centres the existing image in the new canvas.
  • The white page surround, shadow and dashed border are not controlled here; they only appear for images created from a preset paper size.

Size image to canvas

Size image to canvas measures the visible workspace and resamples the current image to those pixel dimensions. It changes the stored image size and records an undo state; it is not a temporary zoom.

How to use

Choose Image → Size image to canvas. The current image is scaled to the workspace viewport and its page-style border is removed. Use Undo to restore the previous size, or Scale Image for explicit dimensions.

Flatten image

Flatten image composites transparency onto white, producing an opaque image suitable for formats or comparisons that do not preserve alpha.

How to use

Choose Image → Flatten image. Use Undo if you need the transparent version back.

To Greyscale

To Greyscale converts the current image to neutral grey by replacing its red, green and blue channels with one mapped value. Alpha is preserved. The result is added as a new gallery image unless Edit → Replace Image is checked. Its menu tooltip says: Converts the image to greyscale using a standard luminance or channel mapping.

How to use
  1. Choose Image → To Greyscale.
  2. Choose a mapping in the settings panel.
  3. Press Apply.
Mappings
  • Luminance (Rec. 601) – 0.299R + 0.587G + 0.114B. The standard perceptual mapping used by most image editors and the default.
  • Luminance (Rec. 709) – 0.2126R + 0.7152G + 0.0722B. The high-definition luminance mapping with more weight on green.
  • Average RGB – (R + G + B) / 3. A simple non-perceptual average.
  • Lightness – (max + min) / 2. Uses the brightest and darkest channels only.
  • Maximum channel and Minimum channel – use the largest or smallest RGB component.

Transparent background

Transparent background is a per-image setting stored in the current image metadata. Disabling it immediately fills transparent pixels with the Palette background colour on the canvas and does not restore the lost alpha when enabled again. Undo is the way to recover the transparent pixels.

How to use
  1. Select the image.
  2. Tick or untick Image → Transparent background.
  3. Use Undo if you need to restore transparency after disabling it.
Behaviour
  • The menu checkbox reflects the current image’s metadata, not an app-wide preference.
  • Disabling transparency composites the image over the Palette background colour.
  • Re-enabling transparency changes the flag, but already flattened pixels remain opaque.

Crop to Selection

Crop to Selection keeps only the rectangular region you have selected and discards the rest of the image.

How to use
  1. Choose Select → Select Region and drag a rectangle.
  2. Choose Image → Crop to Selection.

Transform

Transform resizes, rotates and flips the current target. The target is chosen in this order: selected objects, a selected image region, then the whole image.

How to use
  1. Select objects, make an image selection, or leave everything unselected for the whole image.
  2. Choose Image → Transform.
  3. Check the target line: Selected objects, Selected image region or Whole image, with its x/y position and size.
  4. Change width/height, angle or flip controls and press the matching button. For object groups, press Apply to apply the width/height fields.
Controls
  • Width and Height – target size in pixels. For object groups, the whole selection is scaled as a group.
  • Use target size – resets the width and height fields to the current target bounds.
  • Snap rotation to 45° – controls the angle input’s sticky behaviour. The Rotate button still snaps angles within about 7° of a 45° multiple even when this box is off.
  • Angle – the rotation amount in degrees, with both a slider and a numeric field.
  • Rotate – rotates the target around its centre. Selected objects rotate around the group centre; shapes keep editable vector geometry.
  • Flip H and Flip V – mirror the target horizontally or vertically.
  • Canvas corner handles – when Transform is open, a yellow dashed bounds box and blue corner handles appear. Drag a corner handle to resize the target; the width and height fields update and the transform is applied when you release.
What gets changed
  • Selected objects – only the selected objects move, scale, rotate or flip. The rest of the image is untouched.
  • Selected image region – the selected pixels are transformed in place; rotation and flipping keep the region centred.
  • Whole image – the current image is resized, rotated or flipped. Resizing the whole image also scales its object metadata.
  • Image objects use nearest-neighbour resampling during rotation and flip, preserving hard pixel edges. If all selected objects are shapes, rotation keeps editable vector geometry. A mixed selection of shapes and image objects is rasterised as one object group, so the shapes stop being editable as vectors.
  • For a shape with a copied image, resizing reveals more of the source image rather than zooming the source. An unfixed porthole stays aligned with the image canvas; a fixed porthole rotates and moves with its shape.
  • Resizing the whole image also scales the copied-image reference and centroid, so the porthole stays aligned after the image coordinate system changes.

Measurements → Show Grid

Show Grid draws a measurement grid over the workspace. Grid spacing, colour and thickness are set in the Grid Settings panel. The current grid draws lines only; there is no coordinate-label option.

How to use
  1. Choose Image → Measurements → Show Grid.
  2. Adjust the grid controls in the settings panel.
  3. Use the same menu item to hide the grid.
Controls
  • Show grid – toggles the overlay.
  • Offset X/Y and Spacing X/Y – position and spacing of the grid lines in image pixels.
  • Line type – solid, dashed or dotted.
  • Thickness and Grid colour – line appearance.
  • Use zero offsets – aligns the grid to the image origin.
  • There is no coordinate-label control; the grid draws lines only.
  • Changes apply live as you edit the controls.

Measurements → Measure Line

Measure Line draws a draggable line and reports its pixel length, angle and endpoints.

How to use

Choose Image → Measurements → Measure Line, then drag the line on the canvas. Use Measure Settings to change its colour, thickness and touch behaviour.

Measurements → Measure Settings

Measure Settings controls the draggable measurement line only. It does not control object outlines or the object measurement report; those use their own colours and fixed widths.

How to use

Choose Image → Measurements → Measure Settings, change the line values and press Apply. The line must be visible to see the changes.

Line controls
  • Show line – hides or shows the measurement line without losing its endpoints.
  • Snap to 45° – constrains the dragged endpoint to 45-degree multiples.
  • Snap endpoint to image edges and Edge search radius (px) – searches for the strongest gradient near the endpoint and snaps to it.
  • 45° stickiness – how strongly an angle near a 45-degree step is attracted to it.
  • Touch grab influence (px) – extra grab tolerance for touch and pen input.
  • Line colour and Line thickness (px) – line appearance.
  • The readout shows the current length, angle and endpoints. Reset line creates a fresh horizontal line across the middle.
  • This panel does not control object outlines or the object measurement report.

Measure Objects

Measure Objects is a registered measurement report for detected image objects. There is currently no menu item that opens its standalone panel; the usable report is shown inside the Connected Components panel when Measure objects is enabled.

How to use
  1. Run Connected Components on a binary image.
  2. Enable Measure objects in the Connected Components panel.
  3. Read the report in that panel. The standalone Measure Objects entry is not exposed in the current menu.
Controls and report
  • The report lists object count and each object’s ID, pixel count, bounding-box width/height, oriented width/height, angle, percentage of all objects and percentage of the image.
  • It does not include centroid or position columns.
  • Refresh measurements in the registered panel recalculates the report from the current connected-components or binary image, but that panel is not currently reachable from the menu.

Select

Select Region

Select Region arms a rectangular selection on the current image. The selection is used by crop, copy, cut and other region-aware operations.

How to use

Choose Select → Select Region, then drag a rectangle on the canvas. The Selection panel opens with the exact offset and size.

Select by Colour

Select by Colour picks one pixel and selects every pixel whose hue, saturation and value are inside the three tolerances. The original image stays visible. Only the selected pixels flash every half second between the pixel inverse and the clicked colour. A visible crosshair follows the pointer and marks the last clicked pixel. The picker is active while the panel is open; there is no separate picker button. The selection is a transient mask for copying; it does not create image objects or run Connected Components. The menu tooltip says: Selects pixels by hue, saturation and value tolerance and flashes them for copying.

How to use
  1. Choose Select → Select by Colour. The cursor becomes a picker over the image.
  2. Set the hue, saturation and value tolerances. Defaults are 10°, 32 and 32.
  3. Click a pixel on the image.
  4. Click another pixel to replace the selection. The original image remains unchanged.
  5. Choose the copy mode, then use Ctrl+C (or Cmd+C) to copy the selected pixels.
  6. Use Ctrl+V (or Cmd+V) to paste them into a new transparent gallery image.
  7. Press Esc to clear the flashing selection; click again to pick another colour.
Controls
  • Hue tolerance – allowable distance around the colour wheel in degrees. The comparison wraps around red. Default 10°.
  • Saturation tolerance – allowable difference in colour saturation on a 0–255 scale. Default 32.
  • Value tolerance – allowable difference in brightness on a 0–255 scale. Default 32.
  • Copy as binary – makes selected pixels white.
  • Copy as original colour – keeps the source image colours. This is the default.
  • Copy as exact colour – fills every selected pixel with the clicked colour.
  • Ctrl+C always rebuilds the clipboard from the current selection and current copy mode.
Clipboard

Every copy mode writes the selected pixels onto a transparent background. Pasting always creates a new gallery image and switches to it; the old Paste in place behaviour is no longer used for image paste.

Connected Components

Connected Components is a separate later stage. If object analysis is needed, first produce a binary image from the selection and then run Binary → Binary Regions → Connected Components on that binary image. Select by Colour itself only keeps the mask and the clipboard result.

Select All

Select All selects every gallery image and creates a full-image selection on the current image.

How to use

Choose Select → Select All. This is useful before GIF export or a multi-image operation.

Deselect All

Deselect All clears the gallery selection and the rectangular image selection.

How to use

Choose Select → Deselect All.

Selection panel

The Selection panel shows the exact rectangle coordinates for region-aware operations. Pasting an image always creates a new transparent gallery image and switches to it. Cut and delete can leave transparency or fill with the palette background colour.

How to use
  1. Make a selection with Select Region.
  2. Edit the offset, width or height in the panel if you need exact coordinates.
  3. Choose the paste and cut transparency options.
  4. Press Apply, or use Clear selection to remove it.
Controls
  • Offset X and Offset Y (px) – top-left position of the selection rectangle.
  • Width and Height (px) – exact selection size.
  • Leave transparency on cut/delete – cleared pixels become transparent; unchecked uses the Palette background colour.
  • Clear selection removes the selection rectangle without changing image pixels.

Binary

Threshold

Threshold produces a 0/255 result. With Binary Image checked it creates one greyscale binary mask; unchecked it thresholds the red, green and blue channels independently and outputs a colour 0/255 image. It does not preserve the original grey levels. Its menu tooltip says: Turns an image into black and white using brightness limits.

How to use
  1. Choose Tools → Intensity segmentation → Threshold.
  2. Pick a method and adjust the range or channel values.
  3. Choose whether Binary Image is checked. This changes both the output and how Colour Value is interpreted.
  4. Press Apply. The output is always 0/255 per channel; original grey levels are not preserved.
Threshold methods
  • Greyscale Value (min) – keeps pixels whose luminance is at or above the minimum and outputs 0/255.
  • Greyscale Range – keeps pixels whose luminance is inside the minimum/maximum range.
  • Colour Value – when Binary Image is unchecked, applies separate red, green and blue thresholds. When checked, the three thresholds are averaged and the pixel’s luminance is compared with that single averaged threshold.
  • Otsu (auto) – computes one luminance threshold when Binary Image is checked, or separate channel thresholds when unchecked.
  • Entropy (auto) – computes one luminance threshold or separate channel thresholds using histogram entropy.
  • Cluster (auto) – histogram clustering, not k-means. Binary Image selects grey-histogram clustering; unchecked selects per-channel RGB clustering. The output uses the requested number of cluster levels, not necessarily two.
  • Number of clusters – used only by Cluster mode.

Threshold from Background

Threshold from Background samples a rectangle of background and creates a new binary image using per-channel mean and 3-standard-deviation tolerances. It does not estimate a background in patches and does not subtract a background surface. Its menu tooltip says: Finds objects by comparing them with a background sample.

How to use
  1. Choose Tools → Intensity segmentation → Threshold from Background. This immediately arms a drag-rectangle mode; no settings panel is opened.
  2. Drag a rectangle over an area that represents the background only.
  3. On release, the tool computes the red, green and blue means and tolerances from that rectangle.
  4. A new image named BgThres is added: white where any channel differs from its background mean by more than three standard deviations, black elsewhere.
Behaviour and limits
  • Only the rectangle you draw is used as the background sample; the result covers the current processing scope.
  • Foreground pixels are detected independently per channel. A pixel is white if any channel exceeds its own tolerance.
  • The source image is not changed; a new binary image is added to the gallery.
  • The registered patch-size dialog is not used by the current menu command. There is no patch-size control in the live workflow.
  • Choose a clean background area with no foreground objects, otherwise the mean and 3σ tolerances will be biased.

Morphology → Erode

The current Erode command applies a per-channel 3×3 minimum filter. It is not a thresholded binary erosion: it does not binarise the image first. On a black-and-white mask it shrinks white regions; on a colour image it independently darkens each RGB channel to the darkest value in the neighbourhood.

How to use
  1. Create a binary mask first if you want binary erosion.
  2. Choose Binary → Morphology → Erode.
  3. Press Apply.
Controls and limits
  • The worker applies a per-channel 3×3 minimum filter. There is no exposed kernel-size control in this panel.
  • The visible Threshold, Red, Green and placeholder controls are legacy and are ignored by the current Erode worker.
  • The operation replaces the image in place; use Undo to restore it.

Morphology → Open

Opening is intended to erode and then dilate, but this command is not implemented in the current worker. Choosing it reports Binary Open not yet implemented and leaves the image unchanged.

How to use

Do not use this command yet. Run Erode and then Dilate manually if you need opening behaviour, or use Connected Components to remove small objects.

Morphology → Close

Closing is intended to dilate and then erode, but this command is not implemented in the current worker. Choosing it reports Binary Close not yet implemented and leaves the image unchanged.

How to use

Do not use this command yet. Run Dilate and then Erode manually if you need closing behaviour.

Morphology → Dilate

Dilate applies a per-channel 3×3 maximum filter. On a binary mask it grows white regions; on a colour image it independently brightens each RGB channel to the brightest value in the neighbourhood.

How to use

Choose Binary → Morphology → Dilate. Undo if the expansion merges objects you need to keep separate. There is no exposed kernel-size control; the current kernel is 3×3.

Connected Components

Connected Components labels groups of touching foreground pixels and creates image objects. It can draw centroids, save them for SAM seeding and produce an object measurement report; the resulting objects can be selected, transformed and edited individually. If the image is not exactly thresholded, it reports that and applies Otsu’s method to build a binary mask for the run without changing the source image. Its menu tooltip says: Finds and labels separate objects in a binary image.

How to use
  1. Create a binary mask with Threshold or an appropriate filter. If the image is not binary, Connected Components reports it and uses Otsu’s method for that run.
  2. Choose Binary → Binary Regions → Connected Components. This runs immediately with the current saved options and opens the panel.
  3. Change Minimum component size, Show centroids, Measure objects or Save centroids for SAM if needed.
  4. Press Apply to run again with the new options. Each run adds a new component result image.
  5. Open Binary → Binary Regions → Get Objects to select, group, copy, order, measure or extract the detected components.
Controls
  • Minimum component size – components smaller than this pixel count are skipped. The default is 1 pixel, which keeps every detected component. Changing the value immediately hides smaller components in the image preview; press Apply to commit the new result. The run message reports how many components were skipped by the filter.
  • Show centroids – draws a white cross at the centroid of every component.
  • Measure objects – shows the object measurement report in the panel after a run.
  • Save centroids for SAM – stores the centroid list in browser storage under patterntoolkit-dino-centroids for SAM seeding and prints the JSON in the message area. This replaces the old Morphology → CC Centroids command.
  • The report contains object count, ID, pixel count, bounding-box width/height, oriented width/height, angle, percentage of all objects and percentage of the image. It does not print centroid coordinates.
  • Choosing the menu item already runs the operation once. Pressing Apply again is a second run and adds another result.

Distance Transform

The distance transform replaces foreground pixels with their distance to the nearest background pixel. Bright ridges mark object centres and the result is useful for watershed separation and shape analysis. Its menu tooltip says: Shows how far each object pixel is from the background.

How to use
  1. Threshold the image to make a binary mask.
  2. Choose Binary → Binary Regions → Distance Transform. If the image has no stored distance data and no objects are selected, the first run immediately adds a grayscale distance-transform image and opens the panel.
  3. Set the threshold grey level or drag on the histogram.
  4. Press Apply to add a second, thresholded/binary distance-transform image.
Controls
  • Threshold grey level – contour level on the distance histogram. Apply makes distance-transform pixels at or above the integer contour distance white.
  • Histogram – click or drag across the histogram to move the threshold interactively.
  • Distance measurement line – shows the current contour distance and related statistics below the histogram.
  • If objects are selected, the transform is computed from those objects instead of the whole binary image.
  • The first menu run and each Apply can add another gallery result; delete or undo results you do not need.
  • The stored distance data is also the input for Binary → Binary Regions → Separate Components.

Separate Components

Separate Components opens the Watershed settings panel. It splits touching objects into separate regions by starting from a seed region in each object and growing outward through increasing inverted distance levels. The seed region is controlled by Watershed seed depth in this panel: a percentage of each object’s maximum distance, measured outward from the deepest interior point toward the edge. At 0% the seed is the exact maximum plateau, which reproduces the original behaviour. Above 0% the cut moves outward from the maximum, so a long thin object with several equal maxima is kept as one region. At 100% the whole object is seeded. Growth uses 8-neighbour connectivity so it matches the distance transform. Pixels exactly equidistant from two regions become watershed borders and are drawn as background (label 0). Its menu tooltip says: Splits touching objects into separate regions.

How to use
  1. Create a binary mask with Threshold, or run Binary → Binary Regions → Connected Components or Distance Transform first.
  2. Choose Binary → Binary Regions → Separate Components. The settings panel is titled Watershed.
  3. Adjust Watershed seed depth if needed. The red overlay on the image previews the seed region before you apply.
  4. Press Apply. The coloured label result is added as a new image unless Replace Image is checked.
  5. Use the coloured regions for inspection, or run Connected Components on a binary result if you need object measurements.
Controls and behaviour
  • Seed depth – percentage of each object’s maximum distance used to grow its seed outward from the interior. The default is 10%; 0% uses the exact maximum and reproduces the original behaviour; 100% seeds the whole object. Changing the value updates a red overlay on the image showing the current seed region before you apply.
  • Connectivity – regions grow through all 8 neighbours, including diagonals, matching the distance transform.
  • Distance data – Separate Components uses stored distance-transform data, selected image objects, or computes a distance transform from the current binary image.
  • Each pixel is processed once. Equal-distance plateaus are assigned to their nearest region, and only exact ties become borders, so the result does not depend on scan order.
  • Region labels are coloured with the shared object palette. Label 0 is the dark background and also marks watershed borders.
  • Replace Image overwrites the current image and keeps an undo state; otherwise a new gallery image is added.

Get Objects

Get Objects is the object manager for image objects detected by CC and for the shapes added with Add Shapes. It provides multi-selection, clipboard operations, grouping, measurements, z-order control, extraction to separate images and access to the Transform tools. Its menu tooltip says: Turns labelled regions into selectable image objects.

How to use
  1. Run Binary → Binary Regions → Connected Components to create image objects, or add shapes with Tools → Drawing → Add Shapes.
  2. Choose Binary → Binary Regions → Get Objects.
  3. Select one or more rows in the object list, or click objects on the canvas.
  4. Use the buttons, z-order controls and keyboard shortcuts below.
  5. For resizing, rotating or flipping, select the objects and open Image → Transform.
Object list and multi-selection
  • The list shows every object in draw order, with a colour/icon swatch, name, type and its top-left image coordinate.
  • Click a row to select only that object. It becomes the active object.
  • Ctrl/Cmd-click or Shift-click rows to add or remove objects from the selection.
  • On the canvas, click an object to select it. Ctrl/Cmd/Shift-click toggles it in the selection. Long-press on touch also toggles it.
  • Drag on empty canvas to draw a marquee; every object the marquee touches is selected.
  • Group rows appear below the objects. Click a group row to select all object IDs in that group.
  • Select all selects every object on the current image. Clear clears the selection without deleting anything.
Clipboard and delete buttons
  • Copy copies the selected objects to the object clipboard. Cut copies and removes them. Paste pastes the clipboard into the current image and scales it to fit the current canvas.
  • If the clipboard contains a copied image and shapes are selected, Paste attaches the image to each shape as a porthole instead of creating a gallery copy. Use Fix copied image to shape in this panel or in Add Shapes to lock it.
  • Delete removes the selected objects and cleans up any groups that become too small.
  • These buttons also respect image-region or image clipboard contents where applicable; the status line below the workspace reports what happened.
Group, Ungroup and Measure group
  • Group needs at least two selected objects. It creates a named selection shortcut containing their IDs; it does not merge their pixels.
  • Ungroup removes any groups that contain a currently selected object.
  • Measure group reports the number of selected objects, their IDs, combined bounding box, combined pixel count and the selected area as a percentage of the image.
Extract objects to individual images

Extract objects to individual images creates one gallery image per selected object, sized to that object. If a matching full-size original image is also selected, extracted objects use the original image pixels; otherwise they are white binary masks. This is useful for inspecting or reusing individual regions.

Draw order
  • Bring forward moves the selection one draw-order step forward. Bring backward moves it one step back.
  • Keyboard shortcuts: ] brings selected objects forward one step and [ sends them backward one step.
  • Moving objects on the canvas automatically places the moving selection at the top of the draw order.
Canvas editing
  • Drag an image object or shape to move it. With several objects selected, the whole selection moves together.
  • Shape objects have a centre move region and handles. Drag the centre to move, drag elsewhere inside the shape to rotate, and drag blue bounding-box corners to resize. Visible white vertex dots can reshape vertices where the blue corner is not covering them; edge-midpoint reshape targets are not drawn in the current build.
  • Image objects do not have shape deformation handles. Use Image → Transform to resize, rotate 90°, flip horizontally or flip vertically.
  • Double-click a shape’s rotation area to rotate by 360 / (sides × 2) (square 45°, triangle 60°, pentagram 36°, hexagram 30°, ellipse 90°); double-click the centre to toggle contact stickiness, which is off by default.
  • When a copied image is attached to a shape, the shape behaves as a porthole. Unfixed windows reveal different pixels as they move, resize or rotate; fixed windows keep the same pixels when moved and rotate with the shape.
  • Selected, hovered and active objects are drawn even when Binary → Binary Regions → Show Objects is off. The toggle mainly hides unselected object outlines.
Transform selected objects

Select one or more objects, then open Image → Transform. The Transform panel reports the selected group bounds and sets width, height, rotation angle, 45° snapping, Rotate, Flip H and Flip V. Dragging the blue corner handles on the canvas resizes the target directly. All-shape selections keep editable vector geometry; a mixed selection of shapes and image objects is rasterised, and image objects use nearest-neighbour pixel transforms.

Keyboard shortcuts
  • Delete or Backspace deletes selected objects.
  • Ctrl/Cmd+C, Ctrl/Cmd+X and Ctrl/Cmd+V copy, cut and paste.
  • ] brings to front; [ sends to back.

Show Objects

Show Objects controls whether unselected image objects and shapes are drawn as overlays. Selected, hovered and active objects and shape handles are still drawn when it is off. Grid, measure-line, distance-transform and transform-bound overlays are independent of this toggle. Its menu tooltip is: shows detected objects in image.

How to use

Tick Binary → Binary Regions → Show Objects to show all object outlines, or untick it to hide only the unselected object outlines. Use the individual measurement toggles for grid and line overlays.

Tools

Invert

Invert reverses the image colours, turning light areas dark and dark areas light. It is often used to turn a mask into its opposite.

How to use

Select the image and choose Tools → Invert.

Region Detection → DINO segmentation

DINO segmentation uses self-supervised vision-transformer features to group visually similar patches into regions. PCA reduces the feature dimensions, then clustering and optional Bayesian, growth or boundary refinement produce the displayed regions. DINO is good at finding semantic areas; it is not a semantic classifier.

How to use
  1. Select the image and choose Tools → Region Detection → DINO segmentation.
  2. Pick a display mode, then tune PCA components, cluster size and samples.
  3. Use the mode-specific refinement controls if you need them.
  4. Press Apply; the first run may download the model.
Display modes
  • DINO patches – raw patch clustering with optional centroids and borders. The “Migration freedom” control is visible in this mode but is not applied to the raw DINO-patch path.
  • Refined regions – DINO-seeded Lloyd refinement using RGB means and a Gaussian migration penalty. It does not use a texture term.
  • Boundary refined – pixel-level boundary optimisation with iterations, edge sliding and border-ring merge handling.
  • Cluster merge – merges similar DINO clusters using split threshold and merge iterations; can add region clusters and a quadtree view.
  • Grow – iterative region growing from seed pixels using start N, increment and local statistics radius.
  • Bayesian – probabilistic region assignment with a configurable number of passes.
Shared controls
  • PCA components – dimensions retained from DINOv2 patch features before clustering.
  • Min cluster size and Min samples – HDBSCAN density thresholds over the patches.
  • Model – Small, Base or Large DINOv2. The “Giant” option maps to the Large ONNX model; no Giant ONNX model is published.
  • Show region clusters, Show quadtree, Show boundaries on original, Show centroids and Show borders add diagnostic gallery images or overlays when the active mode supports them.
  • Apply runs the selected mode and adds the segmentation result to the gallery.

Region Detection → SAM Segments

SAM Segments uses the Segment Anything model to produce a mean-colour segment visualisation from point prompts. Seeds can come from DINO centroids; with that option off the worker uses a 6×6 grid of prompts. It adds one mean-colour image, not separate mask and label images.

How to use
  1. Run DINO segmentation first if you want DINO-centroid seeds.
  2. Choose Tools → Region Detection → SAM Segments.
  3. Keep Seed from DINO centroids enabled, or turn it off to use the automatic 6×6 prompt grid.
  4. Press Apply and wait for the model to load and segment.
Controls and limits
  • Model – the dropdown is present, but the current worker always uses Xenova/slimsam-77-uniform; the selected model value is not read.
  • Seed from DINO centroids – enabled uses stored DINO centroids. Disabled uses a 6×6 grid of point prompts.
  • Apply – adds one mean-colour SAM Segments gallery image. It does not add separate mask or label images.

Region Detection → QT Segmentation

QT Segmentation splits the image into quadtree cells and merges similar cells. The homogeneity value controls splitting, while colour, cluster, texture and DINO weights control merging. Texture-aware merging uses wavelet energy to avoid joining regions with similar colour but different structure.

The message area includes a Timings block after each run, showing the quadtree, HDBSCAN, growth and merge durations. This is diagnostic output; it does not change the result.

How to use
  1. Choose Tools → Region Detection → QT Segmentation.
  2. Set the cell variance and optional merge iterations.
  3. Adjust the colour, cluster, texture and DINO weights.
  4. Enable texture-aware merging if fine texture matters, then press Apply.
Controls
  • Cluster QT regions – refines the quadtree blocks into colour/texture regions.
  • QT merge iterations – number of cluster-merge passes; 0 runs all passes.
  • Show QT thresholded regions – adds debug images for the raw block averages and thresholded clusters.
  • Growth depth (bins, 0=auto) – colour-clustering growth depth; 0 uses the histogram knee.
  • QT cell variance (homogeneity) – split threshold. Higher values make fewer, larger cells; lower values split more. When texture-aware merging is enabled, the code caps the effective homogeneity at 90, so values above 90 behave like 90.
  • Merge gate weights – relative RGB, cluster, texture and DINO contributions. Factors that do not apply contribute zero.
  • Max difference – combined-distance ceiling for region fusion. 0 uses an automatic 80th-percentile value.
  • Texture-aware merging – adds wavelet texture to the merge gate so same-colour regions with different structure stay separate. Uses the shared wavelet levels and threshold.

Region Detection → Cross Correlation

Cross Correlation finds where a template occurs in a larger image. Template matching allows different image sizes and uses the larger image as the canvas; it slides the template and marks the strongest peak. Local normalised cross-correlation compares zero-mean windows over a regular grid and requires equal dimensions. Both are sensitive to scale and rotation, so pre-transform the images when those differ.

How to use
  1. Ctrl/Cmd-click two gallery images: the template and the larger canvas.
  2. Choose Tools → Region Detection → Cross Correlation.
  3. Choose template matching or local NCC and press Run Cross Correlation.
  4. Check the result image for the marked peak or correlation map.
Controls
  • Mode – Template matching uses different image sizes and the larger image as the canvas. Local NCC map requires equal dimensions.
  • Window size – local NCC window edge length in pixels.
  • Stride – spacing between local NCC windows. Smaller is smoother but slower.
  • Mask threshold – threshold used by the optional binary mask. In Local NCC mode it is a real normalised-correlation level. In Template matching mode the map is divided by its peak first, so the threshold is a fraction of the maximum response (0.5 means the top half of the peak), not an absolute correlation coefficient.
  • Create threshold mask – adds a binary mask for map values at or above the threshold.
  • Max FFT size – maximum padded FFT edge for template matching; larger images are rejected.
  • Run Cross Correlation – correlates the first two selected gallery images.

Filters → Fit background

Fit background estimates a smooth global lighting/background surface and either shows that surface or subtracts it. It fits a second-order polynomial surface to each RGB channel independently, then evaluates the surface at every pixel. It is for broad gradients such as uneven lighting, vignetting or paper tone, not for removing local objects or detailed texture.

How to use
  1. Select the image and choose Tools → Filters → Fit background.
  2. Set the grid size. This is the number of cells per side used to build the background samples.
  3. Leave Use averaged grid sampling enabled for the normal, more robust fit.
  4. Keep Subtract from image enabled to remove the fitted background, or disable it to output the background surface itself.
  5. Press Apply. A new gallery image is added with the fitted background or background-subtracted result; the source image is left unchanged.
What the algorithm actually fits

The tool is a global polynomial fit, not a blur and not a local per-pixel background estimate. With the default averaged sampling it:

  • divides the image into a grid size × grid size grid;
  • computes the mean value of every grid cell for the red, green and blue channels separately;
  • fits a quadratic surface using terms x², y², xy, x, y and a constant to those cell means;
  • evaluates that polynomial at every image pixel and clamps the result to 0–255;
  • keeps the alpha channel unchanged.

Because the fitted surface is only second order, it describes broad curvature and lighting gradients. Increasing the grid size gives more local cell averages, but the final surface is still smooth and global. Strong local shading or large objects can bias the fit.

Controls
  • Grid size – number of cells per side, default 10. A 10×10 grid produces 100 cell means. Larger values use smaller cells and more local samples; smaller values use larger cells and a coarser estimate. The polynomial remains quadratic at every grid size.
  • Use averaged grid sampling – enabled by default. Uses the mean of each grid cell at its centre, solved by least squares. This is more robust to noise and small details. Disabling it uses the legacy sampling mode: every 10th raw pixel with normalised coordinates and an SVD pseudo-inverse. That mode is faster but more sensitive to noise and foreground objects.
  • Subtract from image – enabled: computes original − fitted surface + mean(surface) per channel, preserving overall brightness and clamping to 0–255. Disabled: outputs the fitted background surface itself, which is useful for inspecting the model.
Limits
  • It cannot model sharp lighting edges, texture, shadows from objects or non-polynomial shading.
  • Each RGB channel is fitted independently; there is no colour-channel coupling.
  • If the polynomial solve fails, the result falls back to a flat mid-grey surface.
  • For uneven illumination with local structure, try Tools → Intensity segmentation → Threshold from Background or a spectral/low-pass workflow instead.

Filters → Quadtree

Quadtree repeatedly divides the image into four cells when local variance exceeds a threshold. The result is an adaptive block representation: flat areas stay large, detailed areas split into small cells.

How to use
  1. Choose Tools → Filters → Quadtree.
  2. Adjust homogeneity and minimum cell size; the preview updates live.
  3. Toggle cell borders to compare the block image with the grid.
Controls
  • Show cell borders – draws the lines between quadtree leaves. Turn off for a pure block-average image.
  • Cell split variance (homogeneity) – a cell keeps splitting while its colour variance is at or above this value. Higher = fewer, larger cells; lower = more, smaller cells.
  • Minimum cell size (px) – stops subdivision when a cell reaches this width and height.
  • All three controls update the live preview immediately.

Spectral Analysis → Steerable Filter

The steerable filter analyses oriented structure using a bank of rotated filters. It highlights edges and texture directions and is also used by the live webcam filter preview.

How to use

Select an image and choose Tools → Spectral Analysis → Steerable Filter. The filtered result is added to the gallery.

Spectral Analysis → Complex Wavelet Decomposition

The dual-tree complex wavelet transform gives approximate shift invariance and separate magnitude, real and imaginary components. Magnitude shows structure strength; phase encodes local edge geometry. Kingsbury and complex-Daubechies bases trade compact support against smoothness.

How to use
  1. Choose Tools → Spectral Analysis → Complex Wavelet Decomposition.
  2. Choose the output (magnitude, real, imaginary or phase) and filter.
  3. Set the number of levels; the live preview updates.
Controls
  • Output – magnitude, real part, imaginary part, or phase mapped to a hue wheel.
  • Levels – number of dyadic scales, clamped to what the image size supports.
  • Filter – Kingsbury 13/19 Q-shift, or complex Daubechies 6/14/22.

Spectral Analysis → Wavelet Denoising

Wavelet denoising applies a real discrete wavelet transform and shrinks small detail coefficients. Soft thresholding removes noise-like detail while keeping strong edges. Auto-MAD estimates the threshold from the median absolute deviation of the detail coefficients; the default multiplier is 3.

Basis and Channel apply only to the denoised image. Levels and T are shared with QT texture: QT thresholds Kingsbury quadrature magnitudes, while Denoise image thresholds the selected real Haar or Daubechies DWT.

How to use
  1. Choose Tools → Spectral Analysis → Wavelet Denoising.
  2. Select the basis and channel, and set the levels and threshold.
  3. Press Denoise image to create a separate denoised gallery image.
Controls
  • Basis – Haar or Daubechies 2/3/4 for the denoised image. QT texture always uses Kingsbury quadrature magnitudes.
  • Channel – Luminance denoises brightness and outputs greyscale; RGB denoises each colour channel separately.
  • Levels – transform depth, shared by QT texture and Denoise image.
  • Threshold T mode – Auto (MAD k), Fixed T, or None (0).
  • Noise k – Auto-MAD multiplier. The threshold is k × 1.4826 × MAD; default 3.
  • Fixed T – threshold used when the mode is Fixed T.
  • Denoise image – runs the real DWT denoiser. It does not modify the source or QT segmentation.

Spectral Analysis → Laplacian Pyramid

A Laplacian pyramid stores a blurred low-pass image plus signed detail residuals at each scale. Summing the upsampled levels reconstructs the original. The pyramid is useful for multiscale blending, detail enhancement and texture analysis.

How to use
  1. Choose Tools → Spectral Analysis → Laplacian Pyramid.
  2. Set the number of levels.
  3. Press Decompose to add the montage and optional layer images.
Controls
  • Levels – number of Gaussian/Laplacian pyramid levels.
  • Gaussian sigma – blur applied before each downsample; the residual is current minus the upsampled next level.
  • Channel – luminance or RGB.
  • Create layer images – adds each residual and the lowpass image to the gallery in addition to the montage.
  • Decompose – builds the pyramid from the anchored base source image. If the current gallery tile is a processed result, the transform uses its original source image, not the displayed result.

Spectral Analysis → Hadamard

The Walsh-Hadamard transform uses ±1 basis functions ordered by sequency (number of sign changes). Unlike FFT it needs no complex arithmetic. Spectrum mode keeps the full coefficients, shows log-magnitude values and links the spectrum image to a drawing mask. High-pass mode zeroes the low-pass square; orientation-band mode reconstructs the octave/orientation grid.

How to use
  1. Choose Tools → Spectral Analysis → Hadamard.
  2. Pick spectrum, high-pass or orientation-band output.
  3. For spectrum work, paint a mask with Drawing Tools, then run Inverse Hadamard.
Controls
  • Output – log-magnitude spectrum, high-pass edges, or orientation bands.
  • Spectrum block size – full power-of-two crop, or 8/16/32/64/128/256-pixel block transforms. Block mode applies to spectrum output only.
  • High-pass cutoff – fraction of the transform edge treated as low-pass. 0.25 matches the Python reference.
  • Log magnitude display – shows log1p(|coefficient|) instead of a signed spectrum.
  • Sequency order – reorders basis functions by number of sign changes.
  • Add band layer images – adds each orientation-band response to the gallery.
  • Max transform size – upper bound for the power-of-two crop; larger sizes are slower.
  • Run Hadamard computes the selected transform. Inverse Hadamard applies the current drawing mask to the stored spectrum.

Spectral Analysis → FFT

The 2D fast Fourier transform converts the image into spatial frequency coefficients. Low frequencies describe broad shading, while high frequencies describe edges and fine texture. PatternToolkit keeps full real and imaginary planes in memory and links spectrum, real, imaginary and phase gallery images to the source. Before the forward transform, transparent pixels are composited over the palette background, so shape cutouts become background-valued holes while the image keeps its alpha channel.

How to use
  1. Select the image and choose Tools → Spectral Analysis → FFT.
  2. Open Drawing Tools and paint on the spectrum to make a mask.
  3. Run Inverse FFT to create a new image from the masked spectrum; the source image is not modified.
  4. To overlay a spatial mask, copy an image first, then use Paste mask over inverse. Transparent clipboard pixels keep the inverse image underneath; opaque pixels replace it.
Controls
  • Create real image – adds a gallery view of the shifted real coefficients. Full precision remains in the FFT registry.
  • Create imaginary image – adds a gallery view of the shifted imaginary coefficients.
  • Create phase image – adds a hue-wheel view of atan2(imag, real).
  • Compute FFT – runs the forward transform on the anchored base source image. If the current tile is a processed result, its original source image is used.
  • Inverse FFT – applies the current drawing mask to the stored FFT and creates a new gallery image.
  • Paste mask over inverse – runs the inverse FFT, then composites the image clipboard over the result. Transparent mask pixels preserve the original inverse pixels.

Drawing → Drawing Tools

Drawing Tools paints mask objects on an FFT or Hadamard spectrum. The drawing store is keyed to the spectral transform, not to ordinary images, so it cannot be used to annotate a normal photograph. Painted areas form the inverse mask; Inverse/erase removes earlier mask objects.

How to use
  1. Create an FFT or Hadamard transform first.
  2. Choose Tools → Drawing → Drawing Tools.
  3. Select a brush, colour and size, then paint on the spectrum.
  4. Use the inverse transform to apply the spectral mask, or erase objects to change it.

The drawing mode refuses to enable when no current FFT or Hadamard spectrum is available.

Controls
  • Tool – Circle / sector, Line or Rectangle.
  • Inverse / erase – erases earlier mask objects instead of adding to the mask.
  • Drawing colour and Line width (px) – colour and stroke size for lines and circles.
  • Arc start (deg) and Arc end (deg) – sector angles for the circle tool. Use 0 to 360 for a full circle.
  • Draw on current spectral image – enables the mask overlay on the current FFT or Hadamard spectrum.
  • Clear mask removes every drawing object from this mask. Fill mask fills it so the next inverse transform removes all frequencies.

Drawing → Add Shapes

Add Shapes creates editable geometric objects using the MosaicMaker interaction model. The Triangle is a right-angled isosceles triangle. The Square can be deformed into a parallelogram, and the Triangle into other triangular variants. Older Parallelogram and Wedge objects open as deformed Square and Triangle objects. The highlighted centre incircle is the move region; dragging elsewhere inside the shape rotates it. Blue bounding-box corners resize the whole shape in X and Y. White vertex dots can reshape individual vertices where they are hit-testable; on an unrotated shape the blue corner overlaps the vertex, so the resize handle wins. Edge-midpoint deformation targets exist in the hit-testing code but are not drawn, so edge reshaping is not a reliable visible interaction in the current build. A deformation that would make the shape concave is rejected. A full circle only moves and resizes; an ellipse, arch or sector can rotate. The circle’s Arc setting cuts that many degrees out of the circle: 0° is a full circle, 180° is an arch, and 90° leaves a three-quarter sector.

Double-click the rotation area to rotate by 360 / (sides × 2): square and rectangle 45°, triangle 60°, pentagram 36°, hexagram 30°, ellipse 90°, and arch 90°. Other arc sectors step 60°. A full circle has no rotation step. Double-click the centre to toggle contact stickiness, which is off by default. When contact stickiness is on, moved shapes snap to nearby shape edges and corners. Snapping uses the real edge span: a nearby edge that does not overlap the moved edge does not attract it, and a corner only snaps to the part of an edge it actually meets. Circles, arcs and ellipses snap by their circumference rather than their bounding box. Border can be switched off, which disables the border width and colour controls; with transparent fill or no fill only the border is drawn. Shapes and Get Objects share the object list, selection and copy/cut/paste/delete operations. When a copied image is pasted into selected shapes, the shape becomes a movable window over that image. Fix Shape rasterises the selected shapes into the background image, removes them from the editable object list, and makes the result available to the FFT tools. Transparent fill writes real transparent pixels; no fill applies only the border and leaves the underlying pixels untouched.

How to use
  1. Choose Tools → Drawing → Add Shapes.
  2. Choose a shape from the list, then press Add Shape to place it at the image centre.
  3. Drag the highlighted centre region to move, or elsewhere inside the shape to rotate. Rotation holds near the shape’s fixed step angles.
  4. Drag the blue bounding-box corners to resize the whole shape.
  5. Use visible white vertex dots for vertex reshaping where they are not covered by a blue corner handle.
  6. Edge-midpoint reshape targets are not drawn in the current build, so treat edge reshaping as unavailable.
  7. Double-click the rotation area to rotate by one fixed step. On touch, long-press the rotation area for the same step. Double-click the centre to toggle contact stickiness (off by default).
  8. Set Arc to 180° for an arch, or 90° for a three-quarter sector. Leave it at 0° for a full circle.
  9. Use Flip H or Flip V in the Add Shapes panel to mirror the selected shapes.
  10. To use a copied image as a window, copy the image, select one or more shapes, then press Paste.
  11. Press Fix Shape to rasterise selected shapes into the background image. For a donut mask, fix a black filled circle, then add a smaller transparent-fill circle and fix that too.
Shape style controls
  • Fill colour – colour used inside the shape. Changes apply to the selected shape and to new shapes.
  • Transparent fill – while editing, only the border is drawn. Fix Shape clears the interior to real transparency in the background image.
  • No fill – draws only the border. Fix Shape applies border pixels only and leaves the interior image untouched. No fill overrides Transparent fill; pasted bitmap pixels are ignored when fixing.
  • Border – turns the outline on or off. When off, the width and colour controls are disabled.
  • Border width (px) – outline thickness in image pixels. Use 0 for no visible outline.
  • Border colour – outline colour.
  • Arc (degrees) – wedge angle cut out of a circle. 0° is a full circle, 180° is an arch, and 90° leaves a three-quarter sector.
  • Flip H and Flip V – mirror the selected shapes horizontally or vertically.
  • Contact stickiness – off by default. Double-click a shape centre to toggle it. When on, moving shapes snap to nearby shape edges and corners where their spans overlap; circles and ellipses snap by their circumference.
Pasted image window

Copy a whole image first, then select one or more shapes and use Paste. Each shape stores a reference to the copied image and the image point under its centroid. The source image is drawn through the shape mask, so the outline remains the visible boundary.

  • Unfixed – the default after paste. Moving a shape updates its centroid on the source image and reveals different pixels. Resizing or reshaping reveals more of the image. Rotating keeps the image aligned with the image canvas, so the pixels underneath stay in place.
  • Fix copied image to shape – locks the image to the selected shape. Moving the shape keeps the same pixels; rotating the shape rotates the image with it; resizing or reshaping reveals more pixels from the shape-aligned image.
  • The checkbox is disabled until a selected shape has a copied image. It applies to every selected shape that has one.
  • Copying, cutting and pasting a shape preserves its copied image, centroid and fixed state.
  • Outside the copied image the porthole is transparent, leaving the shape fill or border visible.
Shape operation buttons
  • Copy, Cut, Paste and Delete operate on the selected objects, just like the Get Objects panel.
  • Fix Shape rasterises selected shapes into the background in their current stacking order, then removes them from the editable object list. Use undo to restore the editable shapes.
  • Zoom in and Zoom out scale the selected shapes around their own centres (approximately 1.25× and 0.8× per press).
  • Bring forward and Bring backward move the selection one draw-order step at a time.
  • When a copied image is attached, the shape remains the visible window and the source image scrolls underneath it.
Shape list and selection

Shapes appear in Binary → Binary Regions → Get Objects alongside image objects. Use that panel for multi-selection, grouping, measurement and extraction. Shapes can also be transformed with Image → Transform when selected.

Data Reduction → PCA

Principal Component Analysis finds orthogonal directions that explain the most variance in a feature dataset. It is useful for reducing dimensions before clustering and for visualising which samples dominate each component. Long runs show progress and can be cancelled.

How to use
  1. Choose Tools → Data Reduction → PCA.
  2. Choose the feature source and number of components.
  3. Press Run PCA; score maps can be copied to the gallery.
Controls
  • Feature dataset – Wavelet vectors or RGB pixels.
  • Gaussian level (0 = off) – full-resolution features or anti-aliased downsampling.
  • Max feature rows – optional cap; the Gaussian level rises automatically if needed.
  • PCA components – number of principal components to keep.
  • Copy PCA eigen images – number of top eigen score maps added to the gallery (0 = none).
  • Run PCA – fits the model and adds the result images.

Data Reduction → HDBSCAN

HDBSCAN finds clusters of varying density without requiring a cluster count. It can label sparse samples as noise. Very large datasets are capped deterministically, with a warning and nearest-cluster assignment for rows outside the cap.

How to use
  1. Choose Tools → Data Reduction → HDBSCAN.
  2. Select the feature source and minimum cluster size.
  3. Press Run HDBSCAN; use Cancel in the progress overlay for a long run.
Controls
  • Feature dataset, Gaussian level and Max feature rows – shared dataset controls, as in PCA.
  • Min cluster size – smallest group HDBSCAN will accept as a cluster.
  • Min samples – density strictness; higher values produce fewer, denser clusters.
  • HDBSCAN cap – deterministic sample limit. Rows outside the cap are assigned to the nearest cluster and a warning is shown.
  • Run HDBSCAN – runs with progress and cancellation.

Data Reduction → K-Means

K-Means partitions samples into a fixed number of clusters by minimising within-cluster distance. The implementation uses k-means++ initialisation; a value below 2 (0 or 1) estimates a cluster count with silhouette scores first. Long runs show progress and can be cancelled.

How to use
  1. Choose Tools → Data Reduction → K-Means.
  2. Set the feature source and cluster count, or leave 0/1 for automatic estimation.
  3. Press Run K-Means.
Controls
  • Feature dataset, Gaussian level and Max feature rows – shared dataset controls.
  • K-Means k – fixed cluster count. 0 or 1 estimates the count first.
  • Max estimate k – upper bound used by the silhouette-score estimate.
  • Estimate K – computes a suggested cluster count and writes it into K-Means k.
  • Run K-Means – trains with k-means++ initialisation and adds the result.

Data Reduction → SOM

A self-organising map trains a two- or three-dimensional topology-preserving map. After training, every sample is assigned to its single best-matching node and rendered as a hard label/colour map. Long runs show progress and can be cancelled.

How to use
  1. Choose Tools → Data Reduction → SOM.
  2. Set the map dimensions, feature source and training options.
  3. Press Run SOM; the map colours samples by their best-matching node.
Controls
  • Feature dataset, Gaussian level and Max feature rows – shared dataset controls.
  • SOM grid – 2D 8×8 or 3D 5×5×5 topology.
  • SOM iterations – individual sample-update steps, not full passes over the dataset. Each step picks one training sample and updates its best-matching node and neighbours; more steps take longer.
  • Run SOM – trains the map and adds the colour-coded result.

Mathematical

The mathematical operations combine a background image with selected target images using pixel-wise subtraction, addition or multiplication. At least two gallery images must be selected. Images that do not match the background’s width and height are skipped.

How to use
  1. Ctrl/Cmd-click at least two gallery images, including the intended background candidate.
  2. Choose Tools → Mathematical → Subtract, Add or Multiply.
  3. Pick the background image; images named *-background are detected automatically.
  4. Press Apply. The background itself is skipped and each processed target gets a new gallery image.
Controls and behaviour
  • Background image – the image combined with the other selected targets.
  • Mean-normalise background – only affects Subtract. It adds the background’s per-channel mean back to target − background. Add and Multiply ignore it. It does not compute or match the target’s means.
  • Targets must have exactly the same dimensions as the background; mismatched images are skipped with a message.
  • The operation creates new gallery images with -background, +background or ×background suffixes; the source images are unchanged.

Custom

Custom runs your own JavaScript over the image pixels. The variables image (Uint8ClampedArray), width and height are available. Each pixel uses four bytes: red, green, blue and alpha.

How to use
  1. Choose Tools → Custom.
  2. Optionally enter a name and description.
  3. Edit the code, using let i = (y * width + x) * 4 to address a pixel.
  4. Press Apply to run the script on the current image.
Controls
  • Script name and Script description – labels stored with the current code; there is no saved-script list in the active panel.
  • Enter code here – JavaScript run once per image. image, width and height are in scope.
  • Apply runs the code on the current image.
  • Pixel layout is RGBA: i red, i+1 green, i+2 blue, i+3 alpha.
  • The legacy Save Script control is not present in the active toolbox panel.

Colours

Palette

The Palette stores foreground and background colours. The current build reads the background colour for blank-image fills, cut/delete fills and transparency flattening. The foreground value is stored and can be swapped, but drawing uses the separate Drawing Tools colour and shapes use their own fill controls, so the foreground value currently has no drawing effect.

How to use
  1. Choose Colours → Palette.
  2. Pick the foreground and background colours.
  3. Use Swap to reverse them, then press Apply.
Controls
  • Foreground colour – stored value, but currently has no drawing effect: Drawing Tools uses its own colour and shapes use their own fill.
  • Background colour – used for blank-image fills, cut/delete background fills and transparency flattening.
  • Swap reverses the two colours.

Patterns

Tile

Tile opens the pattern editor. It repeats or arranges an image across a tiled layout and provides controls for the tile geometry and repeat behaviour.

How to use

Choose Patterns → Tile and edit the pattern in the right-hand panel. Return to another tool to leave tile mode.

The Tile editor is a special panel: it does not have the normal Settings/Help tabs or an About tool block.

Design

Design is reserved for pattern design controls. In the current build, the working pattern editor is Patterns → Tile.

How to use

Use Patterns → Tile for pattern editing. The Design entry currently opens the neutral settings placeholder.

Settings

Manage saved data & model cache

This opens the shared saved-data page. It lists downloaded neural network models, generated image-library caches and shared game/puzzle data. Each list uses multi-selection and a Delete action. Deleting image cache data removes browser-generated catalogue metadata, thumbnails and processed results, but it does not change the source image folder.

How to use
  1. Choose Settings → Manage saved data & model cache.
  2. Use Ctrl/Cmd-click, Shift-click or Shift+Arrow to select rows in a list.
  3. Choose Delete selected for neural network models, image library caches or game/puzzle data.
  4. Confirm the deletion. Source image files are never modified.

To reset PatternToolkit settings or macros, clear the site/browser storage for this site.

Image Library

Image Library manages the local folder selected with File → Open image directory. It reports catalogue and browser-storage usage, and provides reconnect, rescan, thumbnail rebuild and cache-clearing actions. Source images remain read-only and are never changed by any of these actions.

How to use
  1. Choose Settings → Image Library.
  2. Use Open / replace directory to select a folder, or Reconnect directory if browser permission has expired.
  3. Use Rescan directory after adding, changing or removing source images.
  4. Use Rebuild thumbnails after clearing thumbnails or changing thumbnail settings.
  5. Use Cancel current operation to stop a long scan, rescan or thumbnail rebuild. Completed work is kept.
  6. Use Delete catalogue, thumbnails & results to remove all generated browser data for this library. It does not modify the source folder.
  7. Use Request persistent storage if the browser supports it and you want the cache retained under storage pressure.
Status and storage
  • Directory shows the connected folder and its permission state.
  • Catalogue shows image and missing-image counts.
  • Generated shows thumbnail and result counts plus cached bytes.
  • Browser storage shows estimated usage and quota; Persistence shows whether storage is persistent or best effort.
  • Thumbnail generation uses a small worker pool where the browser supports it, with a main-thread fallback.

Global

Global settings apply across the application. The current option draws a green outline around the current gallery thumbnail, not around the large canvas image.

How to use

Choose Settings → Global, tick or untick Show current image outline, then press Apply. The outline appears on the current gallery thumbnail (tile), not around the large canvas image.

Show Settings

Show Settings is a menu toggle retained for compatibility with earlier versions. In the current build, tools with options show their settings panel when chosen, and the panel itself has Settings and Help tabs.

How to use

Use Settings → Show Settings as a stored preference. To work with a tool, choose it from the menu and use the Settings tab that appears.

Help

The Help menu item takes you to this structured help section.

How to use

Choose Settings → Help. The page scrolls to the PatternToolkit help section.

Frequently asked questions

Are my images uploaded?

No. PatternToolkit processes images in your browser. The image pixels are handled by local JavaScript and Web Workers; they are not sent to a server for processing.

Why do some tools ask for two images?

Operations such as Cross Correlation and Mathematical need a second image. Select the two gallery images with Ctrl/Cmd-click, or choose the background image in the tool settings, before you apply the operation.

Why did a processing tool appear to do nothing?

Most tools need a current gallery image and their action button in the right-hand settings panel. That button may be Apply, Run PCA, Run HDBSCAN, Run K-Means, Run SOM, Compute FFT or another named action. Some tools also need a selection or a second image. Check the message line below the workspace for the reason.

How do I undo a change?

Use Edit → Undo, or the Undo toolbar button. Redo restores the change. Destructive image edits are recorded as undo states where the tool supports it.

How do I save a processed image?

Right-click an image tile in the gallery and choose Save Image As. The File → Save images as GIF animation command exports the selected gallery images as an animation instead.

What is a spectral mask?

FFT and Hadamard store complex or signed transform coefficients in memory and add linked gallery images for the spectrum. Drawing on the spectrum creates a mask; running the inverse transform uses that mask to rebuild an image.

When do I see a paper-style page border?

Only when you create an image with a preset paper size and DPI in File → New Image. Imported images and Custom / viewport images use the full workspace without the white page surround, shadow or dashed page edge.

Why is a large image or clustering run slow?

Transforms, segmentation and clustering are computationally heavy. PatternToolkit moves work to Web Workers where possible and provides progress and cancellation for long jobs, but image size and sample count still dominate the running time.

Keyboard and pointer tips

  • Ctrl/Cmd-click gallery tiles to select several images in order.
  • Long-press a gallery tile on touch to add it to the selection.
  • Right-click a gallery tile for Save Image As and Delete.
  • Right-click the canvas, or use the object controls, to work with objects and selections.
  • Drag the divider beside the settings panel to make the panel wider.
  • Use Undo rather than reprocessing an image when you only want to compare results.