{"cells":[{"cell_type":"markdown","metadata":{"_cell_guid":"10fbafb1-466e-ce00-7408-ece8b18d6e42"},"source":"> *  red: adult males\n> * magenta: subadult males\n> * brown: adult females\n> * blue: juveniles\n>* green: pups"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"980cb736-9efc-bd4c-2908-6c4d905c4615"},"outputs":[],"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."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"d6c91084-17ed-1eb8-59ed-ed76803e76c4"},"outputs":[],"source":"from skimage.io import imread, imshow\nfrom skimage.util import crop\nimport cv2\nimport matplotlib.pyplot as plt\ncropped_dotted = cv2.cvtColor(cv2.imread('../input/TrainDotted/0.jpg'), cv2.COLOR_BGR2RGB)\ncropped_raw = cv2.cvtColor(cv2.imread('../input/Train/0.jpg'), cv2.COLOR_BGR2RGB)\n\nfig = plt.figure(figsize=(12,8))\nax = fig.add_subplot(1,2,1)\nplt.imshow(cropped_dotted)\nax = fig.add_subplot(1,2,2)\nplt.imshow(cropped_raw)\n\ndiff = cv2.subtract(cropped_dotted, cropped_raw)\ndiff = diff/diff.max()\nprint(diff.min())\nplt.figure(figsize=(12,8))\ndiff_pic = (diff > 0.2).astype(float)\nprint diff_pic\nplt.imshow(diff_pic)\nplt.grid(False)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"84a9b2fe-0687-de2a-c999-f30beae20b01"},"outputs":[],"source":"import pandas as pd\nimport numpy as np\nimport glob\n\ntrain_csv = pd.read_csv('../input/Train/train.csv')\ntrain_img = glob.glob('../input/Train/*.jpg')\ntrain_dotted_img = glob.glob('../input/TrainDotted/*.jpg')\nsubmission = pd.read_csv('../input/sample_submission.csv')\nprint(len(train_csv),len(train_img), len(train_dotted_img), len(submission))"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"506c8ba1-abd7-6b16-e17b-7cb6f0967af1"},"outputs":[],"source":"from PIL import Image, ImageDraw, ImageFilter\nimport matplotlib.pyplot as plt\n%matplotlib inline\nfrom PIL import ImageChops\n\nplt.rcParams['figure.figsize'] = (12.0, 6.0)\nim1 = Image.open(train_img[9])\nim2 = Image.open(train_dotted_img[9])\nim_diff = ImageChops.difference(im1, im2)\nprint(im_diff)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"0960f2e1-f708-e985-f92c-7f8f9b9ce43f"},"outputs":[],"source":"w, h = im1.size\nmax_x = 0\nmax_y = 0\nmin_x = 0\nmin_y = 0\np1 = im1.load() #get pixels\nfor x in range(w):\n    for y in range(h):\n        if p1[x,y] != (0, 0, 0):\n            if x < min_x and y< min_y :\n                min_x = x\n                min_y = y\n            if x > max_x and y>max_y :\n                max_x = x\n                max_y = y\nplt.imshow(im_diff); plt.axis('off')"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"3e23e69b-9f61-95df-fa23-7a1affd6de14"},"outputs":[],"source":""}],"metadata":{"_change_revision":0,"_is_fork":false,"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}