Jump to content
You must now use your email address to sign in [click for more info] ×

Stacking two photo's : wrong mathematics ?!


Recommended Posts

Stacking two photo's in Affinity Photo, I get different results between 'mean' and 'median'.

Which really surprises me since with two samples the mean and median mathematically have the same outcome, while in Affinity the respective results differ a lot !

I would have expected same results in Affinity Photo. What's going (wr)on(g) ?

Link to comment
Share on other sites

Interesting. Looking at the docs, it suggests that median removes content that is not consistent in each image - suitable for object removal and noise reduction. So I wonder if there's some extra calculations in play there that makes it more suitable for that. I expect they've taken a median calculation and expanded it to suit that purpose? I'm only guessing though. Not sure how it could really work properly with two images.

Link to comment
Share on other sites

It’s an interesting question.
If there are only two images and a pixel is ‘different’ (however it measures this) in each/either, how does Photo decide which one is the ‘inconsistent’ one of the two? They are both inconsistent with each other wherever the pixels are different so I would expect a function which “removes pixel content that is not consistent in each image” to leave lots of holes in the result where the differences were.

Link to comment
Share on other sites

So working with three images whereby I've loaded the same image twice and then chosen a different image and put them into a stack, the median does exactly as you'd expect and disregards the image that is different. However, hiding one of the duplicated images, leaving just two images that are different seems to reveal a picture whereby some pixels are selected from one image and some from the other almost like there's some weird masking taking place (which is kind of expected to some degree). So it looks like it's choosing one or the other image to show for each pixel. How it's deciding that I'm not sure, but a true mathmatical median should be taking into account that there's an odd or even number of samples, and if it's even, taking the two middle ones and doing a mean between those to arrive at the result. Would that be useful from an imaging point of view? I'm not too sure, but it's kind of interesting what is happening - could be useful as an effect maybe?

Link to comment
Share on other sites

2 hours ago, GarryP said:

It’s an interesting question.
If there are only two images and a pixel is ‘different’ (however it measures this) in each/either, how does Photo decide which one is the ‘inconsistent’ one of the two? They are both inconsistent with each other wherever the pixels are different so I would expect a function which “removes pixel content that is not consistent in each image” to leave lots of holes in the result where the differences were.

With even number of images the median should be calculated as the mean of the two middle observations, which Affinity apparently does not. Curious how Affinity calculates the median when even number of images is stacked...

Agree with you suggestion: next to the 'outlier' stack operator a 'remove outlier' stack operator should be more than welcome.

Link to comment
Share on other sites

On 12/3/2019 at 9:50 AM, Maarten Langeveld said:

Curious how Affinity calculates the median when even number of images is stacked...

For something really curious, try duplicating an experiment I did with the simplest set of test files I could think of: two greyscale 8bit PNG files, each consisting of 2 pixel-aligned vertical stripes, one of which is 100% white & the other 100% black. The only difference between the two files is one is the mirror image of the other. Compare the Info panel results for the mean (on the left) & median (on the right) operators:

mean.jpg.ac05d641ca82d0c9f688cb13251eb587.jpg median.jpg.31b4bda83cb729332914062cf670034c.jpg

Assuming I did not do anything stupid (always a possibility), both should result in K values of exactly 50% ... but neither one does. O.o

If you want to check my work, Black & White.zip includes the 2 png files (Black-white.png & White-black.png) plus the .afphoto stack file (Black & White Stack.afphoto).

All 3 1.10.8, & all 3 V2.4.1 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo 
1.10.8; Affinity Designer 1.108; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.