I want to draw rectangle or bounding box in a green color on my brain tumor image dataset to highlight the tumor in image. What would be shortest method for it? I do not want segmentation of tumor.
I have tried openev draw rectangle function but it does not work. Also I have found Active Contour and Canny algorithm but this also does not work.
import cv2
import numpy as np
image = cv2.imread('12.png')
cv2.imshow('Input Image', image)
cv2.waitKey(0)
gray =cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Canny Edges edged = cv2.Canny(gray, 30, 200)
# cv2.imshow('Canny Edges', edged)
# cv2.waitKey(0)
_, contours, hierarchy = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cv2.imshow('Canny Edges after Contouring',edged)
cv2.waitKey(0)
print("Number of contours found = " +str(len(contours)))
cv2.drawContours(image, contours, -1, (0, 255, 0),3)
cv2.imshow('Contours', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
I expect the the tumor part should be in a box from whole image.Rest of the image area should be the same as my actual brain image.Just one green box around the tumor part through simple code not whole algorithm.