rewrite random noise knowing how bayer works
This commit is contained in:
parent
4c0678cf77
commit
94d1e465c9
@ -48,15 +48,12 @@ func naivePalette(p color.Palette) quantizerFunction {
|
||||
|
||||
// randomNoisePalette injects random noise into the quantization step
|
||||
func randomNoisePalette(p color.Palette) quantizerFunction {
|
||||
r := len(p)
|
||||
return func(_, _ int, c color.Color) color.Color {
|
||||
// the randomization here is tuned for the sixteen-color palette for now.
|
||||
// I think the proper theory here is probably "only try and randomize within one palette swatch in either direction".
|
||||
// it might be possible to instead permute the color selected _from the palette_ (i.e. modify the result of p.Index(c))...
|
||||
// ...but I think for that to work you'd need a proper "ordering" for the colors.
|
||||
noise := rand.Intn(64) - 32
|
||||
if noise < 0 {
|
||||
noise = 0
|
||||
}
|
||||
noise := rand.Intn(256) / r
|
||||
rc := permuteColor(c, uint8(noise))
|
||||
return p[p.Index(rc)]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user