{"cells":[
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "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\n#print(check_output([\"ls\", \"../input/train/c0\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output."
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "from skimage.color.adapt_rgb import adapt_rgb, each_channel, hsv_value\nfrom skimage import filters,feature\nfrom skimage.color import rgb2gray\nfrom skimage import io,transform\nfrom skimage.exposure import rescale_intensity\nimport matplotlib.pyplot as plt\n%matplotlib inline\n\n@adapt_rgb(each_channel)\ndef sobel_each(image):\n    return filters.sobel(image)\n\n\n@adapt_rgb(hsv_value)\ndef sobel_hsv(image):\n    return filters.sobel(image)\n\ndef as_gray(image_filter, image, *args, **kwargs):\n    gray_image = rgb2gray(image)\n    return image_filter(gray_image, *args, **kwargs)\n\n@adapt_rgb(as_gray)\ndef sobel_gray(image):\n    return filters.sobel(image)\n\n"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "im = io.imread('../input/train/c0/img_100026.jpg')\nplt.imshow(im)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "img = transform.resize(im,(120,160))\nrgb_sobel = rescale_intensity(1 - sobel_each(img))\nhsv_sobel = rescale_intensity(1 - sobel_hsv(img))\ngrey_sobel = rescale_intensity(1 - sobel_gray(img))\nrgb_hsv_sobel = rescale_intensity(1 - sobel_hsv(rgb_sobel))\nrgb_gray_sobel = rescale_intensity(1 - sobel_gray(rgb_sobel))\nhsv_gray_sobel = rescale_intensity(1 - sobel_gray(hsv_sobel))\n\nfig = plt.figure(1,figsize=(10,15))\nplt.subplot(131)\nplt.imshow(rgb_sobel)\n\n\n\nplt.subplot(133)\nplt.imshow(feature.canny(grey_sobel))\nhsv_sobel = rescale_intensity(1 - sobel_hsv(grey_sobel))\nplt.subplot(132)\nplt.imshow(hsv_sobel)"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "plt.imshow(rgb2gray(im))"
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}