{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"This code in written with the help of PyTorch Image Segmentation Demo:\n\nhttps://learnopencv.com/pytorch-for-beginners-semantic-segmentation-using-torchvision/","metadata":{}},{"cell_type":"markdown","source":"**# Steps\n\n1. reading CSV file\n","metadata":{}},{"cell_type":"code","source":"%matplotlib inline\nimport math\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport os\n\nfrom skimage import measure\nfrom skimage.color import rgb2gray\nfrom skimage.util import img_as_ubyte\nfrom skimage import io\nfrom skimage.feature import greycomatrix, greycoprops","metadata":{"execution":{"iopub.status.busy":"2021-09-09T14:51:40.116015Z","iopub.execute_input":"2021-09-09T14:51:40.116375Z","iopub.status.idle":"2021-09-09T14:51:40.132717Z","shell.execute_reply.started":"2021-09-09T14:51:40.116346Z","shell.execute_reply":"2021-09-09T14:51:40.131675Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imgList = os.listdir('../input/siimisic-melanoma-512-resized-images/test')","metadata":{"execution":{"iopub.status.busy":"2021-09-09T14:51:40.134342Z","iopub.execute_input":"2021-09-09T14:51:40.134636Z","iopub.status.idle":"2021-09-09T14:51:40.660566Z","shell.execute_reply.started":"2021-09-09T14:51:40.134603Z","shell.execute_reply":"2021-09-09T14:51:40.65951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imgPath = []\nfor path in imgList:\n    pathImg = f'../input/siimisic-melanoma-512-resized-images/test/{path}'\n    imgPath.append(pathImg)\nimgPath.sort()\n","metadata":{"execution":{"iopub.status.busy":"2021-09-09T14:51:40.66186Z","iopub.execute_input":"2021-09-09T14:51:40.662139Z","iopub.status.idle":"2021-09-09T14:51:40.690215Z","shell.execute_reply.started":"2021-09-09T14:51:40.662114Z","shell.execute_reply":"2021-09-09T14:51:40.689111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = []\nay = []\nfor patch in imgPath:\n    image_rgb = io.imread(patch)\n    image = img_as_ubyte(rgb2gray(image_rgb))\n    glcm = greycomatrix(image, distances=[4], angles=[0], levels=256)\n    ax.append(greycoprops(glcm, 'dissimilarity')[0, 0])\n    ay.append(greycoprops(glcm, 'correlation')[0, 0])","metadata":{"execution":{"iopub.status.busy":"2021-09-09T14:51:40.692178Z","iopub.execute_input":"2021-09-09T14:51:40.692461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"#  4.18879, 2.35619, 3.92699, 1.74533, 3.49066, 5.23599, 5.93412\nbx = []\nby = []\nfor patch in imgPath:\n    image_rgb = io.imread(patch)\n    image = img_as_ubyte(rgb2gray(image_rgb))\n    glcm = greycomatrix(image, distances=[4], angles=[0.785398], levels=256)\n    bx.append(greycoprops(glcm, 'dissimilarity')[0, 0])\n    by.append(greycoprops(glcm, 'correlation')[0, 0])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cx = []\ncy = []\nfor patch in imgPath:\n    image_rgb = io.imread(patch)\n    image = img_as_ubyte(rgb2gray(image_rgb))\n    glcm = greycomatrix(image, distances=[4], angles=[1.0472], levels=256)\n    cx.append(greycoprops(glcm, 'dissimilarity')[0, 0])\n    cy.append(greycoprops(glcm, 'correlation')[0, 0])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dx = []\ndy = []\nfor patch in imgPath:\n    image_rgb = io.imread(patch)\n    image = img_as_ubyte(rgb2gray(image_rgb))\n    glcm = greycomatrix(image, distances=[4], angles=[2.0944], levels=256)\n    dx.append(greycoprops(glcm, 'dissimilarity')[0, 0])\n    dy.append(greycoprops(glcm, 'correlation')[0, 0])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ex = []\ney = []\nfor patch in imgPath:\n    image_rgb = io.imread(patch)\n    image = img_as_ubyte(rgb2gray(image_rgb))\n    glcm = greycomatrix(image, distances=[4], angles=[3.14159], levels=256)\n    ex.append(greycoprops(glcm, 'dissimilarity')[0, 0])\n    ey.append(greycoprops(glcm, 'correlation')[0, 0])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fx = []\nfy = []\nfor patch in imgPath:\n    image_rgb = io.imread(patch)\n    image = img_as_ubyte(rgb2gray(image_rgb))\n    glcm = greycomatrix(image, distances=[4], angles=[4.18879], levels=256)\n    fx.append(greycoprops(glcm, 'dissimilarity')[0, 0])\n    fy.append(greycoprops(glcm, 'correlation')[0, 0])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imgName = os.listdir('../input/siimisic-melanoma-512-resized-images/test')\nimgName.sort()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame(dict(image_name=imgName, ax=ax, ay=ay, bx=bx, by=by, cx=cx, cy=cy, dx=dx, dy=dy, ex=ex, ey=ey, fx=fx, fy=fy))\nsubmission = submission.sort_values('image_name') \nsubmission.to_csv('submission.csv', index=False)\nsubmission.head()","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}