I was working with some less than ideal photographs, and wanted to adjust them before continuing. I wanted to raise the levels of the very dark areas and lower the levels of the very light areas. I couldn't find a function in Mathematica 8 that would allow me to do this. As a quick work-round, I wrote a function that quickly adjusted the levels. It looks terrible in this simplified example (I had more levels going, for one thing), but you get the idea (I hope!).
image1 = Image[
ReliefPlot[
Table[i - 3 Sin[i^2 + j^2],
{i, -4, 4, .03},
{j, -4, 4, .03}]]];
tweakC = Compile[{pixel}, Module[{ p = pixel},
m = Mean[p];
Which[
m < 0.3, p = pixel * 1.5,
m > 0.85, p = pixel * 0.8 ,
m > 0, p = p ]]];
image2 = ImageAdjust[ImageApply[tweakC, image1]];
ImageAssemble[{image1, image2}]
:
What's the best way to do this? I don't think ImageAdjust or ImageClip do what I want.






