How can I write a 2D gaussian cumulative matlab function that gets applied to an input 2D binary image. The mean of the gaussian cumulative is on a particular selected curved line which will be given as an input. So the inputs of the function is:
- The main 2D binary image.
- A 2D binary matrix with the same size as the main 2D binary image which is 1 where the 2D gaussian cumulative function’s means should be, and 0 everywhere else.
- The standard deviation of the 2D Gaussian cumulative function
And the output is the smoothed form of the main 2D binary image
I have tried this code but its all wrong:
function [smoothed_image] = gaussian_cumulative_2D(binary_image, mean_loop, std_dev)
% Create a meshgrid for the x and y coordinates
[x,y] = meshgrid(1:size(binary_image,2), 1:size(binary_image,1));
% Calculate the distance from each point to the mean loop
distance = sqrt((x-mean_loop(1)).^2 + (y-mean_loop(2)).^2);
% Calculate the gaussian cumulative function
gaussian_cumulative = 0.5*(1 + erf(distance/(std_dev*sqrt(2))));
% Apply the gaussian cumulative function to the binary image
smoothed_image = binary_image.*gaussian_cumulative;
end