ComfyUI > Nodes > ComfyUI-IC-Light > Background Scaler

ComfyUI Node: Background Scaler

Class Name

BackgroundScaler

Category
IC-Light
Author
kijai (Account age: 2181days)
Extension
ComfyUI-IC-Light
Latest Updated
2024-06-19
Github Stars
0.39K

How to Install ComfyUI-IC-Light

Install this extension via the ComfyUI Manager by searching for ComfyUI-IC-Light
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-IC-Light in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Background Scaler Description

Adjust grayscale intensity of masked image areas for artistic effects with scale factor and mask inversion.

Background Scaler:

The BackgroundScaler node is designed to adjust the color of specific areas within an image based on a provided mask. This node is particularly useful for AI artists who want to manipulate the grayscale range of masked regions in their images. By applying a scale factor to the masked areas, you can achieve various artistic effects, such as highlighting or dimming certain parts of the image. The node also offers an option to invert the mask, providing additional flexibility in how the scaling is applied. Overall, the BackgroundScaler node is a powerful tool for fine-tuning the visual elements of your artwork, allowing for precise control over the grayscale intensity of selected regions.

Background Scaler Input Parameters:

image

This parameter expects an image in the form of a 4D tensor. The image serves as the base on which the scaling effect will be applied. The image must be a 4D tensor to ensure compatibility with the node's processing requirements.

mask

The mask parameter is a tensor that defines the areas of the image to be affected by the scaling. It can be either a 3D or 4D tensor. If a 3D tensor is provided, it will be automatically adjusted to a 4D tensor by adding an extra dimension. The mask essentially acts as a stencil, determining which parts of the image will undergo the grayscale adjustment.

scale

This is a floating-point value that determines the intensity of the grayscale adjustment applied to the masked areas. The scale parameter has a default value of 0.5, with a minimum value of -10.0 and a maximum value of 10.0. Adjusting this value will either lighten or darken the masked regions, depending on the scale factor used.

invert

The invert parameter is a boolean that, when set to True, inverts the mask. This means that the areas not covered by the mask will be affected by the scaling, while the masked areas will remain unchanged. The default value for this parameter is False.

Background Scaler Output Parameters:

image

The output is an image tensor with the same dimensions as the input image. This tensor represents the original image with the grayscale adjustments applied to the specified masked areas. The output image will have its pixel values clamped between 0 and 1 to ensure valid image data.

Background Scaler Usage Tips:

  • To highlight specific areas of your image, use a mask that covers those regions and set a positive scale value.
  • For a dimming effect, apply a negative scale value to the masked areas.
  • Experiment with the invert parameter to see how inverting the mask changes the visual outcome.
  • Use subtle scale values for more natural-looking adjustments, and higher values for more dramatic effects.

Background Scaler Common Errors and Solutions:

ValueError: image and mask must be torch.Tensor types.

  • Explanation: This error occurs when the input image or mask is not provided as a torch.Tensor.
  • Solution: Ensure that both the image and mask inputs are torch.Tensor types before passing them to the node.

ValueError: image must be a 4D tensor, and mask must be a 3D or 4D tensor.

  • Explanation: This error indicates that the dimensions of the image or mask do not meet the required specifications.
  • Solution: Verify that the image is a 4D tensor and the mask is either a 3D or 4D tensor. Adjust the dimensions if necessary.

RuntimeError: The size of tensor a (X) must match the size of tensor b (Y) at non-singleton dimension Z

  • Explanation: This error occurs when the dimensions of the image and mask tensors do not match.
  • Solution: Ensure that the mask tensor has the same height and width as the image tensor. If the mask is 3D, it will be automatically adjusted to 4D, but the spatial dimensions must still match.

Background Scaler Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-IC-Light
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.