Jump to content

Fixes to "Add noise"


Recommended Posts

The "Add noise" effect is pretty "jumpy" for low amounts of noise, i.e. moving from 11 to 12 has a huge effect. It could be easily fixed by changing

            int dev = this.intensity * this.intensity / 64;
           ...
                           dstPtr->R = Utility.ClampToByte(srcPtr->R + ((r * dev * 16 + 32768) >> 16));
                           dstPtr->G = Utility.ClampToByte(srcPtr->G + ((g * dev * 16 + 32768) >> 16));
                           dstPtr->B = Utility.ClampToByte(srcPtr->B + ((b * dev * 16 + 32768) >> 16));

into

            int dev = this.intensity * this.intensity / 4;
           ...
                           dstPtr->R = Utility.ClampToByte(srcPtr->R + ((r * dev + 32768) >> 16));
                           dstPtr->G = Utility.ClampToByte(srcPtr->G + ((g * dev + 32768) >> 16));
                           dstPtr->B = Utility.ClampToByte(srcPtr->B + ((b * dev + 32768) >> 16));

Additionally I think the line

                            i = (1867 * r + 9618 * g + 4899 *  >> 14;

was probably meant to be

                            i = (4899 * r + 9618 * g + 1867 *  >> 14;

Cheers :D

Link to comment
Share on other sites

This function is "add noise", not remove :) Basically, the first and most important fix is there to give better control on the amount of noise you add, while the second one is there to fix a minor bug in the coloration of the noise.

(and yes, there is a very tiny performance improvement, but that's not really the point)

Link to comment
Share on other sites

This function is "add noise", not remove :) Basically, the first and most important fix is there to give better control on the amount of noise you add, while the second one is there to fix a minor bug in the coloration of the noise.

(and yes, there is a very tiny performance improvement, but that's not really the point)

Sorry my bad. :oops: my mind read 'remove' instead of 'add'...

Anyways why don't you make a plugin out of it? something Add Noise+ and add a few more features, like the color range of the noise or something...

Link to comment
Share on other sites

It's just bugfixes, it doesn't belong in an extra plugin... I mean I'm just proposing a patch, take it or leave it, though I hardly see any reason for refusing it apart from backward compatibility -- and I don't think it's a concern for Paint.net. Or maybe this is not the right place to submit patches??

Link to comment
Share on other sites

It's just bugfixes, it doesn't belong in an extra plugin... I mean I'm just proposing a patch, take it or leave it, though I hardly see any reason for refusing it apart from backward compatibility -- and I don't think it's a concern for Paint.net. Or maybe this is not the right place to submit patches??

No... What I mean is that if Rick wanted to include your upgrade to add noise, I dunno but I think he'd probably already answered, BUT the changes you made (I've been comparing the code, I know coding, just not much of C#) and it seems to be a nice thing to release as your own plugin, just add a few things not to be only some upgraded effect...

Just a though anyways...

Link to comment
Share on other sites

  • 4 weeks later...

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.

 Share

×
×
  • Create New...