Changing contrast of the image
1 view (last 30 days)
I try to decrease the contrast to 50% and I am using imadjust function. I tried:
imadjust(originalImage, [0.5 1], [0 1]);
imadjust(originalImage, [0 0.5], [0 1]);
They both do not give the result I have in the photoshop (-50% on contrast slider).
I can remove the white background or not in photoshop, but the result is still different.
Any idea how I solve it? I need it to look like in the photoshop...
DGM on 6 Jul 2022
To preface, I have no idea how PS actually calculates anything internally, and I don't have the original image, so this is not necessarily exactly the same. I don't think those details matter anymore.
For a basic demonstration of brightness/contrast controls, see this post. The methods described therein are implemented in MIMT imbcg(). While imbcg() is simple in that it replicates the usage found in common image editing software, you can do the same thing with imadjust(). Imadjust() is more akin to a 'Levels' type adjustment tool, but it can be used to effect linear 'brightness/contrast' controls with some effort and insight. While moving the input levels toward center will raise contrast, moving output levels toward center will decrease contrast.
A = imread('cameraman.tif');
contrastamt = -0.5; % -50% contrast
olhi = tan((contrastamt+1)*pi/4)*0.5 + 0.5; % 1/sqrt(2) for -50%
B = imadjust(A,[0 1],[1-olhi olhi],1);
% the same can be done more succinctly with third-party tools
%B = imbcg(A,'c',contrastamt);
Note the calculation of the output limit. Compare this to the calculations described in the linked demo.