フィルターのクリア

Wrap noisy periodic line into circular mask

5 ビュー (過去 30 日間)
Nick K
Nick K 2020 年 12 月 11 日
編集済み: Nick K 2020 年 12 月 11 日
Hi all,
I'm trying to generate a mask based off a periodic noisy line that is wrapped into a circle.
I can generate a path for the circle around the x,y plane. However I'm stuggling on making it into a mask.
Essentially, I want everything inside the circle to have value 0 and everything outside it to have value 1.
This mask should be returned as an array of dimensions (x,y)
I really need this doing without any fancy inbuilt functions, as I will be porting this to another language.
I feel there must be some solution using loops but I cant quite get it.
Please find the code to generate the noisy circle below:
%% Setup and grid
clear all ; clc; clf
N=256
L=128
x=L*(-(N-1)/2:N/2)/N;
y=x;
%% Generate noisy periodic line through fourier modes
M=10 %number of modes
kmax=N/2
kx=(randi(kmax,1,M)-kmax/2);%random wave numbers
x=L*(-(N-1)/2:N/2)/N;
y=x;
V=zeros(1,N);
A=rand(M)*2-1; %random amplitudes
B=rand(M)*2-1;
for i=1:M
V=V+A(i)*sin((2*pi/L)*kx(i)*x)+B(i)*cos((2*pi/L)*kx(i)*x);
end
%% Generate circular mask
radius = 50; % Choose base circle radius
Pot_rad = radius + V;
for i=1:N
xnew(i) = Pot_rad(i)*cos(x(i)*(2*pi/L));
ynew(i) = Pot_rad(i)*sin(x(i)*(2*pi/L));
end
plot(xnew,ynew)
TLDR; Make Array mask V2D(x,y) from noisy line V(x) wrapped into circle.
Thanks in advance :)

回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by