Commit 23aeccb1 authored by Taddeüs Kroes's avatar Taddeüs Kroes

improc ass4: Added 'jet' plot option to gauss.py.

parent 95bc6bd9
...@@ -77,7 +77,7 @@ def plot_kernel(W, ax): ...@@ -77,7 +77,7 @@ def plot_kernel(W, ax):
def exit_with_usage(): def exit_with_usage():
"""Print an error message with the program's usage and exit the program.""" """Print an error message with the program's usage and exit the program."""
print 'Usage: python %s ( 2d SCALE | 1d SCALE IORDER JORDER' \ print 'Usage: python %s ( 2d SCALE | 1d SCALE IORDER JORDER' \
' | timer METHOD [ REPEAT ] )' % argv[0] ' | timer METHOD [ REPEAT ] | jet SCALE )' % argv[0]
exit(1) exit(1)
if __name__ == '__main__': if __name__ == '__main__':
...@@ -87,7 +87,7 @@ if __name__ == '__main__': ...@@ -87,7 +87,7 @@ if __name__ == '__main__':
F = imread('cameraman.png') F = imread('cameraman.png')
if argv[1] == '2d': if argv[1] == '2d':
# Calculate and plot the convolution of the given scale """Calculate and plot the convolution of the given scale."""
if len(argv) < 3: if len(argv) < 3:
exit_with_usage() exit_with_usage()
...@@ -102,11 +102,11 @@ if __name__ == '__main__': ...@@ -102,11 +102,11 @@ if __name__ == '__main__':
subplot(133) subplot(133)
imshow(G, cmap='gray') imshow(G, cmap='gray')
elif argv[1] == '1d': elif argv[1] == '1d':
"""Calculate the gaussian kernel using derivatives of the specified
order in both directions."""
if len(argv) < 5: if len(argv) < 5:
exit_with_usage() exit_with_usage()
# Calculate the gaussian kernel using derivatives of the specified
# order in both directions
s = float(argv[2]) s = float(argv[2])
iorder = int(argv[3]) iorder = int(argv[3])
jorder = int(argv[4]) jorder = int(argv[4])
...@@ -125,6 +125,7 @@ if __name__ == '__main__': ...@@ -125,6 +125,7 @@ if __name__ == '__main__':
subplot(133) subplot(133)
imshow(G, cmap='gray') imshow(G, cmap='gray')
elif argv[1] == 'timer': elif argv[1] == 'timer':
"""Time the performance of a 1D/2D convolution and plot the results."""
if len(argv) < 3: if len(argv) < 3:
exit_with_usage() exit_with_usage()
...@@ -157,6 +158,25 @@ if __name__ == '__main__': ...@@ -157,6 +158,25 @@ if __name__ == '__main__':
xlabel('s') xlabel('s')
ylabel('time (s)') ylabel('time (s)')
plot(S, times, 'o-') plot(S, times, 'o-')
elif argv[1] == 'jet':
"""Show a 2d jet Gaussian plot of the image."""
if len(argv) < 3:
exit_with_usage()
s = float(argv[2])
subplot(331)
imshow(gD(F, s, 0, 0), cmap='gray')
subplot(334)
imshow(gD(F, s, 1, 0), cmap='gray')
subplot(335)
imshow(gD(F, s, 0, 1), cmap='gray')
subplot(337)
imshow(gD(F, s, 2, 0), cmap='gray')
subplot(338)
imshow(gD(F, s, 1, 1), cmap='gray')
subplot(339)
imshow(gD(F, s, 0, 2), cmap='gray')
else: else:
exit_with_usage() exit_with_usage()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment