Does modifying the contrast of an image change the dynamic range of a photograph?
Does it make it better quality?
Depends on what you are referring to.
Increasing the contrast
using an image editor software means making the darks darker and the brights brighter, and decreasing means the other way around. Increasing the contrast will cause loss of details since you won't be able to distinguish one tone from another as well as you could before you made them darker or brighter, and decreasing might give you more details, depending on your camera's or film's dynamic range and some other factors (I'll explain it later). On the other hand, increasing the contrast might make your images more vivid, whereas decreasing it might make them more dull:
On the image above, the middle one is the original, the left one is with decreased contrast (notice how it is more dull) and the one in the right has increased contrast (more vivid). You can clearly see a loss in detail on the one in the right, with increased contrast, whereas there really isn't any gain in details in the one in the left. Why? For two reasons:
Dynamic Range
I used a cheap film to take that picture, it does not have a good dynamic range, i.e. there wasn't much of a difference between the darkest and the brightest tones to start with. The same is usually valid to cheap digital cameras.
The editing process (most important!)
I edited that picture with an image editing software, after it was already processed and developed, which is the equivalent of editing a JPEG instead of a RAW if you shoot digital. What you are doing is editing what was somehow already edited by the lab guy or by the camera's software, it's like trying to change the colors of a painting that was already painted.
On the other hand, if your camera / film has a good dynamic range and you do your magic while developing the film or if you edit RAW, you can gain a lot of details by decreasing the contrast and messing around with some other lightning settings - the dynamic range is set by your camera/film, but you can mess around with it, paying the price for it, which is loss/gain in details for gain/loss in vivid tones. I can't develop the picture again, but I edited only certain areas of it to simulate it:
You can clearly see in the sky and buildings (brighter tones) that I gained a lot of details by decreasing the contrast and messing with some other lightning settings.
Dynamic range of an image (as opposed to an image sensor) is simply the ratio between the brightest and darkest pixel values. An image of fixed bit depth thus has a fixed maximum dynamic range.
Increasing contrast will increase the dynamic range but only up to the maximum possible given the bit depth.
Whether or not increasing contrast will improve an image depends on many factors. More contrast will make an image bolder, more striking, but too much contrast can destroy an image and leave it looking distinctly "unreal". A low contrast image will invoke different feelings and there are times when this is more appropriate.
Here's an image which I decided looked better with a lower overall contrast:
First rough edit.
Final version.
Does modifying the contrast of an image change the dynamic range of a photograph?
No.
Does it make it better quality?
Yes (sort of), if the original image was underexposed or overexposed or the subject has a bland coloration.
Explanation
To understand the issue, let's imagine we have a very simple monochrome 4-bit camera. This camera's sensors can only store gray-scale images with each pixel having a value between 0-15. You have 16 levels of gray and that's it.
What happens when we increase the contrast of an image with this camera?
Let's say some of the pixels in our image have the following values:
8, 9, 9, 11, 10, 10, 12, 12, 12, 5, 5
A B C D E F G H I J K <-- pixel labels
When we increase contrast we spread these values out. So, first we must choose a center point, say 10. Then, every pixel that is lower than ten gets decreased and higher than 10 gets increased. So our new image might look like this:
6, 8, 8, 12, 10, 10, 14, 14, 14, 1, 1
A B C D E F G H I J K <-- pixel labels
So, the 10 stays the same, but the other values spread out. The benefit of this is that if the difference between 9 and 10 was hard to see in the original print, then now it is more visible since 9 has been converted to 8. So, the difference between pixels C and E, or D and E is greater and easier to see.
For this reason if you have image in which all the values are close together, details can become easier to see in the print.
Notice that you can lose information when you adjust the contrast. For example, let's say you have values of 0 and 1 in your image and the 1's all get changed to 0. Then pixels that were originally different levels of gray are now the same. So, if your original 4-bit image had all its values, say, in the 8-12 level range, then you are safe increasing the contrast. But if your recorded values include all possibilities 0 to 15, then you will lose detail when you increase the contrast.
So, you potentially lose detail, but you make the detail that remains easier to see.
Nowadays, people often talk about dynamic range as the difference between the lightest and darkest areas of the image, and have invented the term "tonal range" to mean the number of discrete measurable values. However, for a photographer the tonal range is the key sensor quality metric, so when we talk about "dynamic range", it is better to think of it as the ability to discriminate between different levels of hue, saturation and brightness. So, while that does include the difference between blacks and whites, it is a lot more than that. Roughly speaking, the dynamic range (or tonal range) is equivalent to the different possible levels of the pixels. So, for example, an 8-bit sensor will usually produce images with greater dynamic range than an 4-bit sensor, other things being equal.
Note that increasing contrast does not increase the dynamic range of an image because you are not increasing the ability to discriminate between different gray levels in the original image. So, in the example above, we change all the 9's to 8's, but that means all the 9's are now gone. In other words, lets say our original image had only 3 different levels: 9, 10, and 11. If we change those to 8, 10, and 12, we still only have 3 different levels. Now, imagine we took the same picture with a more sensitive camera and it gave values: 8, 9, 10, 11, 12. So, we see this camera has 5 different levels, so it has greater dynamic range.
I think you're looking for a short answer here.
Increasing contrast makes the lights lighter and the darks darker. (Expansion)
Reducing it bring everything closer together in brightness. (Compression)
If you're asking if it can bring back detail that was lost while taking the photo, no.
Can it make some details that are too dark or light more visible, yes but it's a poor way to do as it makes everything look pretty flat if done with a simple slider.