Skip to main content

MATLAB Digital image analysis of chest phantom images in CT

Assignment Brief

Write a program in MATLAB that perform the following tasks for all the images:

1. Identify the type of noise in the image and seek a way to remove the noise. The program at this stage should generate a de-noised image.

2. Segment the simulated lung area from the image. The program should generate a binary image showing the simulated lung area on a black background

3. Count and display in the Command Window the number of circles inside the lung region. For some images, half circles also appear at the edge of the lung region. Your program should count those as well. Here, your program should display a figure with detected circles marked (e.g. you may mark it with a small cross or a bounding box).

Challenge task – for additional credit, make your program also perform the following:

4. Segment detected circles from the lung region and draw their boundaries (use a green line).

Process

The input image was first converted to grey from RGB because processing colour images can be complex instead of working with three colour channels we only need to worry about one, conversion to binary could have been an option but this is too simple and risks losing a lot of detail in the image. To remove the noise initial noise in the image a mean filter was implemented by replacing each current pixel value with the mean average of its surrounding neighbors providing the image below with some of the noise removed. The mean filter was chosen for this operation as it reduces the variation of intensities between neighbouring pixels, the noise in the image, by replacing each pixel with an average of its combined neighbour’s and also smoothing the image.

The image is then converted to binary using a custom function. It sets pixels over a specific intensity based on the distribution of bins in the histogram to white and the rest to black, to further remove more noise and to allow performing morphological operations in later steps. The conversation to binary causes some degradation to the image with lots of dark spots and holes appearing. In order to smooth the image and fill those gaps, the image was dilated to provide a more solid image as well as an enlarged border.

The dilated image is eroded in order to reduce the boundaries of the inner circle, making sure they aren’t connected to the outer edge of the lung region or to other circles as this could affect the result of the circle segmentation.

The image was then inverted in order to run the matlab function “bwconncomp” to label the connected components found in the image, in order to segment the main lung region from the background and copy onto a black image.

The next step was to count the circles within the segmented lung region as well as removing them. The segmented lung region was inverted and run through the “bwconncomp“to detect and label the small circles.

Using the results from the second bwconncomp the small circles were counted and also removed from the lung image by filling their pixel regions with white. The largest connected component was ignored as this is the outer lung image, providing the final image of the segmented lung region in a black background without the inner circles.

To draw the detected circles onto the image, the results from the second connected component function was converted from its linear index using the “ind2sub” function to get the x and y coordinates of each of the small circles in order to draw a square border around each circle using the shapeInserter function on the original image.

To find the edges of each of the detected circles. The circles were segmented to a different image and a canny edge detector was used to get the edges. After the edges were detected they were drawn onto the original image, to outline the detected circles with the colour green!

Charles Osei

Dynamics 365 Consultant @ RSM MCSE Business Applications Computer Science – University of Lincoln 2017 Nottingham D365/CRM user group Chapter Leader TDG – Community leader Twitter @charliedevxyz LinedIn https://www.linkedin.com/in/charlesosei/

Leave a Reply

%d bloggers like this: