There is a Depth of Field (DOF) calculator below, but which was not really done for general purpose. It does do that, but there's already a very good one at DofMaster, so there was no need for another. And I shirk at the work to provide sensor size and Circle of Confusion (CoC) for every camera known to man. :)
But the DOF calculator below is different, in that it also computes CoC at the Background behind the subject (amount of blurring), a concern when wanting to blur and hide the background. The calculator compares numerical situations of two lens. Instead of reaching for a 50mm f/1.8 lens, it suggests a better way with better results (greater DOF on subject, but greater blurring at background) by standing back with a longer lens. This technique is well known to pros. Using f/1.8 on work they hope to sell seems not the best choice. This calculator is an (interactive) example of two lens choices, regarding making decisions about blurring the background.
We should realize that focal length and subject distance are Depth of Field (DOF) factors too. We can use them. My notion of a portrait at f/1.8 is that there will of course be DOF problems, usually about the hardest possible way to make a good picture, and the last thing I want if I can prevent it. Notions may vary, but studio portraits likely work at f/8 or f/11. Flashes are big to allow that. We like the sharpness of depth of field.
The defaults shown in the DOF calculator (the one below) initially compares a 50 mm f/1.8 portrait at 6 feet with a 200mm f/4 at 24 feet, both using a DX APS DSLR camera. It assumes the background we want blurred is 40 feet behind the subject (try other distances too, the longer lens usually wins). Pros would more likely use maybe a 200 mm at f/4 for this purpose (of hiding the background). Or 100 mm at f/2.8 can be better too. The 200 mm is 200/50 = 4x longer than 50mm, therefore the two subject fields of view are the same size if the 200 mm lens stands back at 6x4 = 24 feet.
And if both lens with distances adjusted to be the same field of view at the subject are also at the same aperture, then they have the Same DOF range too (at the subject) - the adage about the "same image has same DOF", etc. (at the subject, it does). But where we stand does affect the perspective, and the background is certainly NOT the same then... in the long lens, most of the wide background is zoomed out and gone missing, but what's left is even more blurred focus (assuming that is a plus here). This standing back at greater distance is little problem to do outdoors, and it possibly need not be that extreme. If both could use the same f/1.8 then, the depth of field at the subject is the Same, both 0.29 feet of DOF (which is only 3.5 inches - from nose to hair may be more than that). DOF does not describe the sharpest necessarily, instead it defines the maximum blur that we can accept. But we don't have to use the same aperture, the 200 mm lens at 24 feet can use say f/4, which has 0.66 feet of DOF (8 inches). That's still not much, but it's sure a lot better, more than twice as much DOF. But it is even more blur at the background.
Qualification: This adage is a rule of thumb that the "same image" (meaning "same size subject image") at same f/stop will have the same depth of field. It is true when the shorter lens subject distance is less than about 1/5 of its Hyperfocal distance (then DOF is same within 4%, and normally well less). At reasonable subject distances, this is generally quite true except wide angle lenses need shorter subject distance. There are multiple parameters affecting the result, but try it, you'll find a lot you like. Proper portrait perspective is generally considered to need a longer lens anyway. FWIW, regardless of lens focal length, a subject distance less than 6 or 7 feet is simply too short for proper portrait perspective. 8 or 10 feet is even better. Stand back a bit, don't get the camera up in their face.
And the overwhelming advantage is even much better yet: We said this Field of View (FOV) at the subject would be the same in either situation (about 2.9x1.9 feet, about right for head and shoulders). But the background field at 40 feet of the 50 mm lens is 22 feet wide. 22 feet of stuff you want blurred away. However, the field of view of the 200 mm lens is only 8 feet wide at 40 feet (behind the subject). So most of the objectionable junk you want to blur is simply missing, simply gone, removed in the best possible way. And better, you can surely move the camera slightly to one side to choose to align the best 8 feet of background decently enough, probably even if it were not blurred. But in fact, it is blurred at 200 mm. Probably blurred more (perhaps a bit less if background is near), but 1) the subject DOF is so much better, and 2) there is much less of the background even showing. And 3) usually the background that is visible is blurred even more.
So again, it's like this. Two lenses, one longer and standing back at equivalent distance to have the same field of view at the subject. If at the same f/stop, they have the same depth of field at the subject. But the longer lens is further from the background, so the background is blurred more. And it has a smaller view of that background too, so we can move slightly to choose a nice small spot to show. So then, the longer lens can be stopped down a couple of stops more to improve the subject DOF considerably. This does reduce the background blurriness some, but it's still more blurred than the short lens. What's not to like? The only downside is we need to bring the longer lens, and have room to stand back.
It should be obvious that this is a really big deal to know. There are three properties offered by the longer lens: Greater DOF at subject, a much smaller area of background to select and be seen, and greater blur on the background. There are many numerical combinations where the longer lens is simply better. And a few more where a property or two is still worth consideration. If you also find f/1.8 distasteful, there is this better way.
So the calculator below computes the sensor CoC at both subject and background distances, to make this point.
DOF is certainly not ONLY about aperture. DOF is an extremely important basic of photography, however IMO, exact DOF calculators may not be great practical use, other than to get a rough idea. But we certainly do need to know the concept. We need to know this, it should be second nature to you.
** The three lens properties above cause the CoC (blurred diameter) in the sensor image. Then the DOF that we perceive relates to how large we enlarge that CoC to view it. We do think of cameras with smaller sensors giving greater DOF, which might appear to be the opposite of just said above. And they certainly do that, a little cell phone does not even adjust focus, yet it is in adequate focus about everywhere. But that is only because the field of view of a tiny sensor is drastically cropped. Therefore it must use a very short lens to achieve the same normal wider view (Crop Factor). That shorter lens certainly does increase DOF. But even if we could use the Same lens (and ignore the crop), then the smaller sensor still must be enlarged more, which reduces DOF. In the math, a larger sensor computes a larger acceptable CoC limit, which increases DOF.
The Depth of Field is the computed zone around the focus point, the span where the CoC remains less than our arbitrary limit for the size of CoC, considered to be in focus. The image is only focused at one distance, and gradually degrades away from that point. Focus just outside the DOF calculation will be hardly different than the focus just inside the DOF calculation. DOF is NOT at all magic numbers, it's just where the math computes the CoC size crossed an arbitrary threshold boundary. The boundary is very vague to our eyes.
The name Circle of Confusion is from another era, and Wikipedia quotes work in 1829 and 1832 calculating Circle of Confusion. They had microscope and telescope lenses then, but this was before cameras or film. Still same concept, but maybe if invented today, we might pick a simpler name for CoC (it is the diameter of the blurred circle of an out of focus point source). Sensor size is a factor of enlargement. Older work used CoC = (sensor diagonal / 1730), or 0.025 mm for 35mm film. Today, we often use the computation (sensor diagonal mm / 1500) for acceptable maximum CoC in the final standard print size. These are sometimes rounded numbers, or CoC = 0.03 mm for full frame 35mm sensors, and CoC = 0.02 mm for smaller APS sensors (because the smaller sensor requires half again greater enlargement). These actual calculations are 0.029 and 0.019 mm, but the /1500 was arbitrary in the first place. It is entirely arbitrary, and professional level might be smaller, with larger safety factor. Our CoC number choice does not affect the image, it only affects how we might judge it, or plan it. It is an arbitrary notion about when out of focus is judged to become too noticeable. And DOF very definitely also depends on how large you enlarge the image to view it.
Identify your camera sensor size by entering either CoC or Crop Factor or actual Sensor Size or Film Size. Full frame 35mm cameras often use 0.03 mm for CoC in DOF, and APS cameras often use 0.02 mm. However, the actual standard is diagonal / 1500, which is the 0.029 and 0.019 mm used here (these are arbitrary but Standard definitions). It's about sensor size, which is sometimes hard to know, but probably many of us do know Crop Factor, and we can compute from that. Hard to beat precise sensor size specifications though.
Megapixels is only used here to compute image size (pixels). It does NOT affect Depth of Field or Field of View. Megapixels is only for you to confirm Aspect Ratio is about correct, which does affect FOV. Camera numbers are approximations, so a size difference of several pixels is not a big deal.
Aspect Ratio computes megapixels, image diagonal, and also Field of View (except Sensor Size or Film Size instead directly uses sensor shape for Aspect ratio).
Rounding: Note that numerically, real world APS sensors are slightly smaller than 24x16mm, and their crop factors are actually slightly larger than 1.5 or 1.6. If CoC or Crop Factor or megapixels are rounded values, they could slightly skew the results in a trivial way, but the concept should still be very clear. We're looking for big things.
DOF is Depth of Field, CoC is Circle of Confusion, and FOV is Field of View. BG is background.
If you see results of NaN, it's an error meaning an input is Not A Number (periods are OK, but don't use commas).
CoC is theoretically zero diameter (a point) at the focus point. But this blur circle grows larger when not in focus, and the DOF range is calculated to not exceed the standard (sensor diagonal/1500) limit on acceptable CoC (computed to view as acceptable in the standard 8x10 enlarged print viewed at 10 inches).
The new thing here is that "BG CoC" is the computed CoC at the BackGround, and is shown as "X times CoC", meaning X times size of that diagonal/1500 limit of acceptable CoC. It is a relative scale of blurring. The DOF concept implies that if the background were exactly at the far limit of DOF, the blur diameter there would be exactly equal to CoC (1X CoC). A larger number is greater blur.
Examples, just to show you. You should go out and see how this works too. f/1.8 may be a bit difficult in bright sun, may need up to 1/8000 second at ISO 100. The first picture is f/8, and all are uncropped, full frame. It is probably about the right field size for a head and shoulders portrait. The vertical metal ruler is one foot for scale, about same height as a human head. You'll have to use your imagination. :)
The situation for the example photos shown below switched to specifying the (DX or APS) Nikon D300 specifications of sensor size 23.6 x 15.8 mm (a minor difference). That computes CoC 0.0188 and Crop 1.523 (to compute numbers below the pictures).
The far end of the house and Crepe Myrtle bush is measured to be 40 feet behind the "subject" (you might make out the blurred yellow tape on ground). Focus is on the near subject. Camera is measured to be at 6 feet for the 50mm lens, and 24 feet for the 200 mm lens (6 x 200/50 = 24) - which both are the Same size Field of View at the subject, but 200mm is vastly less view of the background. The bottom yard stick shows field of view. The top yard stick is angled about 25 degrees so that the ends are about 7 inches closer or farther distance than the bottom straight yard stick (hoping to show DOF). DX Nikon D300, 50mm f/1.8 and 70-200mm f/2.8 lenses.
At the background, the first f/8 image below computes 8.1x times the 0.0188 CoC limit, and we can see it is not quite sharp back there (f/8 is only 1.48 feet DOF at 6 feet, but the background is at 46 feet).
In the f/1.8 image, we see 36.2x CoC is much more background blur, and DOF is much less, only 0.29 feet at the subject.
The 200mm f/4 background is at 64 feet now, for 46.4x background CoC (lager CoC was one of our goals, to blur the background). It has larger Circle of Confusion at the background, an even greater blur. We can sort of see the circles. Yet (at the same FOV), the f/4 subject DOF is over 2x greater than if at f/1.8, or 0.65 feet at f/4, better. It's still a tough situation, but we made progress toward our goals (more blur on background, and more DOF around our subject). Just a little experience noticing should learn to know what to expect.
These images are not cropped either. The greater subject distance gives the 200 mm essentially the same field of view at the subject. But the 200mm certainly does crop the background, a plus. And sort of like moving a spot light around, we can easily move the camera slightly to choose the best part of it. And the lens can enhance the DOF, another plus at the subject, and still be more blurred at the background.
IMO, even the f/5.6 background looks better than f/1.8. And f/5.6 certainly has strong DOF advantages at the subject. We have choices. We could of course pick better backgrounds, and subjects too, and there are many numerical combinations, but the longer lens is a very strong technique. It helps portrait perspective too. This is just a quickie test, with a hopelessly poor background to make a point.
Which above do you think could be the better portrait background? Did you notice how much of the wide background is simply missing? The telephoto background is so narrow, making a step or two sideways is easy to select the most desirable part of it to show (or omit). Do you imagine stopping down a couple of stops from f/1.8 could help the subject DOF?
Here are some blowups to better see the subject detail: (same pictures, full frame width, 33% size, 950 pixels wide)
50mm 6 feet f/8, DOF 1.48 ft, BG CoC 8.1x
50mm 6 feet f/1.8, DOF 0.29 ft, BG CoC 36.2x. I don't see much appeal of f/1.8
200 mm 24 feet f/2.8, DOF 0.46 ft, BG CoC 65.6x
200 mm 24 feet f/4, DOF 0.65 ft, BG CoC 46.4x
There really is nothing to debate here. Trying to eliminate the background with 50mm at f/1.8 seems like throwing out the baby with the bath water. Standing back with the longer lens is a good first step. The real point is, suffering with f/1.8 is self inflicted, not normally necessary, or desirable. There are better goals.
For those who get up tight about slight rounding errors:
That's me too, but it's not all that easy. This D300 takes 4288x2848 pixel images. That part always comes out right. That of course computes 12.212 megapixels. The manual calls it 12.3. The 4288x2848 is 1.5056 aspect ratio. The sensor dimensions of 23.6 x 15.8 mm computes 1.4937 aspect ratio. I've been calling it 1.5 ratio. The math is not hard, but the hard part is determining the right numbers to input. So there may be some tiny rounding errors. :)