# Introduction of bias during brightness and contrast manipulation of an image

Quoting from Nature magazine's "Image integrity" guidelines:

Processing (such as changing brightness and contrast) is appropriate only when it is applied equally across the entire image and is applied equally to controls. Contrast should not be adjusted so that data disappear. Excessive manipulations, such as processing to emphasize one region in the image at the expense of others (for example, through the use of a biased choice of threshold settings), is inappropriate, as is emphasizing experimental data relative to the control.

When I change the brightness and contrast of an image, say, with the following command:

ImageAdjust[ExampleImage, {contrast, brightness}]


Is it fair to say that contrast and brightness transformations are "applied equally across the entire image" in the spirit of the above quotation? Of course common sense is required in terms of not purposefully obscuring meaningful data, but are there pitfalls / issues I should otherwise be aware of specifically with regards to this sort of image manipulation in Mathematica?

-
Perhaps related question: mathematica.stackexchange.com/questions/15596/… – cormullion Mar 24 '13 at 15:54

In a word, "yes". ImageAdjust operates the same on each pixel value. To see this, consider an "image"

img=Image[{{1, 2, 3}, {1, 2, 4}, {1, 2, 5}}]


You won't see anything. But if you adjust it:

ImageAdjust[img]


you see a small 3 by 3 block of black and white. If you look at the numbers using

ImageData[ImageAdjust[img]]


then you get:

{{0., 0.25, 0.5}, {0., 0.25, 0.75}, {0., 0.25, 1.}}


So all the 1's have gone to 0, ll the 2's have gone to 0.25, etc. The largest value has gone to 1.

-
However, pixel values must not clip and quantization noise should not be significant if bias isn't to be introduced in this process. Perhaps one can get away with working with 64-bit floating point images in a defined (and preferably linear) color space. Of course the best approach is to make the unprocessed data and the code for processing it available to the readers rather than forcing them to rely on pre-prepared figures. – Oleksandr R. Mar 24 '13 at 16:35
@OleksandrR. Making the scripts available is precisely what I plan to do. – Bob Mar 24 '13 at 20:17
With a stricter meaning of "fairness", ImageAdjust[img] is not "fair" because the operation relies on the min and max pixel values of the image: these min and max values are typically very sensitive to noise. – Matthias Odisio Mar 25 '13 at 15:16

(Would have applied an "honorable" tag to the question if possible)

It is fair to use ImageAdjust[image, {contrast, brightness}] both for your "control" image and "data" image, because with these settings the exact same formula will be used for both images.

It's not always true with all syntactic forms of ImageAdjust. For example, ImageAdjust[img] will use image-specific data in the underlying formula, and therefore a source of potential "unfairness." In some scenario it would not be fair to have the displayed output rely heavily on the value of a noisy dark pixel, for example.

-
Thanks - that's a very good point. This is precisely the sort of reason I prefer using Mathematica to a program like Photoshop where it's not at all clear what's going on. – Bob Mar 25 '13 at 16:16
What do contrast and brightness adjustments mean exactly, mathematically? What does ImageAdjust do precisely? Is is the same that is described here? (It can't be because the neutral contrast adjustment is `0 in Mathematica) – Szabolcs Mar 25 '13 at 18:35
@Szabolcs I know it does not answer precisely your question, but yes, computations are conceptually similar to the ones you pointed to. – Matthias Odisio Mar 25 '13 at 20:32