ComfyUI Node Runs on cloud

Remap

The sink node every Remap distorts into — without it, the family is just math

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
Remap
  • remap
  • src
  • src_mask
  • IMAGE
  • MASK
interpolationINTER_AREA
output_with_alphafalse

Here's the thing that trips everyone up on this pack's distortion nodes: none of them actually distort an image. RemapPinch, RemapBarrelDistortion, RemapToInnerCylinder - they all output a thing called REMAP, which is just a recipe: a pair of coordinate maps describing where every output pixel should sample from in the source. The node that actually applies that recipe to your image is this one, the Remap node. Think of the generator nodes as handing you a lens, and Remap as the camera that uses it.

This is a pack-internal type, so the wiring is mandatory and fixed: take any RemapXxx node's REMAP output, connect it here, connect your source image, done. There's no way to apply a remap without this node, and nothing else in ComfyUI understands the REMAP type - which is why every workflow with these distortions includes this exact node in the middle.

How it works

Under the hood it calls OpenCV's cv.remap with the coordinate maps from the generator. The generator computes where each destination pixel should look in the source (the xs/ys maps), and cv.remap resamples accordingly. The interpolation input picks the resampling quality - INTER_AREA (the default) is the safe choice for shrink-style distortions; INTER_LANCZOS4 and INTER_CUBIC give sharper results on enlarging ones but cost more. The node also handles the "bounding box" bookkeeping some distortions need, so the result always comes back at a sane size.

The inputs

  • remap (REMAP) - the recipe from a generator node.
  • src (IMAGE) - what gets distorted.
  • interpolation - INTER_NEAREST, INTER_LINEAR, INTER_AREA (default), INTER_LANCZOS4, INTER_CUBIC.
  • src_mask (MASK, optional) - if you pass one, you get back a correspondingly distorted mask, which is how you keep masks aligned with the distorted image.
  • output_with_alpha (BOOLEAN) - on, the output becomes RGBA with the remapped mask as the alpha channel.

It outputs IMAGE and MASK - the mask is always produced (a blank full-white one if you didn't supply src_mask), and it's the second output you'll usually ignore.

Where it fits

This is the workhorse that turns the family's gimmicks into usable effects: pinch a face toward its center, correct barrel distortion from a fisheye photo, or wrap a flat texture around a cylinder. The included workflow images in the pack's repo (workflows/remap_barrel_distorcion.png, remap_simple_distortions.png) show the intended graph shape - it's always generator → Remap → preview.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes

restart, or grab comfyui_bmad_nodes from ComfyUI Manager. The pack's OpenCV requirement covers it. No models to download.

The one habit worth building: if you change the generator's parameters, only the generator re-runs - the Remap node re-applies with whatever REMAP it last received, so make sure the wire's actually connected when you tweak. That, and don't expect real-time previews on large images; each re-application is a full resample.

CategoryBmad/CV/Transform

Inputs (5)

NameTypeDefaultDescription
remapREMAP
srcIMAGE
interpolationCOMBOINTER_AREA5 options: INTER_NEAREST, INTER_LINEAR, INTER_AREA, INTER_LANCZOS4, INTER_CUBIC
src_maskoptMASK
output_with_alphaoptBOOLEANfalse

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK