Focal length is the physical measurement of distance between the lens and the imaging sensor when the subject is in focus.

Apart from the definition of focal length in photography as the measurement in millimeters from the lens to the image sensor, focal length has a direct impact on the angle of view, which is a static property of the lens in question but is impacted by the sensor crop factor.

One key to understanding focal length is recognizing how the look of the image changes using lenses with different focal lengths. Using a wide-angle lens, foreground elements are emphasized while background elements are pushed even further away, looking smaller than they really are.

Understanding focal length in photography can feel a bit overwhelming when trying to account for all of the ways it changes the properties of an image. Below, I’ve outlined the focal length differences across the major fields of view.

Ok, let’s see now - our script previously ended with the creation of a bunch of sub-Tissue annotations, so we need to include the selection of the correct annotations, the cell detection, and finally the classification of the cells.

Focal length differences are especially stark with wide-angle lenses. Each mm of width makes a visible difference, unlike telephoto lenses where it takes several mm to be easily noticeable.

Remember that if you tend to specialize in any type of photography, it’s crucial to understand how focal length affects your image so you can have a better idea of what sort of lenses you should be shopping with, as well as the impact they have on a subject and background. You can download my PDF photography guide to get more information about this.

Classes: In case you have more classes than you want to use (for example you have multiple sets of detections that are not cells, and only want to classify the vasculature but not the subcellular detections), you can have the classifier only accept training data from certain classes of training objects. Essentially, prevent cross-contamination with other objects in complex projects. Again, the “Select” button on the right becomes available after changing “All classes” in the dropdown to “Selected classes”.

When duplicating the images for training, make sure you copy the data, or that you apply the color deconvolution part of the script to the new image. In both the pixel and cell classifiers, we use Hematoxylin and Eosin based measurements, which are dependent on those color vectors being the same in the training images as they are in the project images! Double clicking on one of the Stains in the Image tab will show you the name of the current set of stain vectors. Having named mine "H&E Tile 4", I can quickly be certain I have the color vectors set the same way they are for the rest of the project!

Brightfieldmicroscopeimage

By taking the crop factor of a specific sensor and multiplying it by the field of view, we get the field of view as if it were viewed in the 35mm standard.

A lens focal length that’s greater than 50mm is considered a long focal length. This view is narrower than the normal view we’re accustomed to when paying bare attention. An image taken with a 100mm telephoto lens will have a much smaller section of coverage than a normal or wide-angle field of view.

Another, faster but less precise, way of generating training data is to use the Brush or other area annotation tool to select an area and then apply a class to that. All cells that have a centroid within the annotation (not simply intersecting with the annotatino) will be considered that annotation's class during training. Pete has an example in his YouTube playlist.

However, using a prime lens means that you have to physically move in order to create a given field of view. Which kind of lens is better is an age-old question and really comes down to your own personal preferences!

Hopefully it is apparent that this is an oversimplification, as optical density can also be used to detect CD4/CD8/CD3 positive cells, even though the cell detection algorithm will be detecting the entire cell and not just the nucleus. The point to keep in mind is that when you use QuPath like this, the whole cell will be treated like the nucleus, and it will STILL expand a cytoplasm out past the cell borders if Cell expansion is enabled..

It’s important to consider that focal length is a static property of a lens that’s true regardless of crop factor; for example, a 16mm APS-C lens is a 16mm lens even if it has a 24mm equivalent field of view in a full-frame camera. We’ll see + in-depth info about this below.

Smoothed features - collect weighted averages of each measurement from objects within a given radius. This can provide additional context to cell classifiers - “what are the cells nearby like?”

Image

Wide-angle lenses or short focal lengths offer a great opportunity for shooting landscapes, cityscapes, Milky Way photography, and Northern Lights photography.

For example, if I use a short focal length in portrait photography, parts of the body that are closer to me can be unflatteringly emphasized. On the other hand, in genres like landscape photography, it’s more common to see images taken with a wide-angle view, not only to capture the entire scene in a single image but to emphasize elements in the foreground.

First I run the script as far as we have gotten it, so that I can look at the state of the project as I begin cell detection. I will NOT run this in the training images as it will delete all of the training data!!! It would be safest at this time to back up your training data by saving a duplicate copy of the project or the .QPDATA files for those images. The image of the Hierarchy tab to the right shows what I have so far - one parent annotation (the tissue detection), and three child annotations indicating the different tissue types. The goal is to generate cells in the EosinDense and NormalTissue annotations.

In the cell training image, I selected the Points tool (three circles in a triangle) which opened up the Counting dialog box. In the Counting dialog box I clicked Add twice to create two groups, then assigned each group a class (Positive and Negative in this case, although you can create classes for these just like for the pixel classifier) by right clicking and Set class. At this point, all I need to do is select one of the two Points objects and then click somewhere within a cell. That will drop a point of the selected class within that cell. Having a Point object within a cell during training lets QuPath know that you want that cell to be treated as a particular class. It does not guarantee that your classifier will end up giving that particular cell that class - only that it is to be treated as a training example of what you want that class to look like. Also, “look like” is probably a bad choice of words here, as the only thing the classifier will use are the cell measurements. The QuPath classifiers, at this time, never “see” the cell. Any measurements you might have added afterwards will be included with the default measurements generated when the cells are created. Any measurements added after the classifier is created will not be included or used.

Can you help me understand why a lens advertised as 60 mm f2.8 macro is described as 120mm and equivalent to 35mm focal length? I am completely bewildered.

Photos taken with a long focal length look more “compressed” as compared to shorter focal lengths, and allow you to capture subjects from a farther distance without losing image quality.

If necessary, hunt around for mis-classified cells and correct them by placing a Point object of the correct class somewhere within the cell. As long as Live update is selected, the classifier will updated automatically.

To create a machine learning classifier, we will use Classify->Object classification->Train object classifier. If you run into any issues, Classify->Object classification->Reset detection classifications is a quick way back to blank. However, be aware that it will also reset the class on any subcellular detections you might have, so you may want a script to avoid declassifying your spots..

Focal length touches upon many elements of the photography basics; composition, aperture, depth of field, and other aspects all shift when taking focal length into account! Each twist of the zoom ring or swap of a prime lens is a shift in the interplay of focal length and your creative vision.

Dark field microscopy

Which features are used in the object classifier can be chosen through the “Select” button on the right, which becomes available after changing “All classes” in the dropdown to “Selected measurements”.

If I were to select all annotations and run Cell detection, I would end up with a lot of cells within the original Tissue annotation, with all other annotations deleted. That is because once Cell detection starts within a given annotation, it removes all objects within that annotation. We need to specifically select the annotations we want to run Cell detection on, and version 0.2.0+ gives us an easy way to do that.

I emphasize that we get the field of view because again, lens focal length is inherent to a lens. A 25mm Micro 4/3rds lens has a 50mm full-frame field of view. However, it remains a 24mm lens with the distortion properties of a 24mm lens; it’s not magically a 50mm lens.

These lenses take on an expansive field of view that’s wider than what we normally pay attention to. An image taken with a 15mm lens will seem abnormally expansive, taking, for example, an entire landscape with ease.

Features: Features are everything that can be found in the measurement list shown when an object is selected in either the Annotation or Hierarchy tabs. The bottom left corner of the screen will show a scrolling list of all measurements “owned” by the selected object. Many of these measurements will be generated by default, but many other measurements can be added through the Analyze->Calculate features menu, including:

The last measurement we need requires the creation of cells in various parts of the tissue. Cell detection in QuPath is primarily based on detection of the nucleus. That is not to say that cell detection cannot be used to detect other things - just that its purpose is based around finding an object of small round-ish object of a single stain or channel. In brightfield images, Optical Density can also be used when the nucleus could be multiple colors, and those colors obscure each other, as in the case of KI-67 staining with DAB.

In practical terms, angle of view and field of view are used interchangeably in photography to indicate the way our cameras “see” the scene, and using a short focal length or a long focal length will change drastically the field of view or the amount of the scene that is photographed.

A prime lens can’t be adjusted and its focal length and field of view are fixed. The trade-off for flexibility in focal length is usually a wider aperture and better image quality because the prime lens can be optimized for its angle of view. Usually but not always; some top-quality zoom lenses nowadays are absolutely comparable to prime lenses in terms of quality for a given focal length.

Image

The simplest focal length definition is a description of the distance between the center of a lens and the image sensor when the lens is focused at infinity.

By twisting the barrel of a zoom lens, you can adjust the focal length and field of view of your lens, which affects depth of field, distortion, and all other aspects of your image.

Telephoto lenses are those beyond 50mm. These lenses are also physically longer than wide and normal lenses. The field of view is smaller but you gain significant reach.

Great! Now we are all set to run cell detection. I recommend manually creating a few small areas to test out different settings, and make these areas fairly varied in terms of cell density and stain type. Remember, we just saw in the Pixel classifying section what the increased cell density could do to class detection! At some point later I may go into a deeper dive on various cell detection methods, but for the moment I will simply leave a set of links with further information, and that it can be a nice trick to make several small square annotations quickly, select them all and merge them using the Objects menu, and then quickly iterate your cell detection on that distributed single annotation.

Further color/channel based measurements, including texture based measurements (Haralick features). Can be useful if you need to change the color vectors and add additional measurements in cases where you have more than 3 stains.

Hi Anne, it totally depends on the sensor size of the camera. For example, if you’re using a Micro 4/3 sensor camera with the 60mm f2.8 lens, since the crop factor is 2x, it means that you’re cropping the image the double, so technically it’s like shooting at 120mm focal length. Hope it’s clear. 🙂

Bright field microscopy

Due to QuPath using the cell centroid to place a cell “in” a given annotation, some cells at weird edges of annotations will show up as being in the HematoxylinDense areas, despite no cell detection being run there.

Standard focal lengths range from 35mm to 50mm depending on the type of camera sensor. The field of view provided by standard focal lengths approximates the field of view of the human eye.

There are great apps and websites that allow you to calculate depth of field for a given focal length, aperture, subject distance, and sensor.

Focal length can feel a little abstract when looking at one lens versus another. One of the easiest ways to understand focal length is to look at images that use the lenses in question! To wrap up, here are some focal length examples for you to consider:

Understanding your camera’s zoom ability helps you know what sort of pictures you can reasonably expect to take. Just like with an interchangeable lens camera (ILC), the camera will have a focal length range that tells you about the properties of the lens.

Macro lenses have the highest magnification due to their unique construction, which reduces the focal distance they operate within and allow you to focus in very close subjects.

Official documentation Direct link to YouTube video, RECOMMENDED START POINT Forum post that is a bit of a dive into each of the settings. Expand the arrows to see the text

As you can see, the focal length we choose affects the final image. Also, the field of view and lens distortions fundamentally affect the type of photography you do.

Classifier: There are similar classifier options to the Pixel classifier, and as then I recommend starting with the Random trees option, then if you are not getting sufficiently accurate results, switching to ANN once you have narrowed down the list of inputs (measurements in this case). As before, checking the Edit->Calculate variable importance is the most valuable feature that Random trees provides.

As we step into normal focal lengths, which are closer to our human vision (like 35mm), this effect is subtle to invisible. However, once we hit telephoto angles of view, the background appears to be closer to the subject. This effect increases as your lens mm does.

This concept can be complicated when the crop factor and the field of view come into play since we began to ask what is the equivalence of the focal length of a lens using it in a camera with a different sensor format.

Testing out the full script on Tile 4 seems to work just fine! I did adjust the color of “Positive” to Cyan so that it would show up on the Eosin background. Looking at the Show annotation measurements (Grid/Spreadsheet button marked in green above) for the one tile indicates that there may be a higher percentage of elongated cells in the Eosin area than in the normal tissue. But will it hold up? Next let us work on exporting the results in a couple of different ways.

After a few quick tests, the only settings I changed were reducing the Maximum area to 200 (just in case of artifacts, none of the nuclei I found were even close), and increased the Hematoxylin OD Threshold to 0.25 to exclude some of the nuclei that were not fully in-plane and to reduce issues with adjacent HematoxylinDense tissue areas.

Since I wanted to include some classification, I went ahead and saved the data with the test annotations, and then duplicated this image (Tile 4, with data) to create a cell classifier training image. This training image is only really necessary since I am going to use a machine learning classifier to try to detect elongated cells, but normally if elongated cells were the only thing I were interested in, I would choose a single measurement classifier based on the Eccentricity.

Focal length comparisons are incomplete without the infamous crop factor discussion. Nowadays, we have APS-C, Micro 4/3rds, medium format, and full-frame, all of which use a lens focal length description centered around 35mm film gear. While this made sense when the digital revolution began, it’s often simply confusing to parse nowadays.

Please note that lens compression is not related to the lens, but to the distance from the subject (Ex. You can achieve the same field of view and perspective shooting an element with a short focal length like 20 mm or cropping the same area from a 50 mm as long as both images are taken from the same distance).

How does a bright field microscope work

Standard lenses or medium focal lengths are suitable for shooting many different genres like portrait, street photography, landscape, etc.

Training: The training data that the classifier uses can be further limited to only pay attention to points objects if there are annotations lying around your image as well. This option could allow you to have classified area/line annotations for a pixel classifier and Points annotations for cells, all in the same training image. Options include All annotations, Unlocked annotations, Points, and Areas (lines do not count as Areas!).

