Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find an inverse log transformation of an image in matlab

I have been searching for this almost all day. The general form of the log transformation is

s = clog(1+r) 

where

c = 0.1 

The opposite is inverse log transformation(book). What will be the inverse log transformation? Is it

s = exp(r)?

Could not get right output.

like image 348
user461127 Avatar asked Oct 15 '11 23:10

user461127


2 Answers

Exp() will only be an inverse of Log() if Log() is the natural logarithm. If your Log() is using a different base (base 2, base 10, any other arbitrary base), then you will need to use the different base in place of e in Exp().

Update

Try 10^(x/0.1)-1. x/0.1 undoes the 0.1 * operation, 10^ undoes the log(), and -1 undoes the +1.

like image 109
sarnold Avatar answered Sep 24 '22 16:09

sarnold


I think you defined c to normalize the resulting image to a valid (visible) range. Then a rational value for c could be:

c = (L - 1)/log(L) 

where L is the number of gray levels. So s would be:

s = log(r+1) .* ((L – 1)/log(L)) 

or

s = log(r+1) .* c

Then the inverted transformation would be:

s2 = (exp(r) .^ (log(L) / (L-1))) – 1

or

s2 = (exp(r) .^ (1/c)) – 1

This is the transformation output for L=256:

enter image description here

To apply this transformation to an image we need to do some typecasting:

figure;
L = 256;
I = imread('cameraman.tif');
log_I = uint8(log(double(I)+1) .* ((L - 1)/log(L)));
exp_I = uint8((exp(double(I)) .^ (log(L) / (L-1))) - 1);
subplot(2, 2, [1 2]); imshow(I); title('Input');
subplot(2, 2, 3); imshow(log_I); title('\itlog(I)');
subplot(2, 2, 4); imshow(exp_I); title('\itexp(I)');

enter image description here

like image 36
saastn Avatar answered Sep 23 '22 16:09

saastn