{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":0,"cells":[{"metadata":{"_cell_guid":"e2702e0f-fc3e-628f-b980-980c78aab958","_active":false,"collapsed":false},"source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":1,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"6c6c9a4c-ac62-c590-6c53-73bb9ca43ed5","_active":false,"collapsed":false},"source":"import os\nfrom matplotlib import pyplot as plt\nimport cv2","execution_count":16,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"1ce87e83-d3f2-5998-2b98-b11d14f180d8","_active":false,"collapsed":false},"source":"imagesNames = os.listdir('../input/Train')","execution_count":28,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"577800b9-cf63-ff29-ab64-8a27a2c14746","_active":false,"collapsed":false},"source":"imagesNames","execution_count":29,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"057ffa91-a1a6-1e9a-265d-e963cb769931","_active":false,"collapsed":false},"source":"imageTest = cv2.imread('../input/TrainDotted/0.jpg')\nplt.imshow(imageTest[1000:1500,1000:1500,:])\nprint(imageTest.shape)","execution_count":23,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"76c5016a-c740-8ce5-8a7d-307eca8bf73d","_active":false,"collapsed":false},"source":"**Functions**","execution_count":null,"cell_type":"markdown","outputs":[]},{"metadata":{"_cell_guid":"479bb7a0-7495-5097-5d45-a8f6c5dc12e5","_active":false,"collapsed":false},"source":"def extractBlobs(image):\n\n    # Setup SimpleBlobDetector parameters.\n    params = cv2.SimpleBlobDetector_Params()\n    params.minThreshold = 2\n    params.filterByArea = False\n    params.filterByColor = True;\n    params.blobColor = 255\n    params.filterByCircularity = False\n    params.filterByConvexity = False\n    \n    # Create detector\n    detector = cv2.SimpleBlobDetector_create(params)\n\n    img_out = np.copy(image[:,:,2])\n    img=image[:,:,2].astype(np.uint8)    \n    # Detect blobs.\n    keypoints = detector.detect(img)\n    \n    return len(keypoints)","execution_count":30,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"b30e1eb3-03f5-bd62-1d1a-fe4fe1609126","_active":false,"collapsed":false},"source":"extractBlobs(imageTest)","execution_count":31,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"20e4d70d-6b26-d224-5b6a-9d445ab2bf7a","_active":true,"collapsed":false},"source":"pd.read_csv('../input/Train/train.csv')","execution_count":34,"cell_type":"code","outputs":[],"execution_state":"idle"}]}