Skip to main content
View source

Cleanup

View as Markdown

A RocketRide image filter node that prepares incoming images for OCR by normalizing their format, enhancing contrast, correcting skew, and closing small gaps in characters. Use it before OCR when scans are noisy, low quality, or tilted, rather than where downstream processing needs to retain the original image bytes or color.

About OpenCV

OpenCV supplies the image operations used by this node. Here it decodes the normalized PNG, converts it to grayscale, applies blur, contrast enhancement, rotation, and morphological closing, then encodes the result as PNG.

What it does

Receives a streamed image on the image lane, buffers it until the stream ends, then emits a cleaned replacement on the same lane. It is a pipeline-only filter: there are no agent-callable functions or configuration fields. Pick it for an OCR path that benefits from a grayscale, contrast-enhanced and deskewed image; place another image node in the path when preserving color or the input representation matters.

Lanes

Lane inLane outDescription
imageimageReceives an image stream and emits its cleaned PNG replacement.

Configuration

This node has no configuration fields. Add it between the image source and the OCR consumer; it applies the same cleanup sequence to every complete image stream.

Notes

Processing and output

Inputs whose MIME type is not image/png are opened with Pillow, converted to RGBA, and saved as PNG. The cleanup stages then decode the PNG with OpenCV, convert it to grayscale, apply a 5×5 Gaussian blur and CLAHE contrast enhancement (clip limit 2.0; 8×8 tile grid), deskew it, and apply morphological closing with a 2×2 kernel. The output is therefore a grayscale image/png.

Deskewing inverts the grayscale image, finds its non-zero pixels, and uses their minimum-area rectangle to choose a rotation angle. If no such pixels are found, the angle remains zero. Rotation uses cubic interpolation and replicated image borders, so edge pixels are extended rather than filled with a constant border.

Streaming and failures

The node stores every WRITE chunk in memory and performs processing only on END; it suppresses the original stream instead of forwarding it alongside the replacement. It parses the source descriptor received at BEGIN and supplies it when forwarding the cleaned image.

There is no local fallback to the original input. A non-PNG image that Pillow cannot convert raises ValueError; the cleanup stages also raise when OpenCV cannot decode or encode their PNG data. Use valid, complete image streams and account for the full image being buffered before selecting this node for very large inputs.

Upstream docs


Schema

No configuration fields.

Dependencies

  • pillow