Differential interference contrast microscopy

Photographs taken with short focal lengths show distortion in certain elements; those closer to the foreground are magnified whereas all the elements in the background will show a diminished perspective.

Zoom lenses are what anyone who has ever picked up a camera in recent times is familiar with. In fact, they are so common that I often find non-photographers get baffled when I hand them a camera with a prime lens attached!

Selecting annotations by class: Go to the Annotations tab, and select the NormalTissue and EosinDense classes (SHIFT+click or CTRL+click to select multiple classes, like in a file folder). Right click for the context menu, and select the bottom option, Select objects by classification. The two annotations of those classes will now be selected, and in the Workflow tab, you should have a new entry that will let you perform this action by script.

Shape features - mostly included for cells, these can be very useful for detections created by the pixel classifier, annotations, or even subcellular detections if they are being used to detect objects other than ISH spots.

How focal length works is by describing each lens in terms of millimeters (lens mm). This description is a hard-physical reality of the lens in question, no matter the brand, format, or aperture.

Image

Focal length and depth of field are different properties of both a lens and sensor but are somewhat related. Depth of field is how much of a scene is in sharp focus. How narrow or wide the depth of field is, is an interaction between focal length, sensor size, subject distance, and aperture value.

Bright field microscopy advantages and disadvantages

In the relation between focal length and depth of field, when all other values are equal, short focal lengths (or wide angles of view) have deeper depth of field relative to long focal lengths (narrow fields of view). Thus, the longer the focal length, the farther the hyperfocal distance will be.

Analyze->Spatial analysis has additional options that can calculate distances between different classifications of cells, distances of cells to some nearby annotation border, or create clusters of similarly classified cells. These do tend to be more useful after the cells are classified, but can be used for “sub-classifications” or “derived classifications.” For example “CD4 positive: Clustered” vs “CD4 positive: Isolated”

Load training and advanced options: Load training functions in the same way as the pixel classifier - you can use this option to load training data from multiple images. I strongly encourage its use in all cases. Advanced options allows for Feature normalization in case you have extreme differences between your images.

While we do go into some depth here and there are some confusing elements surrounding the topic, I’m confident that by the end of this article, you’ll have a solid foundation on what is focal length and how it relates to digital photography.

Focal length determines many of the characteristics of the photos you can take as well as the physical dimensions of the lens.

Object filter: The object filter allows you to choose which kinds of objects you will classify. There is no option to classify annotations. If you want to classify annotations, create them as detections first, add measurements, classify them, then use a script to convert them into annotations of that class. “Cells” are a good option if you want to restrict your classifier to only cell objects, as other types of detections can be created, either by the Pixel classifier, Subcellular detections (think FISH staining, RNAScope), Tiles & superpixels, or other objects manually created by scripts. I would only choose “Detections (no subtypes)” if I specifically want to classify non-cell objects like subcellular detections. Tiles can be useful for specifically selecting SLICS or other superpixels. Probably 95% or more of the time, most users will really only want to choose “Cells” here.

When you look at the focal length of the lens in question and you see a number below 35mm, you know you’re looking at a short focal length.

Focal length is one of the main considerations when buying and selecting a lens. And understanding how focal length works is essential to capturing the photos you want. Otherwise, you’ll be choosing lenses with random angles of view that only serve to confuse you with choices.

Focal distance is the distance between the subject you are focusing to the camera sensor. Lenses that can work at close focal distances have higher magnification (or reproduction ratios) relative to lenses that need you to stay far from the subject.

Fixed lens camera focal lengths can also be multiplied by the crop factor of the sensor in order to compare it across formats. This is generally only important if you’re trying to replicate a look across focal lengths; i.e. you know you want a 135mm full-frame portrait style.

The main advantage of testing in small regions is really… your patience. If you have to wait 5-10 minutes per iteration, most people will get annoyed and tired of waiting, and will test fewer times. Testing in small regions is not an excuse to not check your results after running it on the full region, but it should allow you to quickly adjust variables and do a fairly good job of creating a useful cell detection algorithm in a short time. Provided the areas represent a good cross section of the different types of tissue areas.

Super telephoto lenses have very different focal lengths, ranging from 300mm and beyond. When considering focal length and field of view, crop factor is incredibly important because you can gain significant amounts of reach using a crop sensor like Micro 4/3rds.

