Focus Map??

I am trying to get the focus map of a picture… Is there a way to get a map kind of like a zdepth, but for the focus, that can be gotten from a single 2d pic??? I can get close on some pics, but not quite what I am wanting… anybody got any ideas?

I am using photoshop 7 so if you have an action that will do it then that would be great… Or a way to do it in blender…

Aaron

What’s a focus map? There is no mapping function in Blender that can detect or use the focus of a 2D image. Or do you mean Focal Blur (FB) or Depth of Field (DOF)?

%<

Well, it is not FB or DOF… A focus map… is what I call it… it is when you take a picture, how there are things in focus, and things not in focus… I am trying to get a map that is kind of… well in a zdepth map how things that are close are white and things further away are black… I am trying to do something similar, but for the focus of a picture… have things that are in focus be white and things not in focus black…

I have been trying to get an action that can get this type map in photoshop… I could not get that good of results in blender… I can get a contrast map… and from that get something close to a focus map, and nearly the quality I am going for… I just did not know if anyone else has tried doing this before.?. and if they could get a focus map… then how did they get it…

If I get better results with what I have then I will show my results, and may even test other peoples pics… but that is a ways off… I have to tweak and fine tune my result a good bit more… it works on some pictures, but not all…

Hope that helps explains what I am asking about a focus map…

Aaron

That’s DOF. Search here for many threads on how to do it with Nodes. If you want a Z-Depth, Greyscale map use Z-Utils:

http://www-users.cs.umn.edu/~mein/blender/plugins/sequence/zutilz/index.html

or ZBuffExtract script by (I think) Flippyneck.

%<

Well that DOF is for 3d objects… I am trying to get the DOF from a 2d picture… so it is a bit harder…

As far as I know there’s no Z axis in a 2D image. You might find some obscure filter for photoshop that hacks it.

%<

Well I have been using the contrast of images to help get whats in focus and what is not… and even though it may not be a zdepth… if the focus was in the front of the pic it would be a zdepth…

I will upload some pictures later showing my progress thus far… and see what you think…

Aaron

so it is a bit harder…

And pretty much impossible from a single image, unless you know exactly the characteristics of the lens that was used, the lighting setup, and the reflectivity of all the surfaces in the scene. You might as well have been there and measured all the distances yourself. Simply extracting the in-focus / out of focus portions of an image is difficult for a computer (e.g. by deconvolving a defocus filter over the image; a priori, what filter do you use?). Our brains do it quickly because we have stored a lot more information about the world than any current software algorithm (e.g., solid chess pieces don’t intersect, walls are usually in the back of the room, etc etc).

Researchers have tried extracting focus as a range-finding technique for mobile robots. They do it by taking multiple low DOF images at different focus distances and deconvolving those. You need the multiple images so you know what order to place things in the Z. Unfortunately even knowing the lens settings exactly, the robots still bump into things if they use this method alone.

Still I’m looking forward to what you get with your contrast method. It should at least give you the focal plane. Have you tried combining it with high-pass filtering to extract the sharp edges? The problem will be deciding what’s in front and what’s behind when things are equally blurred.

Well to answer some of your questions… I know about this program: Combine Z It uses the multiple DOF images and “combines” hence the name, to get an even contrast/focus picture and from that it gets the Zdepth… So that is pretty good…

and I actually do use high pass… I use my own custom filter, high pass, find edges, blending methods, blurs, and a lot more and then mix all of those images together to get something close to the focus map, as I call it…

Here is the image of a few pics I just tried… I tried the high res pics… to try to get more detail, but sometimes it does not work with high res… So I am playing with what works and what does not… This is actually a mix of my old way and my new way of getting the focus map… it comes out a little closer when I do it like this… It still needs work, but I am getting a lot closer…

What do yall think???

http://ser8.imgdump.net/images/09292006/s8_b740a105e037867.jpg

Well with some more testing my new technique is not as good as my old way… So I will make a few new images and probably even show these same images with my old way…

Yall can still tell me what you think of these for now…

Aaron

Well, I made a new way… so this set is a mix of my old way and my newest way… The flower came out the best I think… but the others still did good… I am now working at making it be a bit more correct for each…

Still all of these pictures use the same action… all done automatically… I did not do any pre/post editing…:

What do yall think of these?

