# Creating a 5*5 window around the initial seed point in a region growing algorithm?

1 visualización (últimos 30 días)
Warid Islam el 22 de Sept. de 2022
Respondida: Maneet Kaur Bagga el 16 de Nov. de 2023
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.
figure, imshow(i,[])
% gg = uint8(255 * mat2gray(i));
[x,y]=getpts;x=round(x);y=round(y);
a=imgaussfilt(i,2);
% a=rgb2gray(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 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Maneet Kaur Bagga el 16 de Nov. de 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
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);
m=regMLT(b,min_x,min_y,12);
m=imfill(m,'holes');
Hope this helps!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Image Arithmetic en Help Center y File Exchange.

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by