0

I want to extract the endotracheal region from the MRI of the Sagittal plane of the neck image, but after applying image processing techniques like thresholding, contour detection and binary masking,

I could find that there are other undesired regions as well which are being extracted along with the required region of interest.

import cv2 as cv
import numpy as np

img = cv.imread('sam_mri01.jpg')
cv.imshow('pre1',img)

image_contours = np.zeros((img.shape[1],
                           img.shape[0], 1),
                          np.uint8)

binary_img = np.zeros((img.shape[1],
                         img.shape[0], 1),
                        np.uint8)

for channel in range(img.shape[2]):
    ret, thresh_img = cv.threshold(img[:, :, channel],
                               25, 255,
                                     cv.THRESH_BINARY)
    cv.imshow('pre3', thresh_img)
    contours = cv.findContours(thresh_img, 1, 1)[0]
    cv.drawContours(image_contours,
                    contours, -1,
                    (255,255,255), 1)
    cv.imshow('pre4',image_contours)

contours = cv.findContours(image_contours, cv.RETR_LIST,
                           cv.CHAIN_APPROX_SIMPLE)[0]

cv.drawContours(binary_img, [max(contours, key = cv.contourArea)],
                -1, (255, 255, 255), -1)
    
cv.imshow('result', binary_img)
cv.imwrite('result.jpg',binary_img) 
cv.waitKey(0)

The image:

image of side view of neck(mri)

the result obtained:

result obtained.

I want only the particular tube-like endotracheal channel to be extracted or differentiated. the other regions in black need to be eliminated from the result and this has to be done automatically for any image of this type so that I don't need to set different parameters for different images. The region of interest is the black coloured channel which is the endotracheal region:

the black coloured channel which is the endotracheal region

Bilal
  • 3,191
  • 4
  • 21
  • 49
smkd
  • 1
  • that CT has vignetting. that's weird. CT images usually come in Hounsfield units (-1000 to ~+3000), which correspond to physical quantities, which means these images should have no vignetting. see if you can get a better picture, preferably one that isn't a "picture" but medical data. -- you might need AI for this. distinguishing one black tube from other black regions needs some intelligence. low level image processing has little promise. – Christoph Rackwitz Mar 08 '22 at 15:23
  • @smkd I suggest you inverse the image and use this [approach](https://stackoverflow.com/a/46442154), then if you count the pixels the desired region is the second-largest one (assuming your ROI is connected region). – Bilal Mar 08 '22 at 18:23

0 Answers0