segmentation algorithm by region growth

Hi I need to complete the following assignement and im having issues. For a reason I don't understand my code is currently drawing the backgroup instead of the region i clicked on..
here is what i need to do : The goal of this practical work is to develop a semi-automatic segmentation algorithm by region growth of a medical image and to extract anatomical measurements of the segmented region.
I have attached a video of what my code should be doing and the image im working with.
img = imread('images\vertebre.png');
imshow(img);
[x, y] = ginput(1);
x = uint16(x);
y = uint16(y);
imgf = medfilt2(img, [7 7]);
imshow(imgf);
elemd2 = strel('disk', 2, 0);
seg = zeros(510,628,'logical');
seg(y,x)=1 ;
seg_precedent = zeros(510,628,'logical');
dispMat = zeros(size(img));
while (~isequal(seg, seg_precedent))
seg_precedent = seg;
intensite_region = sum(seg(:) == 1);
m_region = mean(intensite_region);
std_region = std(intensite_region);
seg_dilate = imdilate(seg, elemd2);
contour = seg - seg_dilate;
ind = find(contour==1);
delta = 12;
binf = m_region - (std_region + delta);
bsup = m_region + (std_region + delta);
contour = seg_dilate - seg;
inf_seg = binf < imgf;
sup_seg = imgf < bsup;
candidats = inf_seg & sup_seg;
seg = candidats;
dispMat = img;
dispMat(seg) = 0;
RGB = cat(3,uint8(seg)*255+dispMat,dispMat,dispMat);
imshow(RGB, [])
drawnow
end

2 Kommentare

Image Analyst
Image Analyst am 18 Okt. 2021
What about simply thresholding?
Julien Roussel
Julien Roussel am 19 Okt. 2021
Actually i have to do it this way... im pretty sure my problem is with this line :
intensite_region = sum(seg(:) == 1);
here what i was told about this line
using the seg variable as a mask, extract all of the elements from imgf that belong to the segmented region in seg (meaning all that elements equal to 1 in seg)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Modify Image Colors finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 16 Okt. 2021

Kommentiert:

am 19 Okt. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by