Can't find a way to separate from background

First of all, there may be some focus issues, please don’t worry about that, this tree is nearby and I can easily reshoot (and plan to do so).

I’m trying to separate the tree from the background. My Olympus lens is a kit lens, 14-42 f/4.0-5.6, so the depth of focus is deeper than a pro lens at f/2.8 and so, it is difficult to use focus to separate the tree in from the background by that means. Another problem has been that when there is light on the tree, there also is light in the background (and visa versa) so it’s difficult to use that to separate them. Using darktable, I’ve tried using the green in the background (there also is a bit of green on lichen on a couple of the branches so both a parametric and drawn mask was necessary) but I haven’t got that to work very well either.

My wish for this image is (1) black and white, (2) highlight the shape and texture of the tree while diminishing the background but I don’t mind the texture of the leaf litter on the ground in front of it, that can be kept as well.

Maybe I need to photograph it differently and that is open for discussion as well.

Please show me what you can do!

2021_07_27_P7276024.orf (14.6 MB)

This file is licensed Creative Commons, By-Attribution, Share-Alike.

1 Like

separate.from.background.orf.xmp (10.8 KB) darktable 3.7

I think your friend here are masks. There’s enough colour separation (greens vs browns) to set up masks to work on the background (pushing it back) and work on the foreground (for highlight, shape and texture).

The above edit I made is a rather fast one to show you what I mean. I didn’t fine-tune this, also using drawn masks would probably help with the trouble areas.

Hope this gives you some handholds.


quick shot: colourrgb, select hue of background, tune luminance down:

Maybe a starting point for further editing. History in jpeg

1 Like

Using RawTherapee Dev, I started with one of my generic custom profiles.
Pop.pp3 (16.3 KB) (Note: this requires the Dev version)

I then applied a whole image spot to mask out the greens and applied negative dehaze and positive exposure compensation. In the Black and White tool, I used the channel mixer method and a green filter to further lighten the background. Finally I further tweaked the contrast with a variety of tools.
2021_07_27_P7276024-1.jpg.out.pp3 (19.5 KB)

This is much harder than I thought it to be, yet I still feel like the tree is not the main star, maybe using para mask is the right thing in this case.

2021_07_27_P7276024.orf.xmp (17.5 KB)
dartkable 3.7

About shooting it differently, how about including more prominent leading lines to direct viewer attention, and let more light shaft passing through. I think that deep focus and composition will work well together.

Thanks for sharing!

thanks for posting , I didn’t use masks but instead I desatured the green background and play with lighness using Color Zone module + and color calibration module

darktable 3.6

2021_07_27_P7276024_04.orf.xmp (11.8 KB)


I like this one. Instead of the more stark “foreground/background” that was asked for, you instead created many more degrees of depth. The “separation” is a consequence of that action, not the first thing you see.

Said differently, you have a scene where the eye sees a tree as part of a continuum, not “TREE” and “everything else”.

Nice edit.

RT-dev with some local adjustments.
2021_07_27_P7276024.orf.pp3 (35.9 KB)

1 Like

Try to photograph it under a cloudy sky or in light fog, for example in the morning, where light is not too dark but very diffuse.

Here is an attempt to imitate the “infrared”:

2021_07_27_P7276024_05.orf.xmp (13,5 KB)

darktable 3.7.0~git579.5c3444e43e-1


Make a greyscale that is 7*G - 3*R - 3*B. I like that result but, just for fun, use that to replace the L channel of a Lab version.

%DCRAW% -v -w -T -6 -O x.tiff 2021_07_27_P7276024.orf

magick ^
  x.tiff ^
  ( -clone 0 ^
    -separate -poly -3,1,7,1,-3,1 ^
    -write x2.tiff ^
  ) ^
  ( -clone 0 ^
    -colorspace Lab ^
    -channel 1,2 -separate ^
  ) ^
  -delete 0 ^
  -combine ^
  -set colorspace Lab ^
  -colorspace sRGB ^
  -quality 40 ^


Oh, yeah, and I like this one, 101*G - 50*R - 50*B:

Just for fun

I actually like the color shot too…

EDIT: It looks better without the little central branch to me??

Here’s my clumsy attempt:

2021_07_27_P7276024.orf.xmp (10.1 KB)

1 Like

My soot-and-snow version above, x4.tiff, can be used as a mask to blur the background (where the mask is white) and sharpen the foreground (where the mask is black).

For the blur, we use IM’s “-bilateral-blur”, an implementation of bilateral filter.

For the sharpen, we use that blur as an unsharp mask: sharp = 2 * input -1 * blur.

%IMG7%magick ^
  x.tiff ^
  ( +clone ^
    -bilateral-blur 19x19+49 ^
  ) ^
  ( -clone 0,1 ^
    -poly 2,1,-1,1 ^
  ) ^
  -delete 0 ^
  ( x4.tiff -negate ) ^
  -compose Over -composite ^
  -quality 40 c.jpg

I save it to a low-quality jpg because my internet upload speed is poor.

I didn’t find a sidecar in your jpeg; have I messed up?

You are right. Seems to be one of the rare cases when the development history won’t be stored as XMP tags within the output file (see manual darktable 3.6 user manual - export near “develop history”.) Didn’t check this.

Anyway, here is the xmp:
2021_07_27_P7276024.orf.xmp (10.5 KB)

1 Like

Dt 3.7
2021_07_27_P7276024.orf.xmp (13.9 KB)

edited on laptop

slightly croped

Cant find a way to separate from background_2021_07_27_P7276024.orf.xmp (17.7 KB)

1 Like

This would be my proposal.
Bearing in mind that shadows without relevant details can accept a deep black. The medium tones should be highlighted and the lighter parts more, because they are where all eyes will go.

2021_07_27_P7276024.orf.xmp (11.5 KB)


1 Like

It’s difficult to do this in post processing. My try.