开发者

Create Aperture / depth of field effect

开发者 https://www.devze.com 2022-12-10 05:07 出处:网络
How can I create a function that will replicate the effects of different aperture settings.I want the user to be able to click on different \'focal points\' of their picture and see how the aperture/开

How can I create a function that will replicate the effects of different aperture settings. I want the user to be able to click on different 'focal points' of their picture and see how the aperture/开发者_JAVA百科depth of field would change depending on which focal point is in focus.

Also I was curious if anyone knows how to create a slider bar that would create the blurring effect of a low aperture.


Why not go the simplest route? Set a camera on a tripod, take your pictures with different aperture and focal distance settings. When the user of your app choses a different aperture or focal distance, just swap out the picture to show the depth of field effects. This will save you a lot of trouble, will be authentic, and look much nicer.

You can do this all with 16 pictures (4 focal distances, and 4 aperture settings). Have a slider for the aperture value, and a slider for the focal distance.

If you try to let the user select a point on the picture you'll need to have 3D information available for the scene, and I think this just ramps up the complication of your app. Keep things as simple as possible, because it doesn't take too much to convey the information for your students.


You need a convolution filter. To get the coefficients for the filter, you can look at the impulse response. If you take an out-of-focus picture of a bright point of light, you get a nearly perfect circle - if you generate a circle and average every pixel inside of it, you'll get a good approximation to an unfocused image.


That sounds like something you could do with a configurable pixel shader. WPF and Silverlight are capable of that, as well as other open-source image editing libraries.

Read up on High Level Shader Language for more info. There is also a .NET ImageTools library that may help.

0

精彩评论

暂无评论...
验证码 换一张
取 消