필터 지우기
필터 지우기

How do I change from Square to CIrcle?

조회 수: 2 (최근 30일)
Maitham
Maitham 2014년 5월 3일
댓글: Dina Abd El-twab 2020년 3월 14일
This fresnel diffraction simulation for a square aperture. I need to change it to work with a circle aperture. I need to help to change this step:
u0(257-w*20:256+w*20,257-w*20:256+w*20)=1; % setup aperture
This for a square and how i convert it to a circle?
Thank you.
The code is:
2d propagation from square apertures
ii=sqrt(-1) lambda= .365; % wavelenght [µm] z=1; % distance [µm] w=1; % width of slit is 2*w [µm]
x=-12.75:0.05:12.8; % setup spatial axis [µm] freqx=-10:20/512:10-1/512; % setup frequency axis [1/µm] freqy=freqx;
u0=zeros(512); % field at z=0 a0=zeros(512); % angular spectrum at z=0 H=zeros(512); % transfer function az=zeros(512); % angular spectrum at z=z uz=zeros(512); % field at z=z
for nx=1:512 % setup transfer function for ny=1:512 H(nx,ny)=exp(ii*2*pi*(z/lambda)*... sqrt(1-(lambda*freqx(nx))^2-(lambda*freqy(ny))^2)); end end
u0(257-w*20:256+w*20,257-w*20:256+w*20)=1; % setup aperture a0=(fftshift(fft2(u0))); % fourier transform az=a0.*H; % multiply with transfer function uz=ifft2(fftshift(az)); % inverse fourier transform p=uz.*conj(uz);
figure(1) plot(x, p(:,256)); % plot of cross-section of intensity at z xlabel('x'); ylabel('I');
figure(2) imagesc(x, x, p); %diffraction pattern at z xlabel('x'); ylabel('y'); colormap(gray); colorbar;

채택된 답변

Image Analyst
Image Analyst 2014년 5월 3일
See code examples for creating a circle in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F. You can adapt them as needed.
  댓글 수: 8
Image Analyst
Image Analyst 2020년 3월 14일
Where is your new question (so we don't keep sending Maitham emails)? Your link above no longer works.
yellowMask = rgbImage(:,:,1) == 255 & rgbImage(:,:,2) == 255 & rgbImage(:,:,3) == 0;
yellowMask = imfill(yellowMask, 'holes');
yellowMask = bwareafilt(yellowMask, 1);
props = regionprops(yellowMask, 'Centroid', 'EquivDiameter');
viscircles(props.Centroid, props.EquivDiameter/2);
Dina Abd El-twab
Dina Abd El-twab 2020년 3월 14일
this code didn't give me what i want ,could you please open this link , Iam gonna attach what happened in this link now to contact there

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by