Blend Median problem

Inspired by Pat David’s article [ ] about “removing people”
I made five pictures with four chess pieces. The pictures I opened as a layers in Gimp 2.10-Ubuntu 18.04.

Filters> Gmic> Layers>Blend median gave me a sixth image where I hoped that only two of the pieces would be visible.
However, an attentive viewer easily sees that the others remain as ghosts. Using ImageMagick with the terminal command:
“convert *.jpg -evaluate-sequence median OUT.jpg” gave the same result.

Of course I did something wrong, but what?

Hej Alf!

Just a swift idea: might it be that your different shots vary in white balance and exposure?

Have fun!
Claes in Lund, Sweden


Yes, clearly, this is due to luminosity variations between all your images.
If you try to ‘normalize’ them a little bit, before applying the median blending, then it works quite well:

$ gmic *.jpeg balance_gamma , blend_median o output.jpg


@David_Tschumperle and @Claes

Many thanks for your help. It was wonderful that it was possible to fix.

The images were taken with a Nikon D7500, ISO 400, f / 9.0 1/4 sec. White balance auto. I saw for myself now that one picture was significantly darker than the others.

Alf (Norrköping)

Hi, I’m trying same command but with tif files. At the end I get an almost white image, few red & yellow pixels in some cases.
[gmic]-15./ Apply gamma-corrected color balance of images [0,1,2,(…),12,13,14], with reference color (128).
[gmic]-15./ Blend images [0,1,2,(…),12,13,14] using ‘median’ mode.
[gmic]-1./ Output image [0] as tif file ‘test1.tif’, with pixel type ‘auto’, no compression and bigtiff support (1 image 4000x6000x1x3).
[gmic]-1./ End G’MIC interpreter.

If I do with the Gimp plug in it works well.

In fact I want to use averge all as it is working on Gimp Plugin when selecting input layers all.

Any idea what I could be doing wrong? Thanks in advance

@eadauto Welcome to the forum!

It has to do with how you are saving the image. Please share your command and two sample input files. Drag and drop the files.

Hi thanks!

This is the command, I will try to put 2 files in other format as when I put them on tif get really big (140MB)

c:\gmic\gmic.exe -input MDSC_0302_IT1.tif MDSC_0309_IT1.tif MDSC_0316_IT1.tif MDSC_0323_IT1.tif MDSC_0330_IT1.tif MDSC_0337_IT1.tif MDSC_0344_IT1.tif MDSC_0351_IT1.tif MDSC_0358_IT1.tif MDSC_0365_IT1.tif MDSC_0372_IT1.tif MDSC_0379_IT1.tif MDSC_0386_IT1.tif MDSC_0393_IT1.tif MDSC_0400_IT1.tif balance_gamma , blend_median -output test1.tif

Median requires at least 3 images. M(4,2,4)=4

Works for me. gmic med0.jpg med1.jpg balance_gamma , blend_median o med2.jpg

When you save the image, be sure you don’t clip it. E.g., if you do gmic med0.jpg med1.jpg balance_gamma , blend_median * 257 cut 0,255 o med2a.jpg, you get

Since I don’t have your original files, I can’t tell you exactly what to do. The above happens when you save something with a lower range than your data, or your image viewer doesn’t support the bit depth, and so the upper range is clipped.

@Reptorian You may have any number of input images.

Then I don’t get why use 2 images for blend median? What’s the median of two number? The average of them?

It would be an average of the two middle elements of a sorted list with an even number of elements. If there are only two values, then, yes, you would have their mean.

Oh, it seem like I was confusing mode for median for a while. I was fatigued during the last few days.

Np, we are here to help each other. Often, when my questions are answered, I realize how obvious it is.

Hi, I tried the same with jpg files I posted here and found that the issue is only if I try to save on tif format, if I try png, jpg it works fine. When I try tif it looks like the example you did to break it.
I removed the gamma and other options and it is the same, I guess I’m missing something on the output so tif can work fine.

gmic.exe -input MDSC_0302_IT1.jpg MDSC_0309_IT1.jpg -blend average -output test1.tif
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘MDSC_0302_IT1.jpg’ at position 0 (1 image 1365x2048x1x3).
[gmic]-1./ Input file ‘MDSC_0309_IT1.jpg’ at position 1 (1 image 1365x2048x1x3).
[gmic]-2./ Blend all images [0,1] together, using ‘average’ mode and opacity 1.
[gmic]-1./ Output image [0] as tif file ‘test1.tif’, with pixel type ‘auto’, no compression and bigtiff support (1 image 1365x2048x1x3).
[gmic]-1./ End G’MIC interpreter.

Here is the version:
[gmic]-0./ Start G’MIC interpreter.

gmic: GREYC’s Magic for Image Computing.

    Version 2.7.4
    Copyright (c) 2008-2019, David Tschumperle / GREYC Lab / CNRS.

[gmic]-0./ End G’MIC interpreter.

Will take a look to the link. Thanks a lot

I can’t reply just edit

Which G’MIC version (type gmic version) are you using? Also read about saving in the TIF format starting here: Astrophotography - Stacking images with GMIC command line.