POV-Ray : Newsgroups : povray.binaries.images : Sci-Fi Scene Assets : Re: Sci-Fi Scene Assets Server Time
1 May 2024 16:48:25 EDT (-0400)
  Re: Sci-Fi Scene Assets  
From: Robert McGregor
Date: 20 Feb 2021 09:15:08
Message: <web.60311917a906d8e387570eab0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> That's a wonderful scene, very mysterious and evocative. And thanks for sharing
> the details of your techniques, plus the image of the various assets you used.

Thanks Kenneth, I appreciate that.

> That idea gave me some thoughts about my recent post regarding AA problems with
> very bright objects, where AA fails for those bright pixels (Thanks!) So I put
> together something similar(?) to your idea: Rendering a scene the normal way,
> then bringing the image back into POV-ray and doing an
> image-to-function-to-pigments conversion on it (all 3 color channels). Then
> re-combining (using 'average') those 3 pigment functions-- with simple but
> proper r-g-b color_maps-- to re-create the image as before. At this point, I
> discovered that I could change the color_maps' index values to effectively
> mask-off (as black) any pixels over a certain 0-1 brightness threshold... like
> your idea. Great, so far!

Yes, this sounds very much like what I did (which was orginally inspired by
reading your bright pixels AA problems post and pondering ways to fix that!)

> This is the 2nd part of my task. I looked up 'gaussian blur', and I see that it
> involves matrix use in some way. I'm still a rank beginner when it comes to
> manipulating matrices, but aside from that small problem (ha), I can't even get
> a *basic* experiment with a matrix to work in v3.8xx for Windows

Okay, I didn't use a matrix in that sense, i.e., the matrix keyword as used for
transformations. I just built my own Gaussian smoothing matrix using a 2d array,
like this (note the symmetry):

#declare ConvolutionKernel = array[5][5] {   // Smoothing matrix
   {1,  4,  7,  4, 1},
   {4, 16, 26, 16, 4},
   {7, 26, 41, 26, 7},
   {4, 16, 26, 16, 4},
   {1,  4,  7,  4, 1}
}

This small kernel (matrix) represents pixel weights, and the central element
(with the highest value) is the calculation target, an average of all the
surrounding pixel colors. In a nutshell it works like this:

Place the center weight of the kernel (41 in this case) on an image pixel. The
colors of all pixels under the matrix (from the original image, as sampled from
the function pigment) are multiplied by the overlapping kernel pixel weights,
and the results of all pixels are all added together into a final summed color.

Each kernel weight that is multiplied against a pixel color is added to an
overall matrix sum (at image borders not all weights will have pixels under
them). An average color for the central pixel is then calculated as: summed
color divided by the matrix sum.

Move the center of the kernel to the next pixel and iterate the process until
all pixels have been assigned averaged colors. At that point the averaging has
blurred the image, in this case the 5x5 matrix gives a 3-pixel blur (see
attached sample image, left is a magnified 60x60 test image and right is the
blurred convolution result).

Doing it this way is a *slow* process, especially in SDL, because for a
1920x1080 pixel image the are 2 million+ pixels, and each needs to be averaged
with (for the most part, except edges) 24 neighboring pixels, for an estimated
48 million samples and calculations.


Post a reply to this message


Attachments:
Download 'convolveexample.png' (1219 KB)

Preview of image 'convolveexample.png'
convolveexample.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.