KJNodes/imagegenerated

Gradient To Float(GradientToFloat)

This node receives an image in a four-dimensional tensor format (shape: [batch, height, width, channels]) and performs uniform sampling along the width and height dimensions of the image.

Gradient To Float

image
float_x
float_y
steps
10
KJNodes

The Gradient To Float node receives an image in a four-dimensional tensor format (shape: [batch, height, width, channels]) and performs uniform sampling along the image's width and height directions.

The Gradient To Float node is an image analysis tool whose core function is to extract numerical data from an input image. It samples image pixels to convert image information into a list of floating-point numbers, facilitating subsequent numerical processing or analysis.

Node Function

This node receives an image in a four-dimensional tensor format (shape: [batch, height, width, channels]) and performs uniform sampling along the image's width and height directions. Its internal mechanism involves selecting pixel points at equal intervals along the two main axes of the image based on the user-specified number of sampling steps. It then calculates the average value of these sampled points in the corresponding row or column, ultimately generating two independent lists of floating-point numbers.

Node Parameter Description - Gradient To Float

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
imageIMAGEYes--image (Input Parameter): The source image input for analysis. The node will calculate the list of floating-point numbers based on this image.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
stepsINTYes102 - 10000 (Step: 1)steps (Input Parameter): Sets the number of sampling points along the image's width and height directions. The valid range is 2 to 10000, with a step size of 1.

Output

Parameter NameData TypeDescription
float_xFLOATfloat_x (Output Parameter): The list of floating-point numbers obtained from sampling and calculation along the image's width direction.
float_yFLOATfloat_y (Output Parameter): The list of floating-point numbers obtained from sampling and calculation along the image's height direction.

Usage Scenarios

In practical applications, this node is commonly used in workflows that require converting visual information into controllable numerical sequences. For example, when creating dynamic effects or parametric animations, a gradient image can be fed into this node. The output list of floating-point numbers can then be used to drive parameters of other nodes (such as controlling particle positions, color changes, or shape deformations), thereby creating complex effects linked to the image content.

Notes

Please note that this node, by default, only processes the first image in the input batch and the first color channel (typically the red channel or grayscale value). If a color image is input, it does not automatically perform color space conversion but directly uses the data from the first channel.

The Gradient To Float node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…