Nodes/Eden.art nodesuite/Eden_Image_Math
ComfyUI Node Runs on cloud

Eden_Image_Math

A calculator that does math on pixels — expression in, image and mask out

By edenartlab·Created 3 years ago·Updated 6 months ago· 119
Eden_Image_Math
  • a
  • b
  • c
  • IMAGE
  • MASK
expression
conversion_modemean

Eden_Image_Math is a calculator for pixels. You type a math expression, optionally feed it up to three image or mask tensors, and it evaluates the expression element-wise across every pixel. sin(a*pi) * b + c isn't a hypothetical - that's the example in the node's own description, and it works. This is the node that turns "I wish I could just multiply this mask by 0.5" into a text box instead of a search for the right utility.

How it works

The expression is a safe-eval string using variables a, b, and c, each accepting an image or mask tensor. There's an allow-list regex for the expression (letters, digits, + - * / ( ) , . ^) so you can't sneak arbitrary Python in - a gotcha to remember when you reach for ** for exponentiation; it's not in the allowed set, though ^ is. Masks are auto-broadcast to match image dimensions, so you can mix a mask with an image in one expression without manual resizing.

Because images are 3-channel and masks are 1-channel, the node needs a bridge: conversion_mode (default mean) decides how an RGB result collapses to a mask - average the channels, or take just the r, g, or b channel. You get both IMAGE and MASK outputs from a single run, which is handy: compute once, wire the image to one consumer and the mask to another.

Inputs

  • expression (STRING) - the math to apply. This is the whole node.
  • conversion_mode - mean, r, g, or b; how IMAGE → MASK conversion works.
  • a / b / c - optional tensors; the variables in your expression.

Outputs: IMAGE and MASK.

What it's good for

Mask math is the sweet spot. Multiply a mask by a scalar to weaken it, invert with 1 - a, combine two masks with a * 0.5 + b * 0.5, or do soft-edge work with sin-based feathering. It's the flexible middle layer between "use a fixed mask-op node" and "write a custom node." The a*pi trig use case also makes it a sneaky-good procedural texture tool - evaluate a sine wave over a coordinate image and you've got patterns, not just corrections.

Installing it

Ships in the Eden.art nodesuite (edenartlab/eden_comfy_pipelines). Install via ComfyUI Manager (search "Eden.art nodesuite") or:

cd ComfyUI/custom_nodes
git clone https://github.com/edenartlab/eden_comfy_pipelines
cd eden_comfy_pipelines && pip install -r requirements.txt

Restart after installing.

Common issues

Empty expression does nothing useful - you need to actually type the formula. If nothing happens, check you used a, b, c (lowercase) and that unsupported operators like ** aren't in your expression. Division by zero is a classic footgun: a / b with a mask containing zeros produces inf/nan pixels that then propagate. Clamp or add a tiny epsilon (a / (b + 1e-6)) if you're dividing masks.

CategoryEden 🌱/image

Inputs (5)

NameTypeDefaultDescription
expressionSTRING
conversion_modeCOMBOmean4 options: mean, r, g, b
aopt*
bopt*
copt*

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK