Nodes/opencv-comfyui/OpenCV CV_16UC_0
ComfyUI Node

OpenCV CV_16UC_0

CV_16UC_0 — the unsigned 16-bit type constant, in one node

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV CV_16UC_0
    • int
    channels

    CV_16UC_0 is a calculator for one specific OpenCV type constant: cv2.CV_16UC(channels), the code for an unsigned 16-bit integer array with N channels. Give it a channels INT, get an int back. That's the node, in full. It exists because opencv-comfyui auto-generates a node for every top-level cv2 function, and the CV_* type macros count as functions.

    The encoding is the standard one: type = depth + (channels - 1) × 8, where CV_16U is depth 2. So CV_16UC(1) = 2, CV_16UC(2) = 10, CV_16UC(3) = 18, CV_16UC(4) = 26.

    Where unsigned 16-bit actually shows up

    uint16 is the natural home for image data that needs more range than uint8's 0–255 but has no business being negative - think 16-bit depth maps, radiometric/sensor data, or intermediate values you plan to scale down later. In OpenCV-land you'll meet CV_16U when a function or a dstType parameter wants an explicit output type. In a ComfyUI graph, that translates to: some node in this pack takes a type constant, you need the uint16 one, and you don't want to trust your memory of the table.

    Honest framing: this is plumbing, not a feature. You will not build a workflow around CV_16UC_0; you'll reach for it the once every few months when a type code is needed and it happens to be this one. That's fine - the pack's whole pitch is breadth, and constant-generator nodes are the cost of that breadth. Most of the time the depth you actually want in a ComfyUI float pipeline is CV_32F (see CV_32FC_0); uint16 is the specialist corner.

    The spec

    • channels - INT. 1–4 is the useful range (CV_16UC1=2, CV_16UC2=10, CV_16UC3=18, CV_16UC4=26).
    • Output: int - the type constant.

    Install

    Part of opencv-comfyui (geroldmeisinger). ComfyUI Manager → search opencv-comfyui → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/geroldmeisinger/opencv-comfyui
    

    Restart. Requirements: opencv-contrib-python, numpy, torch. No models.

    Anything to watch?

    The usual sibling mix-up: CV_16UC (unsigned, depth 2), CV_16SC (signed, depth 3), CV_16FC (float, depth 7). They're one digit apart in intent and the numbers don't overlap, so check which one a downstream node actually wants. Signedness is the detail that bites: if your data can go negative, CV_16U wraps and corrupts it. Otherwise this is a trivial, trustworthy node - the rare case where "it's just a calculator" is the entire review.

    Categoryimage/OpenCV

    Inputs (1)

    NameTypeDefaultDescription
    channelsINT

    Outputs (1)

    NameTypeDescription
    intINT