I am attempting to write a script that loops through each pixel in a photograph and applies a bokeh to the image as a whole.
I built a script based off this link, however that seems to be a hack.
I have three input images: a black and white depth map, a photograph, and a bokeh “brush” image (which is currently a hexagon). For every pixel of the photograph, I stamp the bokeh brush so it is centered on that pixel and in the color of that pixel.
It looks… okay on tiny bokeh brushes, but once I increase the bokeh brush size at all it ends up looking like gaussian blur. Here’s a picture of times square blurred with my algorithm:
Nevermind the dark edges, I can fix that.
You can sorta tell it’s different from gaussian, but it’s still a long way away from what could respectably be called bokeh, with crisp edges:
I understand why my algorithm does what it does… how can I more accurately simulate a bokeh?