Jump to content
How to Install Plugins ×

Recolor Using Palette


MJW

Recommended Posts

This plugin is admittedly quite similar to TR's Custom Palette Matcher, but may be useful. It's in the Color menu.

 

The Plugin: Recolor Using Palette.zip

 

As the Help menu says:

 

Recolor Using Palette replaces each pixel color with the nearest color from a specified range of the current palette. The Euclidean distance is used. This minimizes the sum of the squared differences of the red, green, and blue color components.


The controls are:
Starting Palette Index: The number of the first palette color to use. Palette colors are numbered from 1 to 96.

Ending Palette Index: The number of the last palette color to use.

Ignore Opacity When Comparing Colors: When this option is enabled, only the red, green, and blue color components are compared; the alpha value is ignored. The original alpha is preserved in the replaced color. When this option is disabled, the image and palette colors are adjusted to account for their alpha values before being compared. The distance between colors is the distance between the colors when blended with the background color that maximizes the distance. The original alpha is replaced by the alpha of the nearest palette color.

Show Original Image: When enabled, the original, unmodified image is displayed.

 

The UI:

Recolor-Using-Palette-UI.png

 

 

Instead of managing palettes like TR's effect, it relies on PDN's built-in palette handling, which I think is fairly easy to use.  Recolor Using Palette allows a subrange of the current palette to be used. (Note the color-entry numbering is one-based, not zero-based.)

 

One interesting (which is not necessarily the same as useful) feature is that it can take opacity into account when doing the comparison. When opacity is used in the comparison, the entire palette color, including alpha, replaces the image color; otherwise, the image alpha is preserved, and only the red, green, and blue are replaced.

 

Here's a demonstration, using the default palette.

 

Original image:

Recolor-Using-Palette-Tests-Img.png

 

 

With Ignore Opacity When Comparing Colors enabled:

Recolor-Using-Palette-Tests-Img-No-Opaci

 

 

 

With Ignore Opacity When Comparing Colors disabled:

Recolor-Using-Palette-Tests-Img-With-Opa

 

(To be useful in this mode, the palette would likely need to be better suited to the image than it is in this case.)

 

Ignore Opacity When Comparing Colors is disabled by default.

  • Upvote 6
Link to comment
Share on other sites

Link to comment
Share on other sites

  • 3 years later...

Sorry to dig up this post 4 year later.

I know this plugin uses the euclidean distance between two pairs of RGB component.

Though I've recently read about a better-tuned algorithm for approximating color here:

https://www.compuphase.com/cmetric.htm

Was wondering if you are interested in implementing it in your plugin.

 

Also, thanks for the plugin! It's now essential for me working on pixelarts. ❤️

Link to comment
Share on other sites

4 hours ago, David Feng said:

Was wondering if you are interested in implementing it in your plugin.

 

I'll give it some consideration. I know straight Euclidean distance isn't a particularly good method for color comparison.  I'd probably have to disable taking opacity into account when using the more complex color metric. I doubt the method I use can be extended to it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...