{"cells":[{"metadata":{"_cell_guid":"ee82df62-e608-4bc5-8262-f6ad4961054b","_uuid":"1c812b255b9e577cd5f5118823ad3c7725bc8872","collapsed":true,"trusted":true},"cell_type":"code","source":"import sys\nfrom learntools.deep_learning.exercise_1 import load_my_image, apply_conv_to_image, show, print_hints","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"805ef092-0efe-4a85-a0df-5e5d17404469","_uuid":"aef8e139775e21a4e01ad07547aa83a6f3a72919"},"cell_type":"markdown","source":"# Example Convolution: Horizontal Line Detector\nHere is the convolution you saw in the video.  It's provided here as an example, and you shouldn't need to change it."},{"metadata":{"_cell_guid":"8b1ac6d7-521e-4591-b076-af0be8185b45","_uuid":"c8f6a7c3503c2bcc5922b1a01000b13fcdf7055e","collapsed":true,"trusted":true},"cell_type":"code","source":"# Detects bright pixels over dark pixels. \nhorizontal_line_conv = [[1, 1], \n                        [-1, -1]]","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"0ed4659f-9661-404d-8b0c-710bf4666425","_uuid":"bd7f2171bb84fa25e8a106b5834bf34ad2201d93"},"cell_type":"markdown","source":"# Your Turn: Vertical Line Detector\n\n**Replace the question marks with numbers to make a vertical line detector and uncomment both lines of code in the cell below.**"},{"metadata":{"_cell_guid":"51919a23-0fa4-4d60-b616-2cb96bccf0e7","_uuid":"22aff839d64cc10f7d1b88a845d4eac12cdf549e","collapsed":true,"trusted":true},"cell_type":"code","source":"vertical_line_conv = [[1, -1], \n                      [1, 1]]\nvertical_line_conv2 = [[1, -1], \n                      [1, -1]]","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"eb1d9588-cb01-45eb-a0f3-af81d4e3f164","_uuid":"bdbe9e7d79d138b493886c583969da62bcdee69a"},"cell_type":"markdown","source":"**Once you have created vertical_line_conv in the cell above, add it as an additional item to `conv_list` in the next cell. Then run that cell.**"},{"metadata":{"_cell_guid":"42ff7e62-aa38-4263-a8f5-86acaf5e82ae","_uuid":"fbc4e47d0a4bb86166d858046cc7b6e65f7521e4","collapsed":true,"trusted":true},"cell_type":"code","source":"conv_list = [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)\n\nconv_list = [vertical_line_conv2]\n\nfor conv in conv_list:\n    filtered_image = apply_conv_to_image(conv, original_image)\n    print(\"Output: (with -1 -1)\")\n    show(filtered_image)    ","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"182683d4-dd85-443d-b430-7c23e649112e","_uuid":"9813c870835696f2916b93c33ccf1639bc69cf6e"},"cell_type":"markdown","source":"\n**Above, you'll see the output of the horizontal line filter as well as the filter you added. If you got it right, the output of your filter will looks like this.**\n![Imgur](https://i.imgur.com/uR2ngvK.png)\n\n---\n# Keep Going\n**Now you are ready to [combine convolutions into powerful models](https://www.kaggle.com/dansbecker/building-models-from-convolutions). These models are fun to work with, so keep going.**\n\n---\n\nHave questions, comments or feedback?  Bring them to [the Learn forum](https://www.kaggle.com/learn-forum)\n\n**[Deep Learning Track Home](https://www.kaggle.com/education/deep-learning)**"}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"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"}},"nbformat":4,"nbformat_minor":1}