Jump to content

Plugin request: 'posterize' effect with color resampling


Recommended Posts

paint1.jpg

unedited

paint3.jpg

posterized (orange skin is bad.)

paint4.jpg

posterized + recolored

This plugin would take the posterize effect (the source is out for that now that it's incorporated into pdn right?) and add a feature (a check box would probably sufice) that takes the 'color groups' (is it obvious that I don't know a thing about programming in c#?) made by posterize and recolors them based on the colors in the same pixel space on the source canvas (just averaging the sum of the r's g's b's and a's of the pixels in that area would do it right? is that too slow? All the pixels should have similar values if they were posterized to the same color, you could probably just take a few).

This effect would baisically be the same as the color simplify effect except that it would actually work (no offence Ed, I love you plugins.)

A person can do this themselves by posterizing a duplicate layer and then recoloring with eyedropper picked values, but why not automate that hour consuming process?

I've wanted software that could do this for so long it's sad, and based on my observations (the existence of the simplify tool, that topic on vector styling an image, the numerous posts about comic books from people who aren't thrilled with ink sketch) some others would too.

Thanks~ Ethan

sig.png
Link to comment
Share on other sites

Apologies. The spammer has been banned.

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

  • 2 weeks later...

No one responded so I'm going to assume no one is interested in doing this. When I considered the problem further I realized that while the product was attainable the means I had descibed were not practical. I decided to try my own hand at making the plugin though I've never programmed in c# and have only the most primitive notions of general programming structures.

I figured out that I can simulate posterize by diving the source canvas values by a given integer, then multiplying by the same integer. Because the data type is 'int' this effectively devides, truncates, and multiplies, which could also be seen as rounding down the value to a multiple of the operating value. My initial problem was that the poserize effect oft distorts the colors in a manner that doesn't hold true to human expectations of appearance. I initially proposed a 'recolor' process but I see now that process can not be feasibly simulated. My second recourse was to average the my 'posterized-ish' values with the original ones. This produced fairly good results when the operating number of the 'posterize-ish' effect was between 50 and 180. Here's a little snippet of the codelab.dll code.

            r=(((CurrentPixel.R/Amount1)*Amount1)+CurrentPixel.R)/2;
           g=(((CurrentPixel.G/Amount1)*Amount1)+CurrentPixel.G)/2;
           b=(((CurrentPixel.B/Amount1)*Amount1)+CurrentPixel.B)/2;

           CurrentPixel.R = (byte)(int)r;
           CurrentPixel.G = (byte)(int)g;
           CurrentPixel.B = (byte)(int)b;
           dst[x,y] = CurrentPixel;

Can anyone suggest a better method to make posterize or my poor man's posterize do strong seperation of colors but not strong simplification? Also, I've heard something about the perils of unsafe integer arithmetic. Does my fake 'posterize' effect constitute such?

Much obliged~ Ethan

sig.png
Link to comment
Share on other sites

Do you have any examples of what you're looking for?

When you say "color sampling", I keep thinking you mean quantization, such as how a 24-bit RGB image is squashed into an 8-bit image with an optimized palette. But I can't tell for sure.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Wow, I looked up color quantization and got to an article on cluster analysis. I have so much more respect for you after trying to read through that. I never really realized what mad skills you must have.

I didn't say 'color sampling' I said 'resampling', by which I meant picking values from the source just as the eye dropper tool might. From what I can tell, quantization is what the posterize effect does, reducing the color depth but still representing those colors at 24 bit depth. A side effect of the qauntization is that similar colors are sometimes reduced to a single color. I guess what I was asking for is a way to get that side effect of reducing colors in close prroximity to a single color, but in a way that maintains the bit depth.

I imagine the median noise effect does something very near to that exept by weighting the new pixels color with the ones in close phisical proximity to it on the source instead of close physical AND hue proximity as I'm suggesting. Because of this the median effect creates large amounts of distortion in form. I'd like to represent an image in fewer colors but still at a high color depth.

In my first post I gave an example of how quantizing can create values that don't seem natural or similar to the source because of their lower bit depth and fixed it by "resampling" i.e recoloring with colors sampled from the source (which maintain the original bit depth).

So I guess I'm going to try making a median noise effect that uses similar neighboring hues as parameters.

Did I get through that all right?

Thanks a load Rick, I think I'm on the right track now.

sig.png
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...