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) ?

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.

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.

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?

Share on other sites

Interesting... Good to know it works fine using three images. Keeps me wondering what happens when two images are used... Maybe Affinity developers can clarify on this?

Share on other sites

Loading a pair of images twice (4 images stacked : two same pairs) results in same error as with two different images. Mathematically the median should have same result as the mean which it does not with Affinity. Curious...

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.

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:

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

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.6, & all 3 V2.03 Mac apps; 2020 iMac 27"; 3.8GHz i7, Radeon Pro 5700, 32GB RAM; macOS 10.15.7
Affinity Photo
1.10.6; Affinity Designer 1.10.6; & all 3 V2 apps for iPad; 6th Generation iPad 32 GB; Apple Pencil; iPadOS 15.7

(...)

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×

• Affinity

×
• Create New...