BhainCode



INDEX

|S.NO |PROGRAM |DATE | |

|1. |Introduction to MATLAB &commands Related to Digital Image Processing | | |

|2. |Write a MATLAB code for basic gray-level Transformation (Image negative | | |

| |,Log transformation ,Power law transformation) | | |

|3. |Write a MATLAB code for Brightness enhancement & Brightness suppression | | |

|4. |Write a MATLAB code for contrast manipulation | | |

| | | | |

|5. |Write a MATLAB code to perform histogram equalization | | |

|6. |Write a MATLAB code to perform spatial domain filtering | | |

|7. |Write a MATLAB code to perform Gaussian low pass filter | | |

| | | | |

|8. |Write a MATLAB code to compute the edges in the image ( Roberts, Sobel, | | |

| |Prewitt operators ) | | |

| | | | |

|9. |Write a MATLAB code to remove RGB plane | | |

| | | | |

PROGRAM NO:1

Introduction to MATLAB &commands Related to Digital Image Processing

MATLAB Image Processing Toolbox

1. Opening MATLAB in the microcomputer lab.Access the Start Menu, Proceed to Programs, Select MATLAB from the MATLAB folder

2. When MATLAB opens, the screen should look something like what is pictured in Figure below.

MATLAB window

The Command Window is the window on the right hand side of the screen. This window is used to both enter commands for MATLAB to execute, and to view the results of these commands.

The Command History window, in the lower left side of the screen, displays the commands that have been recently entered into the Command Window.

Current Directory, which tells the user which M-files are currently in use. The second window is the Workspace window, which displays which variables are currently being used and how big they are. The third window is the Launch Pad window, which is especially important since it contains easy access to the available toolboxes, of which, Image Processing is one.

Creating an M-file – To create an M-file, select File\New ►M-file.

Saving – The next step is to save the newly created M-file. In the M-file window, select File\Save As…

Opening an M-file – To open up a previously designed M-file, simply open MATLAB in the same manner as described before. Then, open the M-file by going to File\Open…, and selecting your file.

Writing Code – After creating and saving your M-file, the next step is to begin writing code. A suggested first move is to begin by writing comments at the top of the M-file with a description of what the code is for, who designed it, when it was created, and when it was last modified. Comments are declared by placing a % symbol before them. Comments appear in green in the M-file window.

Running Code – To run code, simply go to the main MATLAB window and type the name of your M-file after the >> prompt. Other ways to run the M-file are to press F5 while the M-file window is open, select Debug\Run, or press the Run button (see Figure 3.1) in the M-file window toolbar.

Images

Loading an Image – Many times you will want to process a specific image, other times you may just want to test a filter on an arbitrary matrix. The function imread is used to read an image file with a specified format. The function imshow displays an image, while figure tells MATLAB which figure window the image should appear in. If figure does not have a number associated with it, then figures will appear chronologically as they appear in the M-file.

Writing an Image –This can be accomplished in MATLAB using the imwrite function.

Histogram – A histogram is bar graph that shows a distribution of data. In image processing histograms are used to show how many of each pixel value are present in an image. Histograms can be very useful in determining which pixel values are important in an image. In order to create a histogram from an image, use the imhist function. Contrast enhancement can be performed by the histeq function, while thresholding can be performed by using the graythresh function and the im2bw function.

Negative – The negative of an image means the output image is the reversal of the input image. negative of an image is to use imcomplement.

In digital systems, we use a Fourier Transform designed in such a way that we can enter discrete input values, specify our sampling rate, and have the computer generate discrete outputs. This is known as the Discrete Fourier Transform, or DFT. MATLAB uses a fast algorithm for performing a DFT, which is called the Fast Fourier Transform, or FFT, whose MATLAB command is fft. The FFT can be performed in two dimensions, fft2 in MATLAB. This is very useful in image processing because we can then determine the frequency content of an image.

In MATLAB, conv2 is used to perform a two-dimensional convolution of two matrices. This can also be accomplished by taking the ifft2 of the multiplication of two fft2’s. When this

is done, though, both matrices’ dimensions must be the same. The first filter is medfilt2, which takes the median value of the pixel in question and its neighbors.

In MATLAB erosion and dilation can be accomplished by the imerode and imdilate functions,

MATLAB functions, fspecial, which creates the filter, and imfilter, which applies the filter to the image. The second method uses the MATLAB function, edge, in which you must specify the type of edge detection method desired. Sobel was used as the first edge detection method, while Canny was used as the next type.

PROGRAM NO:2

Write a MATLAB code for basic gray-level Transformation (Image negative, Log transformation, Powerlaw transformation)

1. Introduction to Image negative:

In photography, a negative is an image, usually on a strip or sheet of transparent plastic film, in which the lightest areas of the photographed subject appear darkest and the darkest areas appear lightest. Negatives are normally used to make positive prints on photographic paper by projecting the negative onto the paper with a photographic enlarger or making a contact print. The paper is also darkened in proportion to its exposure to light, so a second reversal results which restores light and dark to their correct order. Negatives were once commonly made on a thin sheet of glass rather than a plastic film, and some of the earliest negatives were made on paper. It is incorrect to call a photograph a negative solely because it is on a transparent material. Transparent prints can be made by printing a negative onto special positive film, as is done to make traditional motion picture film prints for use in theaters. Some films used in cameras are designed to be developed by reversal processing, which produces the final positive, instead of a negative, on the original film. Positives on film or glass are known as transparencies , and if mounted in small frames designed for use in a slide projector or magnifying viewer they are commonly called slides.

A positive image is a normal image. A negative image is a total inversion, in which light areas appear dark and vice versa. A negative color image is additionally color-reversed, with red areas appearing cyan, greens appearing magenta and blues appearing yellow.

Matlab Code:

a=imread('office_5.jpg');

imshow(a);

b=255-a;

figure,imshow(b);

Input and Output Images:

[pic][pic]

2. Introduction to Log Transformation:

Matlab Code:

I=imread('cameraman.tif'); %Read in image

subplot(2,2,1), imshow(I); %Display image

Id=im2double(I);

Output1=2*log(1+Id);

Output2=3*log(1+Id);

Output3=5*log(1+Id);

subplot(2,2,2), imshow(Output1); %Display result images

subplot(2,2,3), imshow(Output2);

subplot(2,2,4), imshow(Output3);

Input and Output Images:

[pic]

3. Introduction to gamma Transformation:

Gamma encoding of images is required to compensate for properties of human vision, hence to maximize the use of the bits or bandwidth relative to how humans perceive light and color. Human vision, under common illumination conditions (not pitch black nor blindingly bright), follows an approximate gamma or power function. If images are not gamma encoded, they allocate too many bits or too much bandwidth to highlights that humans cannot differentiate, and too few bits/bandwidth to shadow values that humans are sensitive to and would require more bits/bandwidth to maintain the same visual quality. Gamma encoding of floating point images is not required (and may be counterproductive), because the floating-point format already provides a piecewise linear approximation of a logarithmic curve. Although gamma encoding was developed originally to compensate for the input–output characteristic of cathode ray tube (CRT) displays, that is not its main purpose or advantage in modern systems. In CRT displays, the light intensity varies nonlinearly with the electron-gun voltage. Altering the input signal by gamma compression can cancel this nonlinearity, such that the output picture has the intended luminance. However, the gamma characteristics of the display device do not play a factor in the gamma encoding of images and video – they need gamma encoding to maximize the visual quality of the signal, regardless of the gamma characteristics of the display device. The similarity of CRT physics to the inverse of gamma encoding needed for video transmission was a combination of luck and engineering, which simplified the electronics in early television sets.

Matlab Code:

I=imread('cameraman.tif'); %Read in image

subplot(2,2,1), imshow(I); %Display image

Id=im2double(I);

Output1=2*(Id.^0.5);

Output2=2*(Id.^1.5);

Output3=2*(Id.^3.0);

subplot(2,2,2), imshow(Output1); %Display result images

subplot(2,2,3), imshow(Output2);

subplot(2,2,4), imshow(Output3);

Input and Output Images:

[pic]

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches