function index_roi= my_region_growing(img, px,py, mean_tresh)

img = double(img);

[x,y] = size(img);
index_roi= zeros(x,y);
index_roi(px,py) =1.0;
index_roi = index_roi>0;

s = strel('square',3);
border = imdilate(index_roi,s);
border = logical(border - index_roi);



out = zeros(x,y);
out = out >0;

b =ones(x,y) * inf;

while sum(border(:))>0;
    
    
    M = mean(img(index_roi));
    
    b(border) = img(border);
    
    b_mask = abs(b-M) <= mean_tresh;
    
    index_roi(b_mask) = 1;
    
    out(~b_mask & border) =1;
    
    border = imdilate(index_roi,s);
    border = logical(border - index_roi);
    border(out) = 0;
    sum(border(:))

end
