{"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":"code","source":"#COMP4121 EDA NOTEBOOK\n\nimport numpy as np\nimport pandas as pd\n%matplotlib inline\nimport matplotlib.pyplot as plt\nimport cv2\n\ntrain_image_path = '../input/resized-plant2021/img_sz_256/' #uses smaller version of dataset for efficiency\ntest_image_path = '../input/plant-pathology-2021-fgvc8/test_images/'\ntrain_df_path = '../input/plant-pathology-2021-fgvc8/train.csv'\ntest_df_path = '../input/plant-pathology-2021-fgvc8/sample_submission.csv'\n\ntrain_df = pd.read_csv(train_df_path)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-12-04T12:30:08.761469Z","iopub.execute_input":"2021-12-04T12:30:08.761977Z","iopub.status.idle":"2021-12-04T12:30:08.788274Z","shell.execute_reply.started":"2021-12-04T12:30:08.761944Z","shell.execute_reply":"2021-12-04T12:30:08.787427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['labels'].value_counts().plot(kind='bar')","metadata":{"execution":{"iopub.status.busy":"2021-12-04T12:30:08.790319Z","iopub.execute_input":"2021-12-04T12:30:08.790677Z","iopub.status.idle":"2021-12-04T12:30:09.012117Z","shell.execute_reply.started":"2021-12-04T12:30:08.790611Z","shell.execute_reply":"2021-12-04T12:30:09.011134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"blue_minimums = []\nblue_maximums = []\nblue_means = []\n\ngreen_minimums = []\ngreen_maximums = []\ngreen_means = []\n\nred_minimums = []\nred_maximums = []\nred_means = []\n\nn = 0\n\nfor image_path in train_df['image'].tolist():\n    if n >= 100: break\n    img = cv2.imread(train_image_path + image_path) #cv2 reads image into numpy array\n    #openCV uses BGR image formatting, so\n    blue_channel = img[:,:,0]\n    green_channel = img[:,:,1]\n    red_channel = img[:,:,2]\n    \n\n    \n    #extract features\n    blue_minimums.append(np.min(blue_channel))\n    blue_maximums.append(np.max(blue_channel).astype(np.int16))\n    blue_means.append(np.mean(blue_channel))\n    \n    green_minimums.append(np.min(green_channel))\n    green_maximums.append(np.max(green_channel).astype(np.int16))\n    green_means.append(np.mean(green_channel))\n\n    red_minimums.append(np.min(red_channel))\n    red_maximums.append(np.max(red_channel).astype(np.int16))\n    red_means.append(np.mean(red_channel))\n    \n    n+=1\n    \nprint(blue_means)","metadata":{"execution":{"iopub.status.busy":"2021-12-04T12:30:09.013215Z","iopub.execute_input":"2021-12-04T12:30:09.014069Z","iopub.status.idle":"2021-12-04T12:30:10.451884Z","shell.execute_reply.started":"2021-12-04T12:30:09.014013Z","shell.execute_reply":"2021-12-04T12:30:10.451013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(np.array(blue_means), density=True, bins=20, color=\"blue\")\nplt.show()\nplt.hist(np.array(green_means), density=True, bins=20, color=\"green\")\nplt.show()\nplt.hist(np.array(red_means), density=True, bins=20, color=\"red\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-04T12:31:45.246186Z","iopub.execute_input":"2021-12-04T12:31:45.246906Z","iopub.status.idle":"2021-12-04T12:31:46.008386Z","shell.execute_reply.started":"2021-12-04T12:31:45.246863Z","shell.execute_reply":"2021-12-04T12:31:46.006742Z"},"trusted":true},"execution_count":null,"outputs":[]}]}