How to apply and revert gamma on an image

9 views (last 30 days)
Jakub
Jakub on 22 Oct 2019
Answered: jacqueline downes on 23 Oct 2019
Hi, Im struggling with an asignment, which I believe I understand, Im getting a wrong result tho (suprisingly :D).
Im have loaded grayscale image, on which I apply exp function. Than Im trying to apply an invert function to obtain the first immage (or at least something close).
Any help would be appretiated.
Img=knee(:,:,1);
ImgD=im2double(Img);
[m,n]=size(ImgD);
gamma=3;
out=abs((1*ImgD).^gamma);
maxm=max(out(:));
minm=min(out(:));
for i=1:m
for j=1:n
out(i,j) = (255*out(i,j))/(maxm-minm);
end
end
reverse=abs((1*out).^(1/gamma));
maxm2=max(reverse(:));
minm2=min(reverse(:));
for u=1:m
for v=1:n
reverse(u,v) = (255*out(u,v))/(maxm2-minm2);
end
end
out = uint8(out);
reverse = uint8(reverse);
figure(1);
subplot(1,3,1),imshow(Img);
subplot(1,3,2),imshow(out);
subplot(1,3,3),imshow(reverse);

Answers (1)

jacqueline downes
jacqueline downes on 23 Oct 2019
In picture preparing it is a smart thought to accomplish a gamma of one for the entire picture securing process. (There might be truth be told, not many special cases … ) To accomplish this, it is important to know the gamma of the camera and some other procedures included. The sensor intself frequently shows a straight conduct.
On the off chance that you know the gamma of the picture obtaining process (camera and so on.), you can make up for it by the opposite gamma in ImageJ (Process >> Math >> Gamma… ) to get the ideal generally speaking direct conduct, for example a gamma of one. You can decide the gamma of the picture obtaining process by utilizing an aligned dark scale.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!