{"cells":[{"metadata":{"_uuid":"9c02122ffd2a56cd4d81275a703de255bf3dcb50","_cell_guid":"1c408096-e2ed-4b1a-96dc-d97f04576a0c"},"cell_type":"markdown","source":"# Exercise Intro\n\nTo build and test your intuition for convolutions, you will design a vertical line detector.  We'll apply it to each part of an image to create a new tensor showing where there are vertical lines.\n\n![Imgur](https://i.imgur.com/op9Maqr.png)\n\n## Import Utility Functions\nWe'll use some small utilty functions to load raw image data, visualize the results and give hints on your answert, etc.  Don't worry about these, but execute the next cell to load the utility functions.\n"},{"metadata":{"_uuid":"1c812b255b9e577cd5f5118823ad3c7725bc8872","_cell_guid":"ee82df62-e608-4bc5-8262-f6ad4961054b","collapsed":true,"trusted":true},"cell_type":"code","source":"import sys\n# Add directory holding utility functions to path to allow importing\nsys.path.append('/kaggle/input/python-utility-code-for-deep-learning-exercises/utils')\nfrom exercise_1 import load_my_image, apply_conv_to_image, show, print_hints","execution_count":1,"outputs":[]},{"metadata":{"_uuid":"aef8e139775e21a4e01ad07547aa83a6f3a72919","_cell_guid":"805ef092-0efe-4a85-a0df-5e5d17404469"},"cell_type":"markdown","source":"## First Convolution: Horizontal Line Detector"},{"metadata":{"_uuid":"c8f6a7c3503c2bcc5922b1a01000b13fcdf7055e","_cell_guid":"8b1ac6d7-521e-4591-b076-af0be8185b45","collapsed":true,"trusted":true},"cell_type":"code","source":"# Detects bright pixels over dark pixels. \nhorizontal_line_conv = [[1, 1], \n                        [-1, -1]]","execution_count":2,"outputs":[]},{"metadata":{"_uuid":"bd7f2171bb84fa25e8a106b5834bf34ad2201d93","_cell_guid":"0ed4659f-9661-404d-8b0c-710bf4666425"},"cell_type":"markdown","source":"## Second Convolution: Vertical Line Detector"},{"metadata":{"_uuid":"22aff839d64cc10f7d1b88a845d4eac12cdf549e","_cell_guid":"51919a23-0fa4-4d60-b616-2cb96bccf0e7","collapsed":true,"trusted":true},"cell_type":"code","source":"vertical_line_conv = [[1, -1], \n                      [0, 0]]","execution_count":9,"outputs":[]},{"metadata":{"_uuid":"fbc4e47d0a4bb86166d858046cc7b6e65f7521e4","_cell_guid":"42ff7e62-aa38-4263-a8f5-86acaf5e82ae","trusted":true},"cell_type":"code","source":"conv_list = [horizontal_line_conv, vertical_line_conv]\n\noriginal_image = load_my_image()\nprint(\"Original image\")\nshow(original_image)\nfor conv in conv_list:\n    filtered_image = apply_conv_to_image(conv, original_image)\n    print(\"Output: \")\n    show(filtered_image)","execution_count":10,"outputs":[]}],"metadata":{"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}},"nbformat":4,"nbformat_minor":1}