# Logarithmic brightness enhancement of an image [closed]

I have the following 8bit grey scale png image:

Two examples for brigthness enhancement are:

• ImageAdjust[image, {0, 5}]

• Image@Rescale[ImageData[image], {0, 0.2}, {0, 1}]

To enhance the brightness logarithmically I was trying the following (using Kubas comment):

improvedImage = c * Log[1 + ImageData[image]]


where

c is depending on the original image.

A good qualitative output is obtained when I force that the improved image has a certain mean intensity:

meanIntensity = 0.3;

c= meanIntensity / Mean[Flatten[ImageData[image]]]= 7.37513

Image[c * Log[1 + ImageData[image]]]


But as you see meanIntensity of the improved image is selected manually and probably not always the best choice.

Which procedure would you propose to determine the factor c or do you propose another solution?.

## closed as unclear what you're asking by MarcoB, Niki Estner, José Antonio Díaz Navas, Carl Lange, bbgodfreyFeb 26 at 15:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• You can do direct arithmetic on images in recent versions of Mathematica, but in its current state the question is completely unclear, and will certainly be closed. If you can write the formula for the transformation you want, you can simply plug in the image into that formula (with a few minor caveats) – Szabolcs Feb 12 at 14:43

It's not entirely clear what you want, but here's a pair of functions I use for "quick and dirty" display of images from the TESS space mission. qImage usually shows me what I want to see without further adjustment.

Turn an array of nonnegative numbers into an Image for display. Reverse the row order to display the first row on the bottom. Scale so the the max value is one.

normImage[i_List] := Image[Reverse[i/Max @@ Flatten[i]]]


Feed an adjusted array to normImage. Use a logarithmic scale based on quartiles.

qImage[i_List] :=
normImage[With[{q = Quartiles[Flatten[i]]},
Log[1 + Clip[(i - q[[1]])/(q[[3]] - q[[1]]), {0, Infinity}]]]]