After clicking Apply, I can see that very few cells changed class, but I can be more confident that a weirdly extreme measurement in other tissue slices will not throw off the classifier. Finally, I need to name (in this case, Elongated cells) and Save the classifier so that I can use that in my script via the Workflow.

Ideally, generating training data like this should be handled by a pathologist or biologist who understands the project and what they are looking for. Communication between the biologist and the QuPather (unless they are the same person) is KEY here, as the biologist may not realize the measurement they want does not exist in the cell's list of measurements. For example, if the biologist was classifying tightly clustered cells as one particular cell type, their classifier may fail for that cell type unless a "distance to nearest cell" measurement was added using the Analyze->Spatial analysis menu. In some cases, the nuclear/cytoplasmic ratio can be used, but only if the cells are tightly enough packed that their cytoplasmic expansion is blocked.In the cases where a known or obvious feature is necessary to determine a class of cell (KI-67 nuclear staining for a KI-67 positive cell), machine learning classifiers should be avoided in place of single feature classifiers.

Focal length also relates to field of view (also called angle of view) because changing the focal length changes the field of view – I’ll explain more about how the field of view and focal length of a lens interact with each other in greater detail below.

Hello Dan! I’m Mariam from Mauritius. I wanted to thank you for this deep explanation on focal length! I just bought my first camera and your article helped me so much!

After selecting Live update, I follow a similar procedure to the pixel classifier. I open up View->Show log and try to determine what unnecessary measurements I can eliminate. From the look of the log, it is using pretty much the measurements I would expect to detect elongated cells; all of the top measurements are shape related. As such, I will use the Selected features option to remove all staining information. I do this by clicking the Select button, then clicking Select all in the dialog box that shows up. Next I type “OD” into the filter, and click the Select none button to unselect all Optical Density based measurements. If I delete the text in the Filter, I can see that only the shape measurements remain. I will repeat this process with “Cell”, as the only real shape information I have is the nuclear shape, and I want the classifier to focus on that.

Yet another warning, but it is important to make sure the number of training objects you include exceeds the number of features you use to train the classifier. I have hopefully stated this elsewhere, but it is too easy for the software to find patterns in the data. If enough completely random measurements are generated, the classifier will be able to find one of those random measurements that fits your training data. This kind of error becomes less and less likely as long as you have more training data than measurements. Too much training data, on the other hand, can risk saturating your machine learning classifier. How much is too much or too little will depend on the number of features, the type of classifier, and the amount of variation in your training data classes.

If your classifier is a bit more complicated, with rare phenotypes, I strongly recommend looking into Sara McCardle's Rare Cell Fetcher script, which will jump from cell to cell of the selected class, and allow you to correct them much more quickly than manually scanning around a large piece of tissue with potentially millions of cells. Do make sure to read up on the specifics of how the script functions with regards to annotations and how it creates training objects!

Focal length in photography comes up far more often than focal distance, which is an entirely different property of a lens. Focal distance is related to focal length but is not dependent on it.

These super long focal lengths are usually more expensive but they allow to capture subjects from a very far distance like in sports and wildlife photography, and to shoot other genres like deep astrophotography.

Hopefully, this article on explaining focal length has clarified some of the stickier aspects of the topic. Especially where they affect wide, normal, and telephoto fields of view.

Normal or standard lenses have a focal length between 35mm and 50mm in full-frame terms. When comparing across formats, they have a field of view that’s also equivalent to a normal lens. These lenses best duplicate how we see the world.

The angle of view in photography is the area of the scene that is captured by the camera sensor. This area is described in degrees of coverage in front of the camera.

Live update: Once you hit Live update, the classes of your cells or other objects are changed. This is not a preview like many of the other options, here you are actually changing the class of your objects. The intention is that you will continue to add new training data or otherwise adjust the classifier in order to get the results you want, then either save the classifier or finish with the dialog box.

Camera zoom lenses allows to change the angle of view without moving and are more versatile than prime lenses. The downside is that maximum apertures are not usually as fast as the fastest prime lenses. For example, an f/1.4 zoom would be ridiculously expensive and massive.

Lens focal length is a surprisingly nuanced topic! A simple physical measurement leads to so many considerations that go into how an image is composed. From the angle of view to depth of field, no aspect of a photograph goes untouched.

So what are the mm in lenses? The key is to understand that focal length is calculated by measuring the distance from the optical center of the lens to the image sensor, and this distance is measured in mm. The longer the focal length, the physically longer the lens will be. Lenses with a wider view will have a shorter focal length and are physically shorter by comparison.