Post Reply 

How to fix these photographs

Mar 1, 2014, 21:45
Post: #1
How to fix these photographs
I have thousands of photographs taken with a cheap camera.

The camera had problems with high contrast images. Most photos had clouds and tree shadows.

The problem is that the clouds look wallpaper white, meanwhile the shadows look totally black.

The images have the information hidden in subtle tonalities of white and black, so I need to enhance the contrast of skies and shadows, without ruining the rest of the photo.

I think that I should identify the pixels with high values of R, G, and B. Those are the whitest, and then I should interpolate those pixels into a higher contrast.

I should do the same with the blacks, which should be pixels with low quantity of R, G, and B.

I’m planning to write code with Visual Studio, to process all the images, but I hope that I can do this work with Gimp.

There is a way to do this with Gimp?

Here are examples of my images:

These two are taken exactly with the same procedure, and the camera took two different photgraps. It shows how the clouds had grey tones and contrast, but the sky looks white on one photo, and the building looks too dark on the other:

[Image: 2dl2m8j.jpg]
[Image: rr5pgp.jpg]

This is a typical image: too white clouds, and too dark forest:

[Image: w1agdj.jpg]

This one looks black on the trees. I wish to have better constrast for the trees.

[Image: 14v4f0l.jpg]

This one is too white in the background, and too dark under the trees:

[Image: hsqm4l.jpg]

Here is another pair of photograps taken separated by one second. It shows how the clouds were deleted into an homogeneous white by the camera:

[Image: 9kz5zq.jpg]
[Image: tz252.jpg]

(I do not have pair of photograps for every photo, so I need to rely on the information stored on each single photo).
Find all posts by this user
Quote this message in a reply
Mar 1, 2014, 22:27
Post: #2
RE: How to fix these photographs
In most pictures your whites are utterly blown out and there is little to recover. There is indeed some hope for the dark trees with the back light.

[attachment=3126]

The second and third picture are correctly exposed for me. The whites in the building are blown out in the first.

In one of you picture there is so much purple-fringing that wouldn't even bother.

As an amateur photographer (who has done his share of photo tweaking) and professional programmer, I seriously doubt that you can come up with a piece of software that will fix all your photos. Each photo is its own problem There are choices to be made that you cannot realistically leave to software.

You should also reconsider how you work. I don't take thousands of pictures to discover later than they are all worthless. All camera have a "histogram" display, checking it after taking the picture is a minimum. Cameras don't do miracles, despite all the automation, you still have to know when and how to take the pictures.

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Mar 1, 2014, 23:57 (This post was last modified: Mar 2, 2014 00:16 by buxcador.)
Post: #3
RE: How to fix these photographs
(Mar 1, 2014 22:27)ofnuts Wrote:  In most pictures your whites are utterly blown out and there is little to recover. There is indeed some hope for the dark trees with the back light.
¿How you did that?

I do not know Gimp, but I'm a programmer, and I made some image making software (maps), so I know something about pixels.

(Mar 1, 2014 22:27)ofnuts Wrote:  The second and third picture are correctly exposed for me. The whites in the building are blown out in the first.
The last two images show how the clouds were deleted to a white image. The first two images show the same thing: clouds should look as in the penultimate image...

(Mar 1, 2014 22:27)ofnuts Wrote:  As an amateur photographer (who has done his share of photo tweaking) and professional programmer, I seriously doubt that you can come up with a piece of software that will fix all your photos. Each photo is its own problem There are choices to be made that you cannot realistically leave to software.
That's discouraging, but surely I can fix the images at least a bit.

I hope that I can enhance the photos to some degree.

(Mar 1, 2014 22:27)ofnuts Wrote:  You should also reconsider how you work. I don't take thousands of pictures to discover later than they are all worthless. All camera have a "histogram" display, checking it after taking the picture is a minimum. Cameras don't do miracles, despite all the automation, you still have to know when and how to take the pictures.
Oh, this is no "work". Those are the photographs I took on my vacations. And I'm a totally amateur photographer.

The camera was a cheap Nikon Coolpix. A total piece of garbage.
There was little under my control. I could not even control focus. At best I pointed the camera to a dark or white spot, (so it automatically regulated), and rapiddly aimed the camera to my objective and made the shoot.

That's how I achieved the last two images with different light intensity. That's better than what the camera did by itself when I tried to take these shots.

I threw away lots of blurred, overexposed, and underexposed photos.

