I would like to set up a node editor in the way, that the darkest pixel in a grayscale render result is set to black and the offset to the original value is subtracted from all the other pixels. While I am aware of the subtraction node I have difficulties finding the darkest pixel in the render results.

  • 1
    $\begingroup$ Did you tried with a "less than" math node ? $\endgroup$ – Polosson Nov 9 '13 at 13:46
  • $\begingroup$ I think, the math node works per pixel, it does not sum over all pixels $\endgroup$ – miceterminator Nov 9 '13 at 17:48
  • $\begingroup$ @miceterminator I'm not sure what you mean, isn't that what you want? Another way to do this is with the brightness/contrast node. You could just slide the brightness down until some pixels are black. $\endgroup$ – gandalf3 Nov 9 '13 at 20:13
  • $\begingroup$ I am looking for a way to automatically find the value to subtract, so that the darkest pixel is black. Like an global input to the subtract math node. $\endgroup$ – miceterminator Nov 9 '13 at 22:09

I don't think an automatic way currely exists. I'm afraid you have to code something to find the target pixel directly.

However, after playing this for quite a bit time, I find a tricky way to get the same result. As shown in the image below. Though it seems not quite effective on performance, but quite acceptable after my testing on a sort of 6000 x 6000 px image, so far.

Version 1

Furthermore, suppose you want to target the brightest pixel, just add an Invert node right before the Nomalize node. Hope that helps.

Version 2:

I think this way is even better. FYI

Version 2a


Version 2b


Run the image, in this case a pointiness input for Suzanne through the following node setup. Keep in mind, the invert value was arbitrarily chosen but works quite well for almost any image. Out of the 'Normalizes' frame comes the image that is quite close to being valued from 0-1. If you further want a custom range placed on those values, run the output of that frame into the Custom Range frame. In the second frame, simply enter the minimum and maximum values you want as the range for your image. Run the output where ever you'd like.enter image description here

  • $\begingroup$ Essentially, you'll normalize the texture across the values of 0 and 1. For your case, leave the min at 0 (black) and select the upper most bound you want. FYI, this works to invert the finished image too. You can reverse the values of min and max to produce a limited range image, inverted, with 1 (white) as an upper most limit. $\endgroup$ – allinyourhead Oct 20 '16 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.