<jupyter_start><jupyter_text>Vertical Edge Detection<jupyter_code>'''Create numpy array as image1 and display it.
[[10 10 10  0  0  0]
 [10 10 10  0  0  0]
 [10 10 10  0  0  0]
 [10 10 10  0  0  0]
 [10 10 10  0  0  0]
 [10 10 10  0  0  0]]
 '''

image1 = np.array(
  [[10, 10, 10, 0, 0, 0]] * 6
)

display(image1)
'''Create vertical_edge_kernel and display it:
[[ 1  0 -1]
 [ 1  0 -1]
 [ 1  0 -1]]
'''

vertical_edge_kernel = np.array([[1, 0, -1]] * 3)
display(vertical_edge_kernel)
# Call your convolution2d() and display the result.
display(convolution2d(image1, vertical_edge_kernel))
'''Create a numpy array and display it:
[[ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]]
'''
image2 = np.array(
  [[0, 0, 0, 10, 10, 10]] * 6
)

display(image2)
# Call your convolution2d() and display the result.
display(convolution2d(image2, vertical_edge_kernel))<jupyter_output>[[  0 -30 -30   0]
 [  0 -30 -30   0]
 [  0 -30 -30   0]
 [  0 -30 -30   0]]<jupyter_text>Horizontal Edge Detection<jupyter_code>'''Create horizontal_edge_kernel and display it:
[[ 1  1  1]
 [ 0  0  0]
 [-1 -1 -1]]

'''
horizontal_edge_kernel = np.rot90(np.array([[1, 0, -1]]*3), 3)
horizontal_edge_kernel = np.array(
    [[1, 1, 1,], [0, 0, 0], [-1, -1, -1]]
)
horizontal_edge_kernel = np.array([[1, 0, -1]] * 3).T

display(horizontal_edge_kernel)
'''Create an numpy array and display it:
[[10 10 10  0  0  0]
 [10 10 10  0  0  0]
 [10 10 10  0  0  0]
 [ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]
 [ 0  0  0 10 10 10]]
'''
image3 = np.array(
  [[10, 10, 10, 0, 0, 0]] * 3 + [[0, 0, 0, 10, 10, 10]] * 3
)

display(image3)
'''Value 0 means there is no edge detected.
Value 30 means 3 bright pixels on top, 3 dark pixels on the bottom.
Value -30 means 3 dark pixels on top, 3 bright pixels on the bottom.
Value 10 is similar to 30 some part of the edge is not bright pixel on top and dark pixel on the bottom.
Value -10 is similar to -30 some part of the edge is not dark pixel on top and bright pixel on the bottom.

'''
# Call your convolution2d(), store it as image4, and display the result.
image4 = convolution2d(image3, horizontal_edge_kernel)
display(image4)
# Apply vertical edge kernel on the previous feature maps to see the result.
display(vertical_edge_kernel)
display(convolution2d(image4, vertical_edge_kernel))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1317764804003336, 'fraction_numerical': 0.12760633861551293, 'mean_word_length': 3.2385159010600706, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '155977', 'license': 'MIT', 'n_tokens_mistral': 1114, 'n_tokens_neox': 925, 'n_words': 373, 'path': 'day11/lab/lab10-problem1-convolution.ipynb', 'repo_name': 'WhatTheFar/practical-ai-bootcamp', 'size': '2398'}