MATLAB Answers

Image Segmentation - Image Analysis

5 views (last 30 days)
Matija Jankovic
Matija Jankovic on 21 Apr 2021
Answered: Sneha Bhukya on 13 Jul 2021
I am working on segmenting B-mode ultrasound images and was hoping to get some advice on the problem below.
I am given an animation.avi file which contains 231 frames of 2D B-mode ultrasound images. The given task is to load each frame into matlab, make it a binary image, and segment the circular inclusion in the image. Ideally, I want to segment it to have a black background with a white circle corresponding to the lesion. My current attempt at doing this is given in the code below. The code itself is doing an ok job at isolating the white lesion from the background (attached image), but I was wondering if anyone had a better method to segment it from the background?
In addition, I want to take the white circular lesion from each frame and reconstruct a 3D image of the cylinder it forms. It has been suggested to me to use VolumeViewer in matlab, but was hoping to get some advice on how I could implement this too.
% Read the AVI file
% Find number of frames, video height, and video width
videoObject=VideoReader('animation.avi');
numberOfFrames = videoObject.NumberOfFrames;
vidHeight = videoObject.Height;
vidWidth = videoObject.Width;
%Iterate through each frame
for frame = 1:numberOfFrames
currentFrame = read(videoObject, frame); % Reading current frame
hImage = subplot(1,2,1); % Create a subplot
image(currentFrame); % plot the current frame
caption = sprintf('Greyscale - Frame %4d of %d.', frame, numberOfFrames);
title(caption, 'FontSize', 22);
drawnow; % Force it to refresh the window.
BW = imgaussfilt(currentFrame, 8); % apply filter
BW = imbinarize(BW, 0.65); % make binary image using threshold
bwImage = subplot(1,2,2); % place next to original frame
image(BW);
caption = sprintf('BW - Frame %4d of %d.', frame, numberOfFrames);
title(caption, 'FontSize', 22);
drawnow; % Force it to refresh the window.
end

Answers (1)

Sneha Bhukya
Sneha Bhukya on 13 Jul 2021
In order to improve your current code i.e., to decrease the number of holes in the background, you can try using morphological operations that fill in gaps.
For stacking up circular lesions from each frame into a 3D cylinder, you can refer to this answer : Stacking multiple 2D images to form 3D image. - MATLAB Answers - MATLAB Central (mathworks.com)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by