Nodes/opencv-comfyui/OpenCV LUT_0
ComfyUI Node

OpenCV LUT_0

Apply a lookup table for instant color grading and stylization

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV LUT_0
  • src
  • lut
  • dst
  • nparray

Here's the node that lets you remap an image through an arbitrary curve in one step. OpenCV LUT_0 wraps cv2.LUT - lookup table - which is the classic way to do color grading, film emulation, contrast curves, and stylized tone mapping without touching any machine-learning anything. Photoshop's "curves," LUT files, and Instagram-style filters are all this operation under the hood.

It works like this: a lookup table is just a mapping from "old pixel value" to "new pixel value." For an 8-bit image that's a 256-entry list. The node walks the image and replaces every pixel value with whatever the table says - value 0 becomes lut[0], value 255 becomes lut[255]. Do that on a single channel and you have a tone curve; do it across color channels and you have a full grade.

The inputs

  • src - the NPARRAY to transform (Image2Nparray in, Nparrays2Image out).
  • lut - the table, also an NPARRAY. This is the fiddly part, and it's the honest reason this node is awkward in practice: nothing in the pack gives you a nice curve editor. The table is a 256×1 uint8 array, which you'd have to build from a Python/numpy source or a custom node that emits nparrays. If you already have an array-producing tool in your graph, great. If not, expect friction.
  • dst - optional out-parameter; ignore it.

The single output is the graded nparray.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Restart, or ComfyUI Manager → search "opencv". Requirements: opencv-contrib-python, numpy, torch. No models to fetch.

Common issues

  • "How do I even build the lut?" - you need a node that emits a 256-element NPARRAY. The pack itself doesn't ship a convenient builder; this is the pack's known UX gap (the README lists widget support for composite types as a todo). Realistically, you'll reach for this node if you already have an array source, or if you're comfortable with a small custom node.
  • Wrong channel count - the LUT can apply to grayscale (1-channel) or color images; if the table's shape doesn't line up with the image, the result degrades. Keep the table 256×1.
  • Batch error - batch_size==1 only; ImageFromBatch, length=1.
  • Lookup table only affects 8-bit range - that's fine for normal ComfyUI images (which are uint8 after Image2Nparray), but don't feed it a float buffer and expect the table to apply to arbitrary float values.

The _1 variant is the same node (the pack numbers OpenCV's MatLike/UMat overloads rather than merging them). Honest verdict: LUT grading is genuinely powerful and this node implements it faithfully - the only thing standing between you and film looks is building the table.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
lutNPARRAY
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY