{"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":"f35072d1-c21f-76a5-12af-46e1f071003a","_active":false,"collapsed":false},"source":"ttt","execution_count":null,"cell_type":"markdown","outputs":[]},{"metadata":{"_cell_guid":"ae803dfe-b55c-7655-1d24-0c4aba528dd0","_active":true,"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 \nfrom sklearn.cluster import spectral_clustering\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom scipy import misc\nimport scipy as sp\nimport matplotlib.pyplot as plt\nfrom sklearn.feature_extraction import image\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.\nf='../input/train/Type_1/0.jpg'\n\nimgOrig =misc.imread(f) \nprint(imgOrig.shape)\nplt.subplot(131)\nplt.imshow(imgOrig,cmap=plt.cm.gray)\nplt.show()\nimgOrig = sp.misc.imresize(imgOrig, 0.10)\ngraph = image.img_to_graph(imgOrig)\n\nbeta = 5\neps = 1e-4\ngraph.data = np.exp(-beta * graph.data / graph.data.std()) + eps\n\nN_REGIONS = 3\nassign_labels= 'discretize';\nlabels = spectral_clustering(graph, n_clusters=N_REGIONS,assign_labels=assign_labels)      \nlabels = labels.reshape(face.shape)    \nplt.imshow(face*labels[0], cmap=plt.cm.gray)","execution_count":5,"cell_type":"code","outputs":[],"execution_state":"busy"},{"metadata":{"_cell_guid":"c3c1d3ed-b00a-7a3e-59b3-e4bb1b5f80b7","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[]}]}