Creating a 5*5 window around the initial seed point in a region growing algorithm?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am trying to implement a region growing algorithm to segment tumor in gastric. I would select the initial seed point manually. Then a 5*5 window would be created around the initial seed point. The minimum value inside the window would be selected as the first seed point of the region growing algorithm. Another new 5*5 window would be created around the the first seed point and the algorithm would be applied within that window. My problem is that I am unable to create the window around the initial seed point. I tried the code below but I don't get the correct result. The original image is attached as Original_Image.png and the tumor region would supposedly look as shown in Tumor.png. Any suggestions would be helpful. Thank you.
i=rgb2gray(imread('Original_Image.png'));
figure, imshow(i,[])
% gg = uint8(255 * mat2gray(i));
[x,y]=getpts;x=round(x);y=round(y);
a=imgaussfilt(i,2);
% a=rgb2gray(a);
b=adapthisteq(a);
m=regMLT(b,x,y,12);
m=imfill(m,'holes');
bw=imbinarize(m);
bw=bwareafilt(bw,1);
seg = region_seg(m, bw, 30);
seg=double(Y).*double(seg);
figure, imshow(seg,[])
0 Kommentare
Antworten (1)
Maneet Kaur Bagga
am 16 Nov. 2023
Hi Warid,
As per my understanding, the code provided is using a gaussian filter which can result in extending the window beyond the boundaries of the image, leading to errors.
Please refer to the modified code below, it will create a circular window around the initial seed point with a radius of 2 pixels. Also it checks if the window lies within the image boundaries, it uses new minimum value as the seed point for the region growing algorithm for gaining more accuracy.
% Initialize the minimum value and its corresponding coordinates
min_value = inf;
min_x = 0;
min_y = 0;
% Create a circular window around the initial seed point
radius = 2;
for i = x-radius:x+radius
for j = y-radius:y+radius
if i >= 1 && i <= size(i, 1) && j >= 1 && j <= size(i, 2)
% Calculate the distance from the pixel to the seed point
distance = sqrt((i - x)^2 + (j - y)^2);
% Update the minimum value and its coordinates if necessary
if distance <= radius && i ~= x || j ~= y
if i < min_value
min_value = i;
min_x = i;
min_y = j;
end
end
end
end
end
% Use the new minimum value as the seed point for the region growing algorithm
a=imgaussfilt(i,2);
b=adapthisteq(a);
m=regMLT(b,min_x,min_y,12);
m=imfill(m,'holes');
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Segmentation and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!