How to create a circle with random roughness using meshgrid?
Mostrar comentarios más antiguos
Hello all,
I'am trying to replicate the circle shown in image 1 using mesh grid. The disordered "area" inside the grid has value -1 and similarly the disordered "area| outside the circle should have +1 value, while the rest of the area should be 0. Below is the code untill I could come up to. As shown in figure 2, imfill does not help anymore to fill in the open pixel area. Any suggestion or insights would be appreciated. Thanks for reading.
% th = linspace(0,2*pi,51)';
gridsize = 1000;
x=linspace(-10,10,gridsize);
y=linspace(-10,10,gridsize);
[X,Y] = meshgrid(x,y); %grid of 1 nm
deltaEps = zeros(size(X));
deltaEps(:,:) = 0;
rnd = randn(length(x));
holeRadius = 5; % in nm
sigma = holeRadius/2;
holeRadius_disorder1 = holeRadius+rnd*sigma;
holeRadius_disorder2 = holeRadius-rnd*sigma;
deltaEps(sqrt(X.^2+Y.^2)<holeRadius_disorder1)=2.6;
% deltaEps(sqrt(X.^2+Y.^2)<holeRadius)=-2.6;
% deltaEps(sqrt(X.^2+Y.^2)<holeRadius_disorder2)=0;
im = imfill(deltaEps,'holes');
im = imfill(im,'holes');
im = bwareaopen(im,1e5);
% im = ~bwareaopen(~im,1e5);
imagesc(deltaEps);
figure()
imagesc(im);
axis equal


Respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices 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!