ComfyUI > Nodes > ComfyUI > ImageQuantize

ComfyUI Node: ImageQuantize

Class Name

ImageQuantize

Category
image/postprocessing
Author
ComfyAnonymous (Account age: 598days)
Extension
ComfyUI
Latest Updated
2024-08-12
Github Stars
45.85K

How to Install ComfyUI

Install this extension via the ComfyUI Manager by searching for ComfyUI
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI 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

ImageQuantize Description

Reduce image colors for compression, artistic effects, and limited palettes, with dithering support for visual fidelity.

ImageQuantize:

The ImageQuantize node is designed to reduce the number of colors in an image, a process known as color quantization. This technique is particularly useful for compressing images, creating artistic effects, or preparing images for specific display requirements where a limited color palette is needed. By converting an image to use a specified number of colors, the node helps in reducing file sizes and can also enhance the visual style of the image by giving it a more posterized look. The node supports different dithering methods to manage the distribution of quantization errors, ensuring that the resulting image maintains visual fidelity and smooth gradients.

ImageQuantize Input Parameters:

image

This parameter expects an image tensor that you want to quantize. The image should be in the form of a tensor with dimensions corresponding to batch size, height, width, and color channels.

colors

This parameter specifies the number of colors to which the image will be reduced. The value should be an integer, with a minimum of 1 and a maximum depending on the specific use case. The default value is typically set to a reasonable number that balances image quality and file size.

dither

This parameter determines the dithering method used during quantization. Dithering helps to distribute quantization errors across the image, which can improve the visual quality of the quantized image. The available options are "none" for no dithering, "floyd-steinberg" for Floyd-Steinberg dithering, and "bayer-x" where x is the order of the Bayer matrix (e.g., "bayer-2", "bayer-4"). The choice of dithering method can significantly affect the appearance of the final image.

ImageQuantize Output Parameters:

result

The output is a tensor representing the quantized image. This tensor has the same dimensions as the input image tensor but with the colors reduced according to the specified parameters. The result maintains the batch size, height, width, and color channels of the original image, ensuring compatibility with subsequent processing steps.

ImageQuantize Usage Tips:

  • To achieve a retro or artistic effect, experiment with lower values for the colors parameter and different dithering methods.
  • For images that need to be displayed on devices with limited color capabilities, use the colors parameter to match the device's color palette.
  • When reducing colors for file size optimization, start with a higher number of colors and gradually reduce until you find a balance between image quality and file size.

ImageQuantize Common Errors and Solutions:

Invalid dither method

  • Explanation: The specified dithering method is not recognized.
  • Solution: Ensure that the dither parameter is set to one of the following: "none", "floyd-steinberg", or "bayer-x" where x is a valid order number.

Colors parameter out of range

  • Explanation: The colors parameter is set to a value that is either too low or too high.
  • Solution: Set the colors parameter to a reasonable integer value, typically between 1 and 256, depending on your specific needs.

Image tensor dimensions mismatch

  • Explanation: The input image tensor does not have the expected dimensions.
  • Solution: Ensure that the input image tensor has dimensions corresponding to batch size, height, width, and color channels. The typical format is (batch_size, height, width, channels).

ImageQuantize Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI
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.