Gaussian ring in 2d
Mostrar comentarios más antiguos
Hello,
I want to generate a 2d image (in form of a matrix) of a ring which is smoothed towards the outer and inner border by a Gaussian distribution, i.e. something looking like this:

That is, pixels in the image corresponding to the middle radius of the ring should have highest values and outer pixels values that are decreasing towards the borders.
Thanks, Denis
2 comentarios
Naresh Sharma
el 17 de Sept. de 2018
Can anyone suggest me the appropriate algorithm to find the center and the diameter(inner and outer) of the ring profile images?
Naresh
Petr Bouchal
el 28 de Dic. de 2022
Editada: Petr Bouchal
el 28 de Dic. de 2022
You can fit with the theoretical ring function using the least-squares method to find the width and central radius and calculate the inner and outer radius afterward.
%% generating ring with gaussian profile
x = linspace(-1,1,200);
y = linspace(-1,1,200);
[X,Y] = meshgrid(x,y);
[Phi,R] = cart2pol(X,Y);
R0 = 0.5; %ring radius
W = 0.2; %ring width
ring = exp(-((R-R0).^2)./W.^2);
%% finding center and diameter
fun = @(x,R) exp(-((R-x(1)).^2)./x(2).^2);
x0 = [1,1];
x = lsqcurvefit(fun,x0,R,ring);
R0_reconstructed = x(1);
W_reconstructed = x(2);
%% accuracy
R0_reconstructed
R0-R0_reconstructed
W_reconstructed
W-W_reconstructed
Respuesta aceptada
Más respuestas (3)
Petr Bouchal
el 23 de Dic. de 2022
Editada: Petr Bouchal
el 28 de Dic. de 2022
Hi, I would say the most appropriate approach is the following:
x = linspace(-1,1,200);
y = linspace(-1,1,200);
[X,Y] = meshgrid(x,y);
[Phi,R] = cart2pol(X,Y);
R0 = 0.5; %ring radius
W = 0.2; %ring width
ring = exp(-((R-R0).^2)./W.^2);
figure(); hold on;
imagesc(ring); axis equal; colormap gray;
plot(size(ring,1)*ring(0.5*size(ring,1),:));
KSSV
el 4 de Oct. de 2016
clc; clear all ;
M = 10 ;
N = 100 ;
R1 = 0.5 ; % inner radius
R2 = 1 ; % outer radius
nR = linspace(R1,R2,M) ;
nT = linspace(0,2*pi,N) ;
%nT = pi/180*(0:NT:theta) ;
[R, T] = meshgrid(nR,nT) ;
% Convert grid to cartesian coordintes
X = R.*cos(T);
Y = R.*sin(T);
[m,n]=size(X);
%
D = (X.^2+Y.^2) ;
% D(D<R1) = 1 ;
% D(D>R2) = 1 ;
Z = gauss(D);
surf(X,Y,Z);
colormap('gray')
shading interp ;
view([0 90]) ;
set(gca,'color','k')
1 comentario
Denis Wolff
el 4 de Oct. de 2016
I suppose you're looking for Laplacian of Gaussian ( Mexican hat )filter ? It fits your description. You can get a laplacian of gaussian kernel by :
log_kernel = fspecial('log');
The attached picture is a surf plot of a laplacian of gaussian kernel.

1 comentario
Denis Wolff
el 4 de Oct. de 2016
Editada: Denis Wolff
el 4 de Oct. de 2016
Categorías
Más información sobre Descriptive Statistics and Visualization en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




