{
  "id": 393335,
  "title": "ROI methods, Yolo vs OpenCV",
  "url": "/competitions/rsna-breast-cancer-detection/discussion/393335",
  "author_name": "Pablo Larrosa",
  "post_date": "2023-03-09T00:01:37.541000",
  "votes": 0,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hi, I was going through the top ten solutions, many of them decide to use Yolo, could anyone tell me why you chose it instead of opencv, performance, better cropping?.</p>\n<p>Thank in advance.</p>",
  "messages": [
    {
      "id": 2174838,
      "postDate": "2023-03-09T12:39:21.843Z",
      "content": "<p>For example this function worked fine and get good results:</p>\n<p>def crop_image(img, show=True):<br>\n    # Binarize the image<br>\n    bin_pixels = cv2.threshold(img, 20, 255, cv2.THRESH_BINARY)[1]</p>\n<pre><code># Make contours around the binarized image, keep only the largest contour\ncontours, _ = cv2.findContours(bin_pixels, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\ncontour = max(contours, key=cv2.contourArea)\n\n# Create a mask from the largest contour\nmask = np.zeros(img.shape, np.uint8)\ncv2.drawContours(mask, [contour], -1, 255, cv2.FILLED)\n\n# Use bitwise_and to get masked part of the original image\nout = cv2.bitwise_and(img, mask)\n\n# get bounding box of contour\ny1, y2 = np.min(contour[:, :, 1]), np.max(contour[:, :, 1])\nx1, x2 = np.min(contour[:, :, 0]), np.max(contour[:, :, 0])\n\nx1 = int(0.99 * x1)\nx2 = int(1.01 * x2)\ny1 = int(0.99 * y1)\ny2 = int(1.01 * y2)\n\nif show:\n    plt.imshow(out[y1:y2, x1:x2], cmap=\"gray\") ; \n\nreturn out[y1:y2, x1:x2]\n</code></pre>\n<p>what I don't know is the plus that yolo gives you</p>",
      "rawMarkdown": "For example this function worked fine and get good results:\n\ndef crop_image(img, show=True):\n    # Binarize the image\n    bin_pixels = cv2.threshold(img, 20, 255, cv2.THRESH_BINARY)[1]\n   \n    # Make contours around the binarized image, keep only the largest contour\n    contours, _ = cv2.findContours(bin_pixels, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\n    contour = max(contours, key=cv2.contourArea)\n\n    # Create a mask from the largest contour\n    mask = np.zeros(img.shape, np.uint8)\n    cv2.drawContours(mask, [contour], -1, 255, cv2.FILLED)\n   \n    # Use bitwise_and to get masked part of the original image\n    out = cv2.bitwise_and(img, mask)\n    \n    # get bounding box of contour\n    y1, y2 = np.min(contour[:, :, 1]), np.max(contour[:, :, 1])\n    x1, x2 = np.min(contour[:, :, 0]), np.max(contour[:, :, 0])\n    \n    x1 = int(0.99 * x1)\n    x2 = int(1.01 * x2)\n    y1 = int(0.99 * y1)\n    y2 = int(1.01 * y2)\n    \n    if show:\n        plt.imshow(out[y1:y2, x1:x2], cmap=\"gray\") ; \n\n    return out[y1:y2, x1:x2]\n\nwhat I don't know is the plus that yolo gives you\n"
    },
    {
      "id": 2174378,
      "postDate": "2023-03-09T05:07:29.253Z",
      "content": "<p>OpenCV provides a wide range of computer vision functions and algorithms, YOLO is a specific object detection system based on deep learning. In fact, YOLO can be used in conjunction with OpenCV to perform object detection on images and videos using the features provided by OpenCV.<br>\nSo to take a wild guess is that to build the detection that the features of YOLO were more aligned with this project?</p>",
      "rawMarkdown": "OpenCV provides a wide range of computer vision functions and algorithms, YOLO is a specific object detection system based on deep learning. In fact, YOLO can be used in conjunction with OpenCV to perform object detection on images and videos using the features provided by OpenCV.\nSo to take a wild guess is that to build the detection that the features of YOLO were more aligned with this project?"
    },
    {
      "id": 2174203,
      "postDate": "2023-03-09T00:01:37.543Z",
      "content": "<p>Hi, I was going through the top ten solutions, many of them decide to use Yolo, could anyone tell me why you chose it instead of opencv, performance, better cropping?.</p>\n<p>Thank in advance.</p>",
      "rawMarkdown": "Hi, I was going through the top ten solutions, many of them decide to use Yolo, could anyone tell me why you chose it instead of opencv, performance, better cropping?.\n\nThank in advance."
    }
  ],
  "comments": [
    {
      "id": 2174838,
      "author_name": "Pablo Larrosa",
      "author_url": "",
      "post_date": "2023-03-09T12:39:21.843000",
      "content": "<p>For example this function worked fine and get good results:</p>\n<p>def crop_image(img, show=True):<br>\n    # Binarize the image<br>\n    bin_pixels = cv2.threshold(img, 20, 255, cv2.THRESH_BINARY)[1]</p>\n<pre><code># Make contours around the binarized image, keep only the largest contour\ncontours, _ = cv2.findContours(bin_pixels, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\ncontour = max(contours, key=cv2.contourArea)\n\n# Create a mask from the largest contour\nmask = np.zeros(img.shape, np.uint8)\ncv2.drawContours(mask, [contour], -1, 255, cv2.FILLED)\n\n# Use bitwise_and to get masked part of the original image\nout = cv2.bitwise_and(img, mask)\n\n# get bounding box of contour\ny1, y2 = np.min(contour[:, :, 1]), np.max(contour[:, :, 1])\nx1, x2 = np.min(contour[:, :, 0]), np.max(contour[:, :, 0])\n\nx1 = int(0.99 * x1)\nx2 = int(1.01 * x2)\ny1 = int(0.99 * y1)\ny2 = int(1.01 * y2)\n\nif show:\n    plt.imshow(out[y1:y2, x1:x2], cmap=\"gray\") ; \n\nreturn out[y1:y2, x1:x2]\n</code></pre>\n<p>what I don't know is the plus that yolo gives you</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2174378,
      "author_name": "Steven Van Ingelgem",
      "author_url": "",
      "post_date": "2023-03-09T05:07:29.253000",
      "content": "<p>OpenCV provides a wide range of computer vision functions and algorithms, YOLO is a specific object detection system based on deep learning. In fact, YOLO can be used in conjunction with OpenCV to perform object detection on images and videos using the features provided by OpenCV.<br>\nSo to take a wild guess is that to build the detection that the features of YOLO were more aligned with this project?</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2174838": "For example this function worked fine and get good results:\n\ndef crop_image(img, show=True):\n    # Binarize the image\n    bin_pixels = cv2.threshold(img, 20, 255, cv2.THRESH_BINARY)[1]\n   \n    # Make contours around the binarized image, keep only the largest contour\n    contours, _ = cv2.findContours(bin_pixels, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\n    contour = max(contours, key=cv2.contourArea)\n\n    # Create a mask from the largest contour\n    mask = np.zeros(img.shape, np.uint8)\n    cv2.drawContours(mask, [contour], -1, 255, cv2.FILLED)\n   \n    # Use bitwise_and to get masked part of the original image\n    out = cv2.bitwise_and(img, mask)\n    \n    # get bounding box of contour\n    y1, y2 = np.min(contour[:, :, 1]), np.max(contour[:, :, 1])\n    x1, x2 = np.min(contour[:, :, 0]), np.max(contour[:, :, 0])\n    \n    x1 = int(0.99 * x1)\n    x2 = int(1.01 * x2)\n    y1 = int(0.99 * y1)\n    y2 = int(1.01 * y2)\n    \n    if show:\n        plt.imshow(out[y1:y2, x1:x2], cmap=\"gray\") ; \n\n    return out[y1:y2, x1:x2]\n\nwhat I don't know is the plus that yolo gives you\n",
    "2174378": "OpenCV provides a wide range of computer vision functions and algorithms, YOLO is a specific object detection system based on deep learning. In fact, YOLO can be used in conjunction with OpenCV to perform object detection on images and videos using the features provided by OpenCV.\nSo to take a wild guess is that to build the detection that the features of YOLO were more aligned with this project?",
    "2174203": "Hi, I was going through the top ten solutions, many of them decide to use Yolo, could anyone tell me why you chose it instead of opencv, performance, better cropping?.\n\nThank in advance."
  }
}