Grid morphology
Paint binary or grayscale grids, apply morphology and compare with the previous state.
About this tool
The grid stores brightness from 0 (black) to 255 (white). Binary mode contains only 0/255. Switching from grayscale to binary converts values at least 128 to 255 and the rest to zero; switching back preserves the values. Mode changes can be undone. The example creates a filled block and a separate bright corner pixel.
Choose an operation and Apply. The centered 3×3 square or cross includes its center. Erosion takes the minimum, dilation the maximum; outside neighbours are ignored (equivalent to outside 255 for erosion and 0 for dilation). Opening is erosion then dilation, closing the reverse. Gradient is dilation minus erosion, white top-hat is input minus opening, black top-hat is closing minus input; inversion is 255 minus input. See the OpenCV morphology tutorial. The saved action label names the footprint actually used.
Binary thinning uses the Guo–Hall neighbourhood rules from scikit-image 0.25.2: Guo–Hall thin, with simultaneous deletions in each of two directional passes and zero outside the grid, including at border cells. Pass pairs repeat until nothing is deleted. The iteration count includes only pairs that delete cells. This is thinning, not a guarantee of an exact medial axis or universal one-cell width; the square/cross setting does not affect thinning or inversion.
Paint is initially active. On touch devices, Paint and Erase use dragging to draw; choose View to scroll across the canvas. One completed stroke is one Undo action; an interrupted stroke is discarded. Focus the current canvas to move the cell cursor with arrows, paint with Space or erase with Delete. Shift or the right mouse button also erases. Undo restores the last effective grid change, including dimensions and value mode. An unchanged operation keeps that Undo step. The previous view always relates to the last effective change.
Resize accepts whole dimensions from 4 to 200 and clears the grid explicitly. Pending size drafts do not resize the working grid. The gray brush accepts whole values 0–255. Image import accepts PNG, JPEG, WebP and GIF files up to 10 MiB. The 16-million-pixel limit is checked after browser decoding and cannot prevent all decoder allocations. Stretch fills the grid with nearest-neighbour sampling; original-pixel mode crops from the top left and pads with black. Transparency is composited over black. Gray is round((299R + 587G + 114B)/1000) from displayed RGB intensities, not physical luminance; binary then applies the threshold 128. Failed or superseded imports preserve the current grid.
Small grids and input drafts use the existing cookie storage. States that cannot be encoded or exceed 1,500 encoded characters remain available only until reload, with a visible notice. The previous view and Undo history are kept only while this page session remains open.