{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport cv2 \nimport matplotlib.pyplot as plt\n\nnp.random.seed(55)\nimport os\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv('../input/train.csv')\n#data.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h1>Applying Ben's Preprocessing</h1>\n\nSo in this kernel I will try to apply the Ben's preprocessing that is popular in APTOS competition. This preprocessing method dated back to previous diabetic retinopathy competitions (Ben Graham is the competition winner). \n\nAccording to the previous diabetic retinopathy winner the reasoning behind doing this preprocessing (points on the bracket is why I believe this might work for this competition) :\n* Enhance finer details (Enhance thin strokes)\n* Tackle different illumination problem. (Background color differences especially between B/W and Color scans)"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"view_count =  15\ni_chk = np.random.randint(0,len(data), size = view_count)\nsample_imgs = []\nben_sample_imgs = []\nfile_list = ['../input/train_images/{}.jpg'.format(data['image_id'].values[i_chk[i]]) for i in range(view_count)]\n\nfor i in range(view_count) :\n    sample_img = cv2.imread(file_list[i])\n    sample_img = cv2.cvtColor(sample_img,cv2.COLOR_BGR2RGB)\n    sample_imgs.append(sample_img)\n    ben_sample_imgs.append(cv2.addWeighted (sample_img,4, cv2.GaussianBlur(sample_img, (0,0) , 10) ,-4 ,128))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"for i in range(15) :\n    fig , ax = plt.subplots(1,2,figsize = (12,15))\n    ax[0].imshow(sample_imgs[i])\n    ax[1].imshow(ben_sample_imgs[i])\n    #plt.autoscale(tight = 'True' , axis = 'y')\n    ax[0].set_title(data['image_id'].values[i_chk[i]], y = 1)\n    ax[1].set_title(str(data['image_id'].values[i_chk[i]]) + ' with preprocess', y = 1)\n    ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h2>Observations</h2>\nThere are few things that I observed if I do this Image processing \n* The difference between Colored scan and B/W scan are less apparent\n* Applies more contrasts to the text and might also enhance thinner strokes at the end of each stroke.\n\nHowever I feel this also introduce minor problem as it also enhance the character from the back page.\n\nKeep in mind that these differences are only from my human eyes, and might not applies directly to the model.\n\nP.S. : This kernel is only a \"what-if\" kernel that is made out of my curiousity. \nPlease do not judge harshly I am still a noob and correct me if there are any mistakes on the comment section."}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}