MTA1 Experiment 1 Question 2a & 2b Solution
MTA1 Experiment 1 Question 2a & 2b Source Code
This few days I received some request.
Most of students couldn't solve the Exp1. 2a and 2b.
So, I will post up the source code for Experiment 1 Question 2a & 2b
Question 2a :
Convert the image ‘peppers.png’ into grayscale, and perform edge detection on the resulting gray image.
Source Code :
I = imread('peppers.png'); %read in an image
A = rgb2gray(I); %convert RGB to Gray format
CN = edge(A, 'canny'); %perform canny edge detection
figure, imshow(I);
figure, imshow(A);
figure, imshow(CN);
Note : This 2a used only canny is because you found that canny is the best edge detection operator for your image by result from Question 1.
Question 2b:
Perform edge detection on each of the three color bands of the image, followed by some fusion rule. Perform edge detection on each of the color bands of the ‘peppers.png’ image and combine the three edge images in order to get the final edge image.
What is the three color bands of the image ?
You are using true color image in this question, so the 3 bands would be RGB.
How to Separate the 3 color bands ?
Example :
R = (I(:,:,1));
G = (I(:,:,2));
B = (I(:,:,3));
Note : I is the read in image.
The 1 2 and 3 indicates the layer of the image.
How to perform edge detection on every layer (band) ?
As you saved each layer into R, G and B variable.
You just need to do edge detection on every R,G and B.
Example :
CN1 = edge(R, 'canny');
CN2 = edge(G, 'canny');
CN3 = edge(B, 'canny');
How to combine the 3 edge detected image into the final image ?
This part, you can use alot of operators.
such as : 'or' , 'and' , 'xor' , 'nand' and etc.
How to use the combination operator ?
Example for 'and' operator :
C = and(CN1,CN2);
D = and(C,CN3);
Example for 'or' operator :
C = or(CN1,CN2);
D = or(C,CN3);
Note : the operator can only have 2 arguments at a time.
So combining the CN1 and CN2 and store into C first, then combine C with CN3 and you will get the final solution and save it into variable D.
-End of Experiment1 2a 2b-
This few days I received some request.
Most of students couldn't solve the Exp1. 2a and 2b.
So, I will post up the source code for Experiment 1 Question 2a & 2b
Question 2a :
Convert the image ‘peppers.png’ into grayscale, and perform edge detection on the resulting gray image.
Source Code :
I = imread('peppers.png'); %read in an image
A = rgb2gray(I); %convert RGB to Gray format
CN = edge(A, 'canny'); %perform canny edge detection
figure, imshow(I);
figure, imshow(A);
figure, imshow(CN);
Note : This 2a used only canny is because you found that canny is the best edge detection operator for your image by result from Question 1.
Question 2b:
Perform edge detection on each of the three color bands of the image, followed by some fusion rule. Perform edge detection on each of the color bands of the ‘peppers.png’ image and combine the three edge images in order to get the final edge image.
What is the three color bands of the image ?
You are using true color image in this question, so the 3 bands would be RGB.
How to Separate the 3 color bands ?
Example :
R = (I(:,:,1));
G = (I(:,:,2));
B = (I(:,:,3));
Note : I is the read in image.
The 1 2 and 3 indicates the layer of the image.
How to perform edge detection on every layer (band) ?
As you saved each layer into R, G and B variable.
You just need to do edge detection on every R,G and B.
Example :
CN1 = edge(R, 'canny');
CN2 = edge(G, 'canny');
CN3 = edge(B, 'canny');
How to combine the 3 edge detected image into the final image ?
This part, you can use alot of operators.
such as : 'or' , 'and' , 'xor' , 'nand' and etc.
How to use the combination operator ?
Example for 'and' operator :
C = and(CN1,CN2);
D = and(C,CN3);
Example for 'or' operator :
C = or(CN1,CN2);
D = or(C,CN3);
Note : the operator can only have 2 arguments at a time.
So combining the CN1 and CN2 and store into C first, then combine C with CN3 and you will get the final solution and save it into variable D.
-End of Experiment1 2a 2b-
Hope this source code can help you out to continue the experiment
you can always drop me a comment or msg to complain or ask.
I wont be free for chatting through msn and ym because I got an exam on tuesday'night,
if you found any problem executing the code,
you can post in the comment part and i will try to solve for you later.
you can always drop me a comment or msg to complain or ask.
I wont be free for chatting through msn and ym because I got an exam on tuesday'night,
if you found any problem executing the code,
you can post in the comment part and i will try to solve for you later.
Copyrighted (c) 2007 , Law Ding Yong







