How to create a circle with random roughness using meshgrid?
显示 更早的评论
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


回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!