# Log transformation of an image in matlab

Log curve maps a narrow range of grey-level values in the input image into a wider range of output levels

### Mathematical Form:

Log transformation in general in shown by this equation

s=clog(1+r)

### Uses:

1. Used to expand the values of dark pixels in an image while compressing the higher values

2. It compresses the dynamic range of images with large variations in pixel values

### Properties:

It can have intensity range from 0 to 10^6 or higher

We can not see the significant degree of detail as it will be lost in the display

### Example:

Example of image with dynamic range: Fourier spectrum Image

### Explanation:

As discussed above applying log transformation to an image will expand its low valued pixels to a higher level and has little effect on higher valued pixels so in other words it enhances image in such a way that it highlights minor details of an image as shown in figure below. Image (a) has minor details which are not much prominent but after applying log transformation we are able to see those little details

### Graph:

The log transformation has a graph as shown below in this you can easily see that how it is shifting low intensity grey-level values to high values while having a little or no effect on higher intensity pixels.

Now we want to implement this in matlab the code for this implementation is given below. We used same equation for transformation as shown on top i.e

s=clog(1+r)

clear all;

a=imread(‘C:\MATLAB7\Figure-3.tif’);

a=im2double(a);

x=a;

[r,c]=size(a);

C=4;

for i=1:r

for j=1:c

x(i,j)=C*log(1+a(i,j));

end

endsubplot(1,2,1)

imshow(a);

title(‘Before Transformation’)subplot(1,2,2)

imshow(x);

title(‘After Transformation’)

If you have further questions feel free to ask by commenting below….Thanks!