diff --git a/count_rice.ipynb b/count_rice.ipynb index f8bb510..8205c9d 100644 --- a/count_rice.ipynb +++ b/count_rice.ipynb @@ -1,12 +1,5 @@ { "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# wlXlv Image" - ] - }, { "cell_type": "code", "execution_count": null, @@ -19,6 +12,7 @@ "from PIL import Image\n", "from scipy import ndimage\n", "\n", + "\n", "def count_rice_number(img_path):\n", " # Load the uploaded image\n", " img = cv2.imread(img_path)\n", @@ -31,6 +25,7 @@ " ##### Add MedianFilter to remove salt and pepper noise #####\n", " ############################################################\n", " gray = cv2.medianBlur(gray, 3)\n", + " gray = cv2.GaussianBlur(gray, (3, 3), 0)\n", "\n", " #############################################\n", " ######## Apply Fourier Transform ############\n", diff --git a/crop_frame.ipynb b/crop_frame.ipynb index 2829aa2..a15304f 100644 --- a/crop_frame.ipynb +++ b/crop_frame.ipynb @@ -7,11 +7,14 @@ "outputs": [], "source": [ "import math\n", + "\n", "import cv2\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from PIL import Image\n", "from scipy import ndimage\n", + "\n", + "\n", "def crop_cell(img_path):\n", " # Load the uploaded image\n", " img = cv2.imread(img_path)\n", @@ -71,7 +74,7 @@ " \n", " ######### PREPROCESS THE ROTATED IMAGE TO DETECT CELL ###########\n", " ## Convert image to grayscale image \n", - " gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n", + " gray = cv2.cvtColor(rotated_image_raw, cv2.COLOR_BGR2GRAY)\n", " ## Apply Gaussian Blur for smoothing\n", " gray = cv2.GaussianBlur(gray, (5, 5), 4) \n", " # Define the gamma value\n", @@ -132,7 +135,7 @@ " sorted_contours = sort_contours(filtered_contours)\n", " \n", " print(f\"Number of cells : {len(sorted_contours)}\")\n", - " fig, ax = plt.subplots(math.ceil(len(sorted_contours) / 4), 4, figsize=(12, 6))\n", + " fig, ax = plt.subplots(math.ceil(len(sorted_contours) / 4), 4, figsize=(8, 6))\n", " for a in ax.ravel():\n", " a.axis('off')\n", " print(ax.shape)\n",