http://ser8.imgdump.net/images/09292006/s8_469b19356220768.jpg

I still don’t get what those “focus maps” are supposed to be…do you just want to extract image parts that draw the attention of the viewer, or what kind of “focus”?
At least i don’t see how those images are even close to a useable depth map…

As said, there is no information in a single image to extract depth except with manual filtering of image characteristics that happen to correclate with depth, which can be totally different for each image, or non-existant at all.
For real and robust depth extraction, you need multiple images. E.g. two images taken from points seperated by a sufficiently large base line that you feed to a disparity algorithm (stereo vision)…

I know about the stereopic depth extraction… I can’t find a program to do it… but I know about it… my version I have shown thus far… are just attempts to seperate different shapes, and mabey get a focus map… but I am still playing with different ways… I do not think I will find a TRUE way to get a focus depth out of EVERY picture, but out of most pictures I would like to get at least something…

I can get almost exact on some pictures… but that method does not work on others… So I am playing with what steps get the result I am going for, that can be reproduced on any other picture…

I hope to be able to get something of a focus depth or z depth based around what is in focus and not in focus… So I am still trying a lot of things…

My reasons for doing this is… so that I can make an automatic way of making: old pictures into stereoptic pictures… or be able to make a rough model of things in the picture… and just to see how close I can get to a focus depth/focus map…

Hopefully that fixes your confusion…

Aaron

I have an idea of what you are trying to do, but I think it would be simpler to simply use the blur tool in photoshop to imitate DOF.

You can find such a program here:
http://www.3dphotopro.com/software.html

It’s named “Depth map Creator” and costs 250$. But you can download a free demo version, when you register for the newsletter.

Here is a tutorial for the program:
http://www.3dphotopro.com/soft/depthmap/help.htm

I didn’t test it, yet. But maybe I’ll try it tonight. The results in the tutorial look quite good. But, what would be better, is a free version of such a program…maybe anybody knows a free alternative?

I’m really interested creating depth of field in video-files quickly. Maybe someone has good tips for me?

Thx

Thanks for the link Deader. I had been trying to find a program like that since I saw this site: http://axon.physik.uni-bremen.de/research/stereo/vrml/index.html

Now if you are wanting to get the zdepth from a video… there are a variety of camera tracking programs, that can track motion… so that you can get a zdepth…

This site has different plugins for a program that can do quite a lot…:http://www.thefoundry.co.uk/pkg_plugins.aspx?ui=44213E51-76C0-4926-9D5D-3A8059449900 but other than that I think PFtrack can, and mabey Syntheyes…

We had to create disparity maps as homework for computer vision…
Just takes a few lines of code using the OpenCV library.
See here for an example: http://www.kingston.ac.uk/~ku32195/3DStereo.html
(we used the same images, and another pair…)
I think i still have the code somehwere…but no idea how good it works with random images not created for demonstrating the algorithm to students :slight_smile:

Is it even possible to make a stereoscopic view from a single image?

Strike that, I guess with a program made to mimic that, it would be possible. You could try photometry to make a plane with a limited elevation, project the image as a texture and then make two renders with offset camera’s.

This site has alot of data on photometry and links to the programs.

Jason

Well if I can get a focus depth… which is what I am trying to get… I just call it a focus map… because then if the focus is what is closet to the camera then it is like a zdepth… then I can put it in blender and make a stereoptic like how I have been doing… but the first step is to get a zdepth or focus depth…

I had been making the zdepth of a picture manually, and can get pretty close, but I wanted to try to get an automatic way to at least get close, and then if I had to I could clean it up a bit for the zdepth afterwards… But I wanted to be able to get a zdepth or close from a focus depth… if at all possible…

Aaron

Is there a way to get a map kind of like a zdepth, but for the focus, that can be gotten from a single 2d pic?

Nope. The pictures show that your method doesn’t even come close. I assume gray level is supposed to reflect distance. If that’s the case, the center of the flower is as far away as the grass in the background. In the landscape picture, everything in the scene is essentially at infinity and is all in focus, so you can’t derive depth from focus for that photo. I’m afraid you’re extracting contrast more than anything else.

Like I said before, without prior knowledge about the objects in the scene (reflectivity, size, lighting, focal length, etc.), you’re never going to extract depth information from a single image.