Python - University of Pennsylvania
Edge Detection
MATLAB:
Jb = rgb2gray(J); imagesc(Jb);axis image; colormap(gray); bw = edge(Jb,'canny');
Python:
import matplotlib.pyplot as plt from PIL import Image import numpy as np from skimage.feature import canny
Jb = np.array(Image.open('demo.png').convert('L')) plt.figure(); plt.imshow(Jb, cmap='gray') bw = canny(Jb)
Numerical Image Filtering
MATLAB:
Filter
# Looping through all pixels
-0.8
[nr,nc] = size(Jb);
J_out = zeros(nr,nc);
2.0
for i=1:nr,
for j=1:nc;
-0.8
if (i1),
J_out(i,j) = 2*Jb(i,j) - 0.8*Jb(i+1,j) - 0.8*Jb(i-1,j);
else
nc
J_out(i,j) = Jb(i,j); end
(i,j)
(i-1,j)
end
(i+1,j)
end
figure; imagesc(J_out);colormap(gray)
nr
Computation time: 0.050154 sec
Python:
nr, nc = Jb.shape[0], Jb.shape[1]
Array index start at 0
J_out = np.zeros((nr,nc))
for i in range(nr):
for j in range(nc):
if (i < nr - 1) & (i > 0):
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]
plt.imshow(J_out, cmap='gray')
plt.show()
Computation time: 1.45 sec Python for loop is slower than Matlab
Numerical Image Filtering
Convolution without Looping using meshgrid
>> [x,y] = meshgrid(1:5,1:3)
x=
row
1 2 3 4 5 1 2 3 4 5
column
1 2 3 4 5
y=
row
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3
column
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- matplotlib eds uga
- stereo vision
- documentation
- sesg6025 coursework fractals and integration
- 1 getting up and running 2 loading and viewing your first
- 1 lecture 15 data visualization
- matplotlib 2d and 3d plotting in python
- cs 4476 introduction to computer vision fall 2018 ps0
- python university of pennsylvania
Related searches
- university of pennsylvania finance depart
- university of pennsylvania finance program
- university of pennsylvania finance department
- university of pennsylvania finance master
- university of pennsylvania masters programs
- university of pennsylvania online masters
- university of pennsylvania online programs
- university of pennsylvania wharton
- university of pennsylvania mba tuition
- university of pennsylvania graduate programs
- university of pennsylvania phd programs
- university of pennsylvania transfer