I do not know what a camera/photo histogram is, and the camera had nothing of that, but I know what a Fourier transform is. So I suposse that an histogram should be a frequency distribution.
Find all posts by this user
Quote this message in a reply
Mar 2, 2014, 00:11
Post: #4
RE: How to fix these photographs
I suposse that I will end making my own code. So I will like advice on that.

To this point I plan to measure "blackness" and "Whiteness" by taking the cube root of the product of R, G, and B. (I think that these file format should be made of a byte for each R, G, and B channels. I do not expect an alpha chanell).

And I think that the non white pixels should have low values for some channel, so the cube root will give a low value.

Actually, instead of R, G, and B I should take (|R-128|.|G-128|.|B-128|)^(1/3)

Based on that parameter, I should apply a correction on the R,G,and B channels using something like this:

[Image: 29m37r7.png]
Find all posts by this user
Quote this message in a reply
Mar 2, 2014, 00:40 (This post was last modified: Mar 2, 2014 00:42 by ofnuts.)
Post: #5
RE: How to fix these photographs
(Mar 1, 2014 23:57)buxcador Wrote:  ¿How you did that?
- Color Selection (using large threshold and selection only on "Value") to select the dark bark
- Then extend and blur the selection a bit (Select/Grow, Select/Feather)
- Then use the curves tool to lighten the dark bits.

If you don't know how to do that with software like Gimp, your chances of making a program that can do it are very slim.

(Mar 1, 2014 23:57)buxcador Wrote:  I do not know Gimp, but I'm a programmer, and I made some image making software (maps), so I know something about pixels.

It's not a problem of pixels, it"s a problem of image processing and rendering. Plenty of small details to care about to get an acceptable result. Gimp source code is available. Have a look Smile

(Mar 1, 2014 23:57)buxcador Wrote:  The last two images show how the clouds were deleted to a white image. The first two images show the same thing: clouds should look as in the penultimate image...

The information is lost... you best bet is to transplant a new sky from another picture.

(Mar 1, 2014 23:57)buxcador Wrote:  That's discouraging, but surely I can fix the images at least a bit.

I hope that I can enhance the photos to some degree.

You can fix some images, but this is some work, especially if you aren't familiar with the software. You are never going to fix your thousands of images (even if these are only hundreds). Even if it takes you 5 minutes per image, one thousand images=5000 minutes=83 hours, or 10 very busy days or one hour every day for three months.

Select the dozen more important/less defective photos and improve them.

(Mar 1, 2014 23:57)buxcador Wrote:  Oh, this is no "work". Those are the photographs I took on my vacations. And I'm a totally amateur photographer.

By work I mean 'take pictures'.

(Mar 1, 2014 23:57)buxcador Wrote:  The camera was a cheap Canon Coolpix.
There was little under my control. I could not even control focus. At best I pointed the camera to a dark or white spot, (so it automatically regulated), and rapiddly aimed the camera to my objective and made the shoot.

That's how I achieved the last two images with different light intensity. That's better than what the camera did by itself wen I tried to take these shots.

A more expensive camera would have given roughly the same results. You are asking the camera to take pictures that are well beyond its dynamic range.

(Mar 1, 2014 23:57)buxcador Wrote:  I threw away lots of blurred, overexposed, and underexposed photos.

Too bad. The underexposed pictures are the easiest to fix. In fact the usual technique to reduce the chances of blown out lights is to set the camera to underexpose by .5 to 1EV. It's easier to fix underexposed darks afterwards than to recover lost lights.

(Mar 1, 2014 23:57)buxcador Wrote:  I do not know what a camera/photo histogram is, and the camera had nothing of that, but I know what a Fourier transform is. So I suposse that an histogram should be a frequency distribution.

No, the X axis is the luminosity of the pixels, and the Y axis is the count of pixels with that luminosity.

See the [http://docs.gimp.org/2.8/en/gimp-histogram-dialog.html]histogram dialog[/url] in Gimp, it's exactly the same. All cameras have this display. The cheapest Canon cameras currently sold (Ixus 132) have one. See this user manual page 72 (even without your user manual you can likely obtain it by pressing the "display" button while taking the picture or when reviewing it after the shot).

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Mar 2, 2014, 11:11
Post: #6
RE: How to fix these photographs
I'm willing to bet you have a modern point & shoot camera, even if it is cheap.

Most point & shoots have the ability to lock exposure/auto-focus on a half button press as well as the hovering over your subject.

Preventive (in-camera) measures:
Take more than one instance of your scene, *but first
Hover around the scene and notice how the light changes, when the is darkest, hold the shutter button halfway down for a second, then push it all the way down to take the picture.

Next, hover the camera around a little until you find where the buildings / foreground get brighter or look more normal (not so dark / shadow)
-Then halfway push the shutter button again to lock the exposure,

* when its pressed halfway, you can move the camera around the scene and the lighting shouldn't change much.

Exposure:
Also, In the camera,
check if you can adjust the exposure (how much light comes into the camera)
The range/setting will look something like
Code:
[-] -0.2 -0.1 0.0 +1.0 +2.0 [+]

Last, if after trying above, the blown out sky is still unavoidable, you want the curves tool "value" setting similar to the screenshot below.
   

You'll want to select the sky first if you don't want the rest of the image affected.

In my second screenshot, I found sky data in 2 of your photos (besides the 3rd visible one of the restaurant)
To quickly select the sky;
1.Duplicate your image layer
- Colors > Threshold (to simplify for background(sky) & foreground(brush/buildings) selection)
Adjust the black triangle in the Threshold window until you have the foreground mostly to all black(like silhouette), click ok.
2. Click the white part (sky) on the threshold layer with the select by color tool Bycolorselect
3. Move the threshold layer under all the layers in the layers window.
4. Copy & "Edit > Paste as > New layer...

5. Then you can apply the curves.
   

"In order to succeed, your desire for success should be greater than fear of failure." BC
[Image: 29uocaf.png]
iFS007 tut vids on YT ~ auto color B&W landscape tut
Visit this user's website Find all posts by this user
Quote this message in a reply
Mar 2, 2014, 12:30
Post: #7
RE: How to fix these photographs
(Mar 2, 2014 00:11)buxcador Wrote:  I suposse that I will end making my own code. So I will like advice on that.

To this point I plan to measure "blackness" and "Whiteness" by taking the cube root of the product of R, G, and B. (I think that these file format should be made of a byte for each R, G, and B channels. I do not expect an alpha chanell).

And I think that the non white pixels should have low values for some channel, so the cube root will give a low value.

Actually, instead of R, G, and B I should take (|R-128|.|G-128|.|B-128|)^(1/3)

Based on that parameter, I should apply a correction on the R,G,and B channels using something like this:

[Image: 29m37r7.png]

That's what I meant when I said you don't write photo processing code without a bit of know-how Smile
  • map your 0->255 values to 0.->1.
  • the luminosity of a spot is indeed the composition of the RGB values, but with coefficients for each channels (we are more sensitive to green). Look up the actual coefficients searching for "HSV and HSL" on Wikipedia).
  • are you working in "linear light" or in "corrected light" (taking the gamma in account)?
  • the kind of curve that you plan to apply to all your pictures has the following problem:
    • will not fix your blown-out skies (an area where all pixels are at 100% will still be an area where all pixels are at 100%)
    • it will ruin the sky in pictures where is is acceptable
    • it will ruin the darks in picture where they are acceptable
    • it will reduce contrast in all your pictures
Here is the curve I used for your trees:
  • Since I made a selection on the trees and their immediate vicinity it doesn't apply to the rest of the picture (in particular it leaves the sky alone)
  • it changes only the dark tones
  • its slope in the middle tones means the original contrast is kept

But each of your pictures will require the application of one or more selection plus the appropriate curve.

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Oct 1, 2014, 19:20
Post: #8
RE: How to fix these photographs
I tried using my procedure from http://gimpforums.com/thread-removing-flash-glare for two images and I came with this:

Photo 1:
   

Photo 2:
   

Blur for gaussian blur you calculated from the site which I mention in the post.
When you play with levels be carefull. Don't do Auto Levels. Instead of this, set it to each cannel (red, green, blue) on the value layer (it's important!) and play with the gamma slider until you get correct image in this channel. When you do this, go to Value channel and first - set correct gamma. Finally play with other sliders on Value channel (pick black point and pick white point from output levels).

After do this you end up with the similar images which I presented in my post.

I corected hundreds images in this way and it's working for me. I hope for you too.
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Question How can I fix this? blueYOSHI 1 161 Aug 8, 2017 16:35
Last Post: paynekj
  Border less Printing Fix SportsPosterPros 7 521 Sep 10, 2014 12:27
Last Post: SportsPosterPros
Exclamation brush size slider FIX IT CaoMengde777 0 307 Jul 24, 2014 18:38
Last Post: CaoMengde777
  I found a bug with moving the layers and docable dialogs. How do I fix it? CopperZirconium 2 343 Jun 21, 2014 17:21
Last Post: CopperZirconium
  fix the edges and white in this image moltres_rider 4 597 Dec 28, 2013 11:27
Last Post: rich2005

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS