1

enter image description here

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.

image

    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.

api55
  • 11,070
  • 4
  • 41
  • 57
mamoona
  • 11
  • 4
  • Where is your input image? – Bahramdun Adil Apr 24 '19 at 09:37
  • @mamoona remove these `>`, put your code into triple ``` (at the beginning and end), move link to image outside code snippet – barbsan Apr 24 '19 at 09:48
  • 1
    I think it is something NOT very possible. – Bahramdun Adil Apr 25 '19 at 01:15
  • can you elaborate more that how it is not possible. @BahramdunAdil – mamoona Apr 25 '19 at 01:34
  • 1
    @mamoona Because the object you want to detect on the image doesn't have a very obvious feature to detect, especially the last two images, so it makes it hard to separate the tumor from the bone. But the first one is OK. You just need to look for a brighter area. – Bahramdun Adil Apr 25 '19 at 03:05
  • Can You explain or refer me to the brighter area technique you mentioned from implementation perspective ,So I can run on fix 5-10 images that have clear tumors. thank you for your comment. – mamoona Apr 25 '19 at 05:36
  • 1
    You won't archive this without segmenting your image. Your skull has a very similar intensity to your tumor, that's why simple thresholding won't do. – T A Apr 25 '19 at 13:57

1 Answers1

0

Based on the comment to this answer I updated my answer, and I think that this is still a Deep Learning problem, but of a different kind.

If you need to segment the tumor along its contour, one way to do it may be Mask R-CNN(1) (you can read the original paper published in 2017). This method allows image segmentation along their contours. Here you can find a sample implementation of the method.

As far as I can see from the image, you have to deal with grayscale images, and it may be difficult to segment tumors from the rest of the scene by simple methods, here I agree with @BahramdunAdil. Therefore, I suspect that the training might need a lot of data and time.

Good luck!

(1) He, Kaiming, et al. "Mask r-cnn." Proceedings of the IEEE international conference on computer vision. 2017.

Bolat Tleubayev
  • 1,765
  • 3
  • 14
  • 16
  • 1
    Hi, thanks for your comment , I have classified my images using CNN. I have idea about the things you mentioned. Trained the whole image with CNN and it does predict well my whole dataset. The problem is I want to just want to highlight tumor area for better interpretation on screen that where is the tumor from whole image.I m wandering for any simple technique that work on 5-10 images that are easy to detect like not tumor not in bone area.Similar to this https://stackoverflow.com/questions/27647664/python-opencv-drawcontours-fail-when-i-draw-just-the-bigger-contour-object – mamoona Apr 25 '19 at 05:30
  • @mamoona thank you for clarification, I have updated my answer – Bolat Tleubayev Apr 25 '19 at 13:50
  • thank you , now your answer seems interesting and addressing to my problem.I will definitely look at it. – mamoona Apr 26 '19 at 02:10