Use Cases
- Cell counting
- Nuclei detection
- Marking points of interest
- Landmarks for registration
Annota provides a comprehensive set of tools for creating and editing annotations.
Tools enable users to interact with the image and create annotations. Each tool implements a specific interaction pattern:
| Tool | Purpose | Interaction |
|---|---|---|
| PointTool | Create point markers | Single click |
| RectangleTool | Draw rectangles | Click and drag |
| PolygonTool | Draw polygons | Click vertices, double-click to finish |
| PushTool | Edit polygon vertices | Click and drag to push/pull vertices |
| ContourTool | Extract contours from masks | Click to detect contours |
| SplitTool | Cut annotations into pieces | Click start point, click end point |
Activate a tool using the useTool hook:
import { useTool, PointTool } from "annota";
function MyComponent({ viewer }) { const pointTool = new PointTool();
useTool({ viewer, handler: pointTool, enabled: true, });
return null;}Allow users to switch between tools:
import { useTool, PointTool, RectangleTool, PolygonTool } from "annota";import { useState } from "react";
function ToolController({ viewer }) { const [activeTool, setActiveTool] = useState("point");
const tools = { point: new PointTool(), rectangle: new RectangleTool(), polygon: new PolygonTool(), };
useTool({ viewer, handler: activeTool === "pan" ? null : tools[activeTool], enabled: activeTool !== "pan", });
return ( <div> <button onClick={() => setActiveTool("pan")}>Pan</button> <button onClick={() => setActiveTool("point")}>Point</button> <button onClick={() => setActiveTool("rectangle")}>Rectangle</button> <button onClick={() => setActiveTool("polygon")}>Polygon</button> </div> );}Create point annotations with a single click.
Use Cases
Interaction
Single click to place a point marker at that location.
import { PointTool } from "annota";
const pointTool = new PointTool({ style: { fill: "#FF0000", fillOpacity: 0.8, stroke: "#FFFFFF", strokeWidth: 2, },});Draw rectangular regions by clicking and dragging.
Interaction:
import { RectangleTool } from "annota";
const rectangleTool = new RectangleTool({ style: { fill: "#00FF00", fillOpacity: 0.3, stroke: "#00FF00", strokeWidth: 2, },});Draw polygons by clicking to add vertices.
Interaction:
import { PolygonTool } from "annota";
const polygonTool = new PolygonTool({ style: { fill: "#0000FF", fillOpacity: 0.3, stroke: "#0000FF", strokeWidth: 2, },});Edit polygon vertices by pushing and pulling.
import { PushTool } from "annota";
const pushTool = new PushTool({ radius: 50, // Influence radius in pixels strength: 1.0, // Strength of the push effect (0-1) showCursor: true, // Show the cursor indicator});Interaction:
Cut annotations into multiple pieces with a line.
import { SplitTool } from "annota";
const splitTool = new SplitTool();Workflow:
Combine multiple selected annotations into a single annotation:
import { useAnnotator } from "annota";
function MergeButton() { const annotator = useAnnotator();
const handleMerge = () => { const merged = annotator.mergeSelected(); if (merged) { console.log("Successfully merged annotations"); } };
return <button onClick={handleMerge}>Merge Selected</button>;}Automatically detect contours from underlying image data.
import { ContourTool, loadOpenCV } from "annota";
// Load OpenCV before using ContourToolawait loadOpenCV();
const contourTool = new ContourTool({ threshold: 128, // Threshold for binary mask minArea: 100, // Minimum contour area maxContours: 1000, // Maximum number of contours});All tools support these common options:
const tool = new PointTool({ style: { fill: "#FF0000", fillOpacity: 0.8, stroke: "#FFFFFF", strokeWidth: 2, },});const tool = new PointTool({ layer: "tumor", // Annotations will be created on the 'tumor' layer});const tool = new PointTool({ properties: { type: "cell", confidence: 1.0, },});Reuse Instances
Create tool instances once, not on every render.
const [tools] = useState({ point: new PointTool(), rectangle: new RectangleTool(),});Visual Feedback
Show which tool is active with UI highlighting.
Allow Deactivation
Always provide a way to disable tools (e.g., “Pan” mode).
Keyboard Shortcuts
Add keyboard shortcuts for common tools (P, R, G, V).