Tag: contrast

Take advantage of selection tools in Photoshop

From all the native functionalities of any image processing software including Photoshop, the selection tools are definitely among the most important ones. For instance, when talking about brightness, the only reason to make global adjustments is a wrongly exposed image from the camera. Most of the times, we will be interested in making local adjustments, for instance in contrast, brightness or color saturation.

While the main functionality when performing these adjustments in Photoshop are the adjustment layers, a clever use of the selection tools will facilitate the whole process.

The problem is that selecting exactly what we want is not always a straightforward or easy process. The different smart selection tools that Photoshop provides take advantage of sharp changes in image properties such as color or brightness.

However, the images we are dealing with and, more specifically, the regions within those images where we want to apply those local adjustments not always have the gradients necessary to make the selection process a clean and simple one. Take, for instance, this image of the Parliament in Budapest, Hungary.


While the photo is relatively well exposed, the sky is a bit overexposed while the foreground is a bit dark. This leads to a loss of details and color contrast. The fact that the sky is not completely overexposed means that detail can still be extracted without the need to combine the photo with a darker one by means of a blending or HDR process. This is usually something desirable, since while blending two images can help achieve a great result, using a single one can significantly simplify the whole process.

As I just mentioned, having structure on the sky means that we can use one of the many selection tools available in Photoshop to select the sky, reduce the brightness and increase the contrast in order to better balance the whole image. However, the same structure that will help us achieve the desired result will make the selection process a non trivial one. As an example, the following image shows the result of applying the ‘Magic Wand Tool’ with a tolerance of 50, which is a rather high value.


In order to select the whole sky, it is necessary to recursively apply the tool to capture the different sections of the sky, something that can be problematic, specially when coming close to the skyline (where the sky meets the buildings).

Since the selection tools rely on rapid changes in contrast, we can take advantage of this by artificially increasing or decreasing the contrast between the different regions of the image, depending on what we want to achieve. The first step in this process is to duplicate our base layer twice and convert the top layer to black and white.


The reason for doing this is that black and white images have larger contrast than color images by definition. From the three layers, the base one is there to preserve the original image, the middle one will become our contrast-corrected color image and the top one is going to serve as a mask to make the selection process an easier one.

The next step is then to increase the contrast of our top layer until the sky is almost completely white and the foreground is almost completely dark. To increase the contrast you can go to ‘Image -> Adjustments -> Brightness/Contrast…’ and simply move the ‘Contrast’ slider to the right. Since you want to dramatically increase the contrast, you will most probably need to repeat this step several times taking the slider to its maximum value.

Pro Tip – Use photoshop vintage effect to create retro-style photos

Another option that will allow you to avoid repeating the same step several times is to create a ‘Levels’ layer over the top layer. Then you need to move the left slider to the right until the foreground becomes almost completely black and the right slider to the left until the sky becomes almost completely white. The most important part of the image is the skyline, so don’t worry too much if not all the sky turns white or the foreground black.


By looking at the image above, it is already evident that the selection process will be much simpler than before. In fact, we can now use the selection by color, given that the difference in color between the top and the bottom parts is remarkable. For this, go to ‘Select -> Color Range…’. Depending on your image, you can adjust the ‘Fuzziness’ to allow the tool to select a wider or narrower range of colors. For our image of the Parliament, since the foreground is noticeably darker than the sky, we can increase the Fuzziness to its maximum value and then select the sky. The following image shows the result of the selection process.


Now the selection cleanly follows the skyline. If there are some spots that were selected in the dark region, you can remove them from the selection using the rectangular selection tool while pressing the ‘Alt’ key.

With this selection, hide the two top layers and select the second layer while keeping the selection (you can save the selection if you want in case you loose it by mistake). Next you can make the adjustments you want and they will only be applied to the sky. Also, by inverting the selection, you can apply changes to the foreground. For the next image, I increased the contrast and decreased the brightness on the sky and increased the brightness on the foreground.


The image looks much more balanced now, but if you look closely, some parts of the skyline look strange, specially the top left corner of the Parliament building. This is because the selection in that region was not perfect because the sky  is a bit darker than on the rest of the image. The easiest way to correct this is to apply a layer mask and mask the top layer in those regions with a low opacity (around 25%).


For the final image, I applied a vignette to help the building stand out. As you have seen, the selection process can be simplified by just adjusting the contrast of a layer that is used only for the selection process. While this process might not be suitable for every image (specially when the contrast between the two regions that want to be adjusted is too low from the beginning), for some images it can produce smooth results and will certainly speed up the whole process.

If you have any questions regarding the contents of this post, just write me an email and I will be happy to help you.

Histograms – From your camera to Photoshop

In this post I want to take a detailed look at one of the most basic tools used in image processing and that is sometimes overlooked by photographers. I am talking about histograms, an incredible useful way of looking at the data contained in an image that can give a lot of information both during the capture of an image with your camera and during the post-processing using an image processing software such as Photoshop.

What Is a Histogram in Photography?

But let’s first take a look at what a histogram is. A histogram is a graphical representation of any type of information, it does not have to be an image. In formal terms, a histogram is a bar plot that represents the number of occurrences (y-axis) of a given event (x-axis). This could be, for instance, the number of people with a given age within a group. Imagine, for instance, a photography club where the members have different ages as follows:

  • 20 years old: 3 members
  • 21 years old: 1 member
  • 22 years old: 1 member
  • 23 years old: 4 members
  • 24 years old: 1 member
  • 25 years old: 6 members
  • 26 years old: 0 members
  • 27 years old: 2 members

A histogram representing the values above would look like the following figure.

hist1You can see the age range represented on the x-axis and the number of members with a given age on the y-axis. This way of presenting the information is very simple and easy to interpret and hence the widespread use of histograms in all branches of data analysis.

When talking about photography, the x-axis will represent the intensity or brightness (which can go from 0 to 255 on an 8-bit image) and the y-axis will represent the number of pixels with that given brightness. In the case of a grayscale image, a single histogram contains all the information of the image while in the case of a color image three separate histograms are needed, one for each of the basic colors.

Notice that given an image, a histogram can be constructed, but given a histogram, an image cannot be constructed. In other words, when a histogram is created, important information is lost and thus histograms cannot be used as compressing algorithms. This is because the histogram tells us how many pixels have a given brightness level, but it does not give any information on the location of those pixels within the image.

So what information can we get from a histogram? This is related to a rule of thumb according to which the more spread among all values a histogram is (i.e. flat) the more balanced the image will be. Now, when applying this rule, you need to take into account what type of image you are dealing with.

Take, for instance, the following black and white image of the Charles Bridge in Prague together with the histogram (highlighted with a red rectangle) as shown in Photoshop.


There are a couple of things that we can learn from this image. First of all, the scene looks rather dark, and that is why almost all the pixels are on the lower (leftmost) half of the histogram. The histogram is ordered from left to right, with the darkest value (0) on the left and the brightest one (255 when working with an 8-bit image) on the right.

In addition to this overall distribution of the brightness values, it is also noticeable that there are two main peaks with a valley in between. In this particular image, the reason for these two peaks is that both the water and the bridge itself are rather dark while the rest of the buildings and the overcast sky are lighter. This means that the scene itself lacks of mid tones and hence the gap in the histogram.

If we improve the image by increasing the brightness and the contrast, we end up with a much flatter histogram that also covers a wider range of brightness values.


Now you can see how the center of the bulk of pixels moved to the right and it lies much closer to the center of the histogram. At the same time (and as a consequence of this), the image looks much more balanced than before.

If you look closely to the histogram, especially on darkest pixels, you can see that the bars are now much more disperse than before with a lot of variations and low values intertwined with high values. This is actually a consequence of the algorithm used to increase the contrast in Photoshop, which is similar to a histogram equalization.

Now, what happens if your image was intended to be dark? Good photos are not necessarily those that comply with all the rules known like for instance a flat histogram, completely in-focus or well balanced in colors. After all, that is why automatic modes do not always produce the images we are looking for.

The image below, once again from Prague, is a backlit scene that was intended to be dark in order to create a high contrast photo as a result.


Notice how the histogram shows most of the pixels on the left side with a relatively high peak on the far right side. This is the result of having the Sun on the image which, even though small, is very bright while the rest of the scene is underexposed to capture the silhouettes and shadows. Trying to get a flatter histogram with this image would render a completely different (and unwanted) result.

Finally, the image below, from the Red Square in Moscow, is a much more balanced one, something the is reflected on a histogram centered at the mid tones. Even though there is a high concentration of pixels on the middle, the overall distribution is symmetric and has a good coverage of all the values without getting into the extremes (under or overexposed areas). This is also a natural consequence of the scene being captured, with no strong shadows or light sources included.


Notice that even though this is a color image, the histogram I am showing is the luminosity one. This is because what we are interested on here is the exposure balance of the picture, so the full color histogram will not yield any useful information for our purposes.

As you can see, in general, the use of a histogram can be very useful, but you need to get used to the particularities of each image in order to correctly read it. When capturing an image, it is useful to look at the histogram for a couple of reasons. First, the back screen of your camera can be brighter or darker than the average monitor. This means that you could get disappointed when you get back home and open your images with your computer. Also, if the ambient light is too strong, the contrast of the camera screen might no be good enough to distinguish whether your image is properly exposed or not. However, a histogram will always be visible and, as long as you stay away from the extremes (unless that’s your intention!), once you get back home you will at least be able to do a good job with post-processing, since your image will not have completely dark or burnt out areas.

Something similar goes with post-processing. No matter how bright or dark your monitor is, looking at the histogram will always give you an objective assessment of the exposure of your final image. This way you will avoid the problem of publishing a photo that looks too dark or too bright in other people’s monitors.

I hope this post was useful to you. Next time you are out making photos, look at the histograms of the photos that you take and I am sure that with some time you will incorporate this great tool in your workflow. And as usual, if you have any question, just write me an email!