Is it possible to find the maximum/minumum value pixel in an image

Supposing I have an image that is varying shades of gray. I would like to find the darkest pixel in the image and return that value

I would also like to find the brightest value, and return that.

Is this possible in the compositor?

The purpose is to do an manual normalization I want to subtract the darkest value (thus setting the darkest pixel to 0) And then divide by the brightest pixel (thus setting the brightest pixel to 1)

I know about the normalization node, but I want to use the values from one layer to normalize the other.

Any ideas?

Daren,

I think what you are trying to do is something that the famous visual effect artist/supervisor Steven Wright calls it gamma slamming. It is used by the industry to check if the your foreground shadow, gamma and highlights matched the background when compositing the layered images together. Try using the gamma node and adjust in the direction to get your dark pixels and white pixels. I can’t say which direction to adjust to node to it though.

Check these websites to find more information about it.

I
I hope this

I run into a similar situation last year when I was trying to come up with a way for denoising images.
I managed to isolate all the pixels which had high levels of noise but was unable to process them further in the compositor.
All the information I could gather (e.g. from Shake/Nuke) suggested that it was not directly possible in the compositor using nodes - or I could not figure out how to do it.
So in terms of what you’re asking, in principle it should be possible but only through scripting.

In fact if it is a single frame we’re talking about that’s easily doable in Python where you could parse through all channel values per pixel and determine the ones with the highest value.

@BrownEditor:
That’s not exactly what I was looking for, but those websites are awesome nonetheless! I found a lot of really useful info running around them

@Blendercomp:
you know what would be awesome? a Python node in the compositor. It’s like just a node, with a selection box. The selection box allows you to select a text file in the cache, then runs it. If Blender had that I could do amazing things, image processing was one of the areas I had a lot of experience in back as an undergraduate and my first job was working with the Landsat satellite fixing code for the satellite images.

Technically, it could be done by using the dilate function a thousand times then all pixels in the image should be equal to the brightest one, so you can just use a “Levels” node and the mean will also be the brightest

Repeat the process for the darkest (except with erode)

unfortunately, this is slower than molasses and it doesn’t need to be

I did play with this a bit and didn’t find any nice looking way, but here goes a very nasty setup that gives what we want.
It renders sloooooowly because we have to erode many times, but it works :slight_smile:


Let’s treat this as a starting idea that may be used for further tweaking :slight_smile:

^^ If you scale down the image first then dilate / erode a few times before scaling up again it’s much faster, but still a work-around (and less accurate).

And I think pynodes for the compositor would be a brilliant idea, I think they were developed for materials but never for compositing.

+1 for pynodes. Now all we need is to find someone to code it for us! :slight_smile:

@Bartek: wow! Impressive idea! :slight_smile:
Still, this cannot beat a few lines of Python in terms of speed.

Um could you find mid value by averaging image, blur, then find diff from mid. Apply that difference to minus from 100% or white?

Hmm, I hope this is what you were looking for.


Leon Cheung! I love this! Thankyou. Hmmm, I wonder if I can use it for timelapse deflicker tool? That is to normalise each frame then regrade to norm…

Wow this is an old thread. I think Blender now allows for Erode/Dilate function with infinite iterations, so the problem has been solved that way too