Download - MATLAB: IMAGE PROCESSING Training session
- 1 - | P a g e
MATLAB: IMAGE PROCESSING Training session
Spectrum Solutions, No 46 ,1st Floor State Bank of India (SBI) Branch Ariyankuppam, Pondicherry , 605007
Website : www.spectrumultra.com Mail : [email protected] Contact No : 7667052212, 9381775781
- 2 - | P a g e
CONTENT
Chapter No. Title Page No.
Chapter 1 Input Image to MATLAB System 3 Chapter 2 RGB to Gray Scale Conversion 4-6 Chapter 3 Image Processing with GUI 7-12 Chapter 4 Image Resize and Rotate 13-15
Chapter 5 Image Processing Vs. GUI (Axis) 16-20
- 3 - | P a g e
CHAPTER 1
INPUT IMAGE TO MATLAB SYSTEM
1.1 Input image and its display
Program
[fname,pname]=uigetfile('*.jpg','browse to ....');
img=imread(fname);
imshow(img)
Output
Assignments 1. Take input image and display it in MATLAB.
- 4 - | P a g e
CHAPTER 2
RGB TO GRAY SCALE CONVERSION 2.1 Input Image and Gray Conversion (Figure Plot)
Program
[fname,pname]=uigetfile('*.jpg','Browse to....'); im=imread(fname); figure(1) imshow(im); img=rgb2gray(im); figure(2) imshow(img); Output
- 5 - | P a g e
2.2. Input Image and Gray Conversion (Subplot) Program
[fname,pname]=uigetfile('*.jpg','browse to.......'); im=imread(fname); subplot(1,2,1) imshow(im); title('rgb') img=rgb2gray(im); subplot(1,2,2) imshow(img); title('gray')
Output
- 6 - | P a g e
Assignments
1. Take input image and display it with title. 2. Take input image, convert it into Gray Scale Image and Display both in separate
figures. 3. Take input image, convert it into Gray Scale Image and Display both in subplot
with title.
- 7 - | P a g e
CHAPTER 3
IMAGE PROCESSING WITH GUI
1. Input image, It’s conversion into Gray Scale Image and Display both in separate figures
with GUI.
Step 1: Create a folder on desktop with an image available in it.
Step 2: Start MATLAB and Go to
File>>GUI>>Blank GUI(Default)>>OK
- 8 - | P a g e
Step 3: The GUI window will appear
Step 4: Select Panel
Step 5: Select Button
- 9 - | P a g e
Step 6: Double Click Button and Change the Button Name, Font Size and Color. Step 7: Right Click Button View Callback>>Callback Step 8: Save the program in Folder Created on Desktop in Step 1.
- 10 - | P a g e
Now the program window will appear
Step 9: Write the program of color image in button 1 and color+rgb in button 2.
- 11 - | P a g e
Step 10: Run the code. Output 1 : RGB Image Output
Output 2: Gray Scale Image Output
- 12 - | P a g e
Assignments 1. Take input image and display it with title using GUI (1 Button)
2. Take input image, convert it into Gray Scale Image and Display both in separate
figures using GUI (2 Buttons).
3. Take input image, convert it into Gray Scale Image and Display both in subplot
with title using GUI.
4. Take input image; convert it into Gray Scale Image and Display using GUI.
Button 1: Input Image and Display
Button 2: Input Image convert into Gray and Display in 2 figures.
Button 3: Input Image convert into Gray and Display in 2 subplots.
- 13 - | P a g e
CHAPTER 4
IMRESIZE AND IMROTATE
IMROTATE Program
[fname,pname]=uigetfile('*.jpg','browse to.......');
a=imread(fname);
b=imrotate(a,-45,'crop');
figure
imshow(a)
figure
imshow(b)
Output
- 14 - | P a g e
IMRESIZE Program [fname,pname]=uigetfile('*.jpg','browse to.......');
a=imread(fname);
b=imresize(a,0.1); % 0.1 means 10% of original image
figure
imshow(a)
figure
imshow(b)
Output
- 15 - | P a g e
Assignments 1. Take input image and rotate it 30 degree right and display.
2. Take input image and rotate it 45 degree left and display
3. Take input image, convert it into Gray Scale Image and Display using GUI.
Button 1: Input Image and Display
Button 2: Input Image convert into Gray and Display in 2 figures.
Button 3: Input Image convert into Gray and Display in 2 subplots.
Button 4: Input Image convert into Gray, rotate 45 degree and display in 2 figures.
Button 5: Input Image convert into Gray, rotate 45 degree and display in 2
subplots.
4. Take input image and resize it 30% and display.
5. Take input image and resize it 60% and display.
6. Take input image, convert it into Gray Scale Image and Display using GUI.
Button 1: Input Image and Display
Button 2: Input Image convert into Gray and Display in 2 figures.
Button 3: Input Image convert into Gray and Display in 2 subplots.
Button 4: Input Image convert into Gray, resize 10% and display in 2 figures.
Button 5: Input Image convert into Gray, resize 40% and display in 2 Subplots.
- 16 - | P a g e
CHAPTER 5
IMAGE PROCESSING VS. GUI (AXIS)
Axis Plot Step 1: Create GUI with 2 Buttons (Input Image, Gray Scale Image) Step 2: Write the program for input image in Button 1 (Input Image) [fname,pname]=uigetfile('*.jpg','browse to.......');
a=imread(fname);
%figure (figure command should not be used)
imshow(a)
- 17 - | P a g e
Step 2: Write the program for Gray Scale Image in Button 2 (Gray Scale Image) [fname,pname]=uigetfile('*.jpg','browse to.......');
a=imread(fname);
b=rgb2gray(a);
%figure (figure command should not be used)
imshow(b)
Output
- 18 - | P a g e
Create 2 more butons for “Resize and Rotate” Step 1 Add 2 more buttons of “RESIZE and ROTATE” IMRESIZE (Program) [fname,pname]=uigetfile('*.jpg','browse to.......');
a=imread(fname);
b=imresize(a,0.1); % 0.1 means 10% of original image
imshow(b)
Output
Visibility of image reduced because it is 10% of input image
- 19 - | P a g e
Step 1 IMROTATE (Program) [fname,pname]=uigetfile('*.jpg','browse to.......');
a=imread(fname);
b=imresize(a,0.1); % 0.1 means 10% of original image
imshow(b)
Output
Image rotated 45 degree clockwise.
Assignments
1. Create GUI 2 buttons (Input Image, Gray Image). Show both outputs in GUI axis.
2. Create GUI 4 buttons (Input Image, Gray Image, Resize, and Rotate). Show all outputs
in GUI axis.
- 20 - | P a g e
3. Create GUI 4 buttons (Input Image, Gray Image, Resize, and Rotate). Resize (40%) and
rotate (45 degree). Show all outputs in GUI axis.
4. Create GUI 4 buttons (Input Image, Gray Image, Resize, and Rotate). Rotate (90
degree, gray scale), Resize (30 percent, gray scale) . Show all outputs in GUI axis.
5. Create GUI 4 buttons (Input Image, Gray Image, Resize, and Rotate). Rotate (25
degree, gray scale), Resize (5%, color). Show all outputs in GUI axis.