code jb = rgb2gray(j); imagesc(jb);axis image; colormap...
TRANSCRIPT
![Page 1: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/1.jpg)
Jb = rgb2gray(J);
imagesc(Jb);axis image; colormap(gray);
bw = edge(Jb,'canny');
Code
Edge Detection
![Page 2: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/2.jpg)
Numerical Image FilteringFilter
-0.8
-0.8
2.0
[nr,nc] = size(Jb);
J_out = zeros(nr,nc);
for i=1:nr,
for j=1:nc;
if (i<nr) && (i>1),
J_out(i,j) = 2*Jb(i,j) - 0.8*Jb(i+1,j) - 0.8*Jb(i-1,j);
else
J_out(i,j) = Jb(i,j);
end
end
end
figure; imagesc(J_out);colormap(gray)
Looping through all pixels
(i,j) (i-1,j)
(i+1,j)
nc
nr
Computation time: 0.050154 sec
![Page 3: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/3.jpg)
Numerical Image Filtering
![Page 4: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/4.jpg)
Convolution without Looping using meshgrid
>> [x,y] = meshgrid(1:5,1:3)
x =
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
y =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
column
row
column
row
![Page 5: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/5.jpg)
[x,y] = meshgrid(1:nc,1:nr);
figure(1); imagesc(x); axis image; colorbar;
colormap(jet);
figure(2); imagesc(y); axis image; colorbar;
colormap(jet);
![Page 6: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/6.jpg)
[x,y] = meshgrid(1:nc,1:nr);
y_up = y-1;
y_down = y+1;
y_up = min(nr,max(1,y_up)); % keep y_up index within legal range of [1,nr]
y_down = min(nr,max(1,y_down));
ind_up = sub2ind([nr,nc],y_up(:),x(:)); % create linear index
ind_down = sub2ind([nr,nc],y_down(:),x(:));
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Computation time: 0.024047 sec
Convolution without Looping using meshgrid
![Page 7: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/7.jpg)
[x,y] = meshgrid(1:nc,1:nr);
y_up = y-1;
y_down = y+1;
y_up = min(nr,max(1,y_up)); % keep y_up index within legal range of [1,nr]
y_down = min(nr,max(1,y_down));
ind_up = sub2ind([nr,nc],y_up(:),x(:)); % create linear index
ind_down = sub2ind([nr,nc],y_down(:),x(:));
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Convolution without Looping using meshgrid
x and y are subscript indice.
Jbxy
x
y
![Page 8: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/8.jpg)
[x,y] = meshgrid(1:nc,1:nr);
y_up = y-1;
y_down = y+1;
y_up = min(nr,max(1,y_up)); % keep y_up index within legal range of [1,nr]
y_down = min(nr,max(1,y_down));
ind_up = sub2ind([nr,nc],y_up(:),x(:)); % create linear index
ind_down = sub2ind([nr,nc],y_down(:),x(:));
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Convolution without Looping using meshgrid
y_up y y_down
y =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
y_up =
0 0 0 0 0
1 1 1 1 1
2 2 2 2 2
y_down =
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
![Page 9: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/9.jpg)
y_up = y-1;
y_down = y+1;
y_up = min(nr,max(1,y_up)); % keep y_up index within legal range of [1,nr]
y_down = min(nr,max(1,y_down));
ind_up = sub2ind([nr,nc],y_up(:),x(:)); % create linear index
ind_down = sub2ind([nr,nc],y_down(:),x(:));
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Convolution without Looping using meshgrid
y_up y y_down
y =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
y_up =
1 1 1 1 1
1 1 1 1 1
2 2 2 2 2
y_down =
2 2 2 2 2
3 3 3 3 3
3 3 3 3 3
![Page 10: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/10.jpg)
y_up = min(nr,max(1,y_up)); % keep y_up index within legal range of [1,nr]
y_down = min(nr,max(1,y_down));
ind_up = sub2ind([nr,nc],y_up(:),x(:)); % create linear index
ind_down = sub2ind([nr,nc],y_down(:),x(:));
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Convolution without Looping using meshgrid
linear_index = sub2ind([n_row, n_col], row_subscript, col_subscript)
4A=
12
A(:)=vectorization
A32 = = A(:)7
7 = sub2ind([4 3], 3,2)3
![Page 11: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/11.jpg)
y_up = min(nr,max(1,y_up)); % keep y_up index within legal range of [1,nr]
y_down = min(nr,max(1,y_down));
ind_up = sub2ind([nr,nc],y_up(:),x(:)); % create linear index
ind_down = sub2ind([nr,nc],y_down(:),x(:));
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Convolution without Looping using meshgrid
linear_index = sub2ind([n_row, n_col], row_subscript, col_subscript)
4
3
A=
12
1
A(:)=vectorization
A32 = = A(:)7
7 = sub2ind([4 3], 3,2)
ind_up = sub2ind([nr,nc],y_up(:),x(:));
Operation on vectors
Jbxy=Jbidx
![Page 12: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/12.jpg)
J_out = 2*Jb(:) - 0.8*Jb(ind_up) - 0.8*Jb(ind_down);
J_out = reshape(J_out, nr, nc);
figure; imagesc(J_out);colormap(gray)
Convolution without Looping using meshgrid
2 -0.8 -0.8
=
J_out
Jb Jb(ind_up) Jb(ind_down)
![Page 13: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/13.jpg)
With loop Without loop
Computation time: 0.024047 secComputation time: 0.050154 sec
![Page 14: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/14.jpg)
Canny Edge Detection
Objective: to localize edges given an image.Binary image indicating edge pixels
B(i,j) = 1 if I(i,j) is edge
0 if I(i,j) is not edge
Original image, I Edge map image, B
![Page 15: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/15.jpg)
1. Filter image by derivatives of Gaussian
2. Compute magnitude of gradient
3. Compute edge orientation
4. Detect local maximum
5. Edge linking
Canny Edge Detection
![Page 16: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/16.jpg)
1) Compute Image Gradient
the first order derivative of Image I in x,
and in y direction
![Page 17: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/17.jpg)
Edge Detection, Step 1,
Filter out noise and compute derivative:
Gradient of Gaussian
![Page 18: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/18.jpg)
Edge Detection, Step 1,
Filter out noise and compute derivative:
Image Smoothed Derivative
![Page 19: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/19.jpg)
Edge Detection, Step 1,
Filter out noise and compute derivative:
In matlab:
>> [dx,dy] = gradient(G); % G is a 2D gaussain
>> Ix = conv2(I,dx,’same’); Iy = conv2(I,dy,’same’);
![Page 20: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/20.jpg)
Edge Detection: Step 2
Compute the magnitude of the gradient
In Matlab:
>> Im = sqrt(Ix.*Ix + Iy.*Iy);
![Page 21: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/21.jpg)
We know roughly where are the edges, but we need their precise
location.
![Page 22: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/22.jpg)
Finding the orientation of the edge
• The gradient of an image:
• The gradient points in the direction of most rapid change in
intensity
• The image gradient direction is given by:
– how does this relate to the direction of the edge?
![Page 23: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/23.jpg)
%% define image gradient operator
dy = [1;-1];
dx = [1,-1];
%% compute image gradient in x and y
Iy = conv2(I,dy,'same');
Ix = conv2(I,dx,'same');
%% display the image gradient flow
figure(3);clf;imagesc(J);colormap(gray);axis image;
hold on;
quiver(Jx,Jy);
quiver(-Jy,Jx,'r');
quiver(Jy,-Jx,'r');
![Page 24: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/24.jpg)
![Page 25: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/25.jpg)
[gx,gy] = gradient(J);
mag = sqrt(gx.*gx+gy.*gy); imagesc(mag);colorbar
![Page 26: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/26.jpg)
image gradient direction:
![Page 27: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/27.jpg)
Edge orientation direction:
![Page 28: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/28.jpg)
[gx,gy] = gradient(J);
th = atan2(gy,gx); % or you can use:[th,mag] = cart2pol(gx,gy);
imagesc(th.*(mag>20));colormap(hsv); colorbar
![Page 29: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/29.jpg)
(Forsyth & Ponce)
Discretized pixel locations
![Page 30: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/30.jpg)
(Forsyth & Ponce)
Thesholding
0 1
1
1
0
0
1
1
0
gradient
![Page 31: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/31.jpg)
(Forsyth & Ponce)
Non-maximum suppression along the line of the
gradient
0 1
1
1
0
0
1
1
0
gradient
0 1
1
1
0
0
0
0
0
NMS
![Page 32: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/32.jpg)
(Forsyth & Ponce)
Gradient direction
0 1
1
1
0
0
1
1
0
gradient
0 1
1
1
0
0
0
0
0
NMS
![Page 33: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/33.jpg)
Local maximum
![Page 34: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/34.jpg)
No intensity values at r and p:
Interpolate these intensities using neighbor pixels.
Where is next edge point?
![Page 35: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/35.jpg)
Where is next edge point?
we construct the tangent to the edge curve (which is normal to the
gradient at that point) and use this to predict the next points
![Page 36: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/36.jpg)
Where is next edge point?
we construct the tangent to the edge curve (which is normal to the
gradient at that point) and use this to predict the next points
![Page 37: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/37.jpg)
Edge Linking: Hysteresis • Check that maximum value of gradient
value is sufficiently large
– drop-outs? use hysteresis
• use a high threshold to start edge curves and a low
threshold to continue them.
![Page 38: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/38.jpg)
Edge Linking: Hysteresis
• Check that maximum value of gradient
value is sufficiently large
– drop-outs? use hysteresis
• use a high threshold to start edge curves and a low
threshold to continue them.0 1
1
0
0
0
0
0
0
threshold_high
1
0
0
000 1
![Page 39: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/39.jpg)
Edge Linking: Hysteresis
0 1
1
0
0
0
0
0
0
threshold_high
1
0
0
000 1
0 1
1
1
0
0
0
0
0
threshold_low
1
0
0
100 1
![Page 40: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/40.jpg)
Edge Linking: Hysteresis
0 1
1
0
0
0
0
0
0
threshold_high
1
0
0
000 1
0 1
1
1
0
0
0
0
0
threshold_low
1
0
0
100 1
0 1
1
1
0
0
0
0
0
hysteresis
1
0
0
000 1
![Page 41: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/41.jpg)
1. Filter image by derivatives of
Gaussian
2. Compute magnitude of gradient
3. Compute edge orientation
4. Detect local maximum
5. Edge linking
Canny Edge Detection
![Page 42: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/42.jpg)
Canny Edge Implementationimg = imread ('Lenna.png');
img = rgb2gray(img);
img = double (img);
% Value for high and low thresholding
threshold_low = 0.035;
threshold_high = 0.175;
%% Gaussian filter definition (https://en.wikipedia.org/wiki/Canny_edge_detector)
G = [2, 4, 5, 4, 2; 4, 9, 12, 9, 4;5, 12, 15, 12, 5;4, 9, 12, 9, 4;2, 4, 5, 4, 2];
G = 1/159.* G;
%Filter for horizontal and vertical direction
dx = [1 0 -1];
dy = [1; 0; -1];
![Page 43: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/43.jpg)
Canny Edge Implementation% % Convolution of image with Gaussian
Gx = conv2(G, dx, 'same');
Gy = conv2(G, dy, 'same');
% Convolution of image with Gx and Gy
Ix = conv2(img, Gx, 'same');
Iy = conv2(img, Gy, 'same');
Ix Iy
![Page 44: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/44.jpg)
Canny Edge Implementationangle = atan2(Iy, Ix);
%% Edge angle conditioning
angle(angle<0) = pi+angle(angle<0);
angle(angle>7*pi/8) = pi-angle(angle>7*pi/8);
% Edge angle discretization into 0, pi/4,
pi/2, 3*pi/4
angle(angle>=0&angle<pi/8) = 0;
angle(angle>=pi/8&angle<3*pi/8) = pi/4;
angle(angle>=3*pi/8&angle<5*pi/8) = pi/2;
angle(angle>=5*pi/8&angle<=7*pi/8) =
3*pi/4;
Continuous angle Discretized angle
![Page 45: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/45.jpg)
0 1
1
1
0
0
1
1
0
Canny Edge Implementation%Calculate magnitude
magnitude = sqrt(Ix.*Ix+Iy.*Iy);
edge = zeros(nr, nc);
%% Non-Maximum Supression
edge = non_maximum_suppression(magnitude, angle, edge);
edge = edge.*magnitude;
gradient
0 1
1
1
0
0
0
0
0
NMS
Gradient magnitude Localized edge
![Page 46: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/46.jpg)
0 1
1
0
0
0
0
0
0
Canny Edge Implementation%% Hysteresis thresholding
% for weak edge
threshold_low = threshold_low * max(edge(:));
% for strong edge
threshold_high = threshold_high * max(edge(:));
linked_edge = zeros(nr, nc);
linked_edge = hysteresis_thresholding(threshold_low, threshold_high, linked_edge, edge);
0 1
1
1
0
0
0
0
0
hysteresis
threshold_high threshold_low
![Page 47: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/47.jpg)
1. Filter image by derivatives of
Gaussian
2. Compute magnitude of gradient
3. Compute edge orientation
4. Detect local maximum
5. Edge linking
Canny Edge Detection
![Page 48: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/48.jpg)
Canny Edge Implementationimg = imread (‘image.png');
img = rgb2gray(img);
img = double (img);
% Value for high and low thresholding
threshold_low = 0.035;
threshold_high = 0.175;
%% Gaussian filter definition (https://en.wikipedia.org/wiki/Canny_edge_detector)
G = [2, 4, 5, 4, 2; 4, 9, 12, 9, 4;5, 12, 15, 12, 5;4, 9, 12, 9, 4;2, 4, 5, 4, 2];
G = 1/159.* G;
%Filter for horizontal and vertical direction
dx = [1 -1];
dy = [1; -1];
![Page 49: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/49.jpg)
Canny Edge Implementation% % Convolution of image with
Gaussian
Gx = conv2(G, dx, 'same');
Gy = conv2(G, dy, 'same');
% Convolution of image with Gx and
Gy
Ix = conv2(img, Gx, 'same');
Iy = conv2(img, Gy, 'same');
Ix Iy
![Page 50: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/50.jpg)
Canny Edge Implementation
angle = atan2(Iy, Ix);
mag = sqrt(Iy.^2 + Ix.^2);
Gradient Magnitude Gradient Angle
![Page 51: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/51.jpg)
![Page 52: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/52.jpg)
![Page 53: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/53.jpg)
0 1
1
1
0
0
1
1
0
Canny Edge Implementation
%% Non-Maximum Supression
edge = non_maximum_suppression(magnitude, angle, edge);
gradient
0 1
1
1
0
0
0
0
0
NMS
Localized edge
0 1
1
0
0
0
0
0
0
0 1
1
1
0
0
0
0
0
hysteresis
threshold_high threshold_low
low = threshold_low * max(edge(:));
high = threshold_high * max(edge(:));
linked_edge = hysteresis_thresholding(low, high);
![Page 54: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/54.jpg)
![Page 55: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/55.jpg)
% % Convolution of image with
Gaussian
Gx = conv2(G, dx, 'same');
Gy = conv2(G, dy, 'same');
% Convolution of image with Gx and
Gy
Ix = conv2(img, Gx, 'same');
Iy = conv2(img, Gy, 'same');
Ix Iy
![Page 56: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/56.jpg)
Canny Edge Implementationangle = atan2(Iy, Ix);
mag = sqrt(Iy.^2 + Ix.^2);
Gradient Magnitude
![Page 57: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/57.jpg)
![Page 58: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/58.jpg)
Canny Edge Implementationangle = atan2(Iy, Ix);
mag = sqrt(Iy.^2 + Ix.^2);
Gradient Angle
![Page 59: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/59.jpg)
![Page 60: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/60.jpg)
Canny Edge Implementation
%% Non-Maximum Supression
edge = non_maximum_suppression(magnitude, angle, edge);
Localized edge
low = threshold_low * max(edge(:));
high = threshold_high * max(edge(:));
linked_edge = hysteresis_thresholding(low, high);
![Page 61: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/61.jpg)
![Page 62: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/62.jpg)
![Page 63: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/63.jpg)
![Page 64: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/64.jpg)
![Page 65: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/65.jpg)
% % Convolution of image with
Gaussian
Gx = conv2(G, dx, 'same');
Gy = conv2(G, dy, 'same');
% Convolution of image with Gx and
Gy
Ix = conv2(img, Gx, 'same');
Iy = conv2(img, Gy, 'same');
Ix Iy
![Page 66: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/66.jpg)
![Page 67: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/67.jpg)
![Page 68: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/68.jpg)
![Page 69: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/69.jpg)
![Page 70: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/70.jpg)
![Page 71: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/71.jpg)
![Page 72: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/72.jpg)
![Page 73: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/73.jpg)
![Page 74: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/74.jpg)
Canny Edge Implementationimg = imread (‘image.png');
img = rgb2gray(img);
img = double (img);
% Value for high and low thresholding
threshold_low = 0.035;
threshold_high = 0.175;
%% Gaussian filter (https://en.wikipedia.org/wiki/Canny_edge_detector)
G = [2, 4, 5, 4, 2; 4, 9, 12, 9, 4;5, 12, 15, 12, 5;4, 9, 12, 9, 4;2, 4, 5, 4, 2];
G = 1/159.* G;
%Filter for horizontal and vertical direction
dx = [1 -1];
dy = [1; -1];
![Page 75: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/75.jpg)
Canny Edge Implementation% % Convolution of image with
Gaussian
Gx = conv2(G, dx, ‘full');
Gy = conv2(G, dy, ‘full');
% Convolution of image with Gx and
Gy
Ix = conv2(img, Gx, 'same');
Iy = conv2(img, Gy, 'same'); Ix Iy
![Page 76: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/76.jpg)
Canny Edge Implementation
angle = atan2(Iy, Ix);
mag = sqrt(Iy.^2 + Ix.^2);
Gradient Magnitude Gradient Angle
![Page 77: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/77.jpg)
![Page 78: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/78.jpg)
![Page 79: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/79.jpg)
0 1
1
1
0
0
1
1
0
Canny Edge Implementation%% Non-Maximum Supression
edge =
non_maximum_suppression(magnitude,
angle, edge);
gradient
0 1
1
1
0
0
0
0
0
NMSLocalized edge
0 1
1
0
0
0
0
0
0
0 1
1
1
0
0
0
0
0
hysteresis
threshold_high threshold_low
low = threshold_low * max(edge(:));
high = threshold_high * max(edge(:));
linked_edge = hysteresis_thresholding(low, high);
![Page 80: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/80.jpg)
![Page 81: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/81.jpg)
![Page 82: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/82.jpg)
![Page 83: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/83.jpg)
![Page 84: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/84.jpg)
Ix Iy
![Page 85: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/85.jpg)
% % Convolution of image with
Gaussian
Gx = conv2(G, dx, ‘full');
Gy = conv2(G, dy, ‘full');
% Convolution of image with Gx and
Gy
Ix = conv2(img, Gx, 'same');
Iy = conv2(img, Gy, 'same');
Ix Iy
![Page 86: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/86.jpg)
![Page 87: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/87.jpg)
![Page 88: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/88.jpg)
http://www.cfar.umd.edu/~fer/optical/index.html
Cornelia Fermüller
![Page 89: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/89.jpg)
Image Scale
![Page 90: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/90.jpg)
![Page 91: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/91.jpg)
![Page 92: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/92.jpg)
![Page 93: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/93.jpg)
Different scale of image encodes different edge response.
![Page 94: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/94.jpg)
Image Pyramids
Known as a Gaussian Pyramid [Burt and Adelson, 1983]
• In computer graphics, a mip map [Williams, 1983]
• A precursor to wavelet transform
![Page 95: Code Jb = rgb2gray(J); imagesc(Jb);axis image; colormap ...cis581/Lectures/Fall2017/CIS581Fall17-04.pdfConvolution without Looping using meshgrid >> [x,y] = meshgrid(1:5,1:3) x = 1](https://reader033.vdocument.in/reader033/viewer/2022042201/5ea0d6777efe4b527d37f3b5/html5/thumbnails/95.jpg)
Figure from David Forsyth