HOW TO FIND THE FULL WIDTH AT HALF MAXIMUM

16 Ansichten (letzte 30 Tage)
MOHD
MOHD am 29 Aug. 2012
Hi,
I have a problem in the following code:
clear all;
clc;
close all;
lamda=531e-9;
k=2*pi/lamda;
[x,y]=meshgrid(-1*lamda:(2*lamda/127):1*lamda);
r=sqrt(x.^2+y.^2);
w=10^-3;
z=10^-3;
z1=sqrt(w.^2+z.^2);
N.A=w/z1;
v=((k*r));
I=(2*bessel(1,v)./(v)).^2;
I0=max(max(I));
I2=I/I0;
I3=0;
figure(1)
plot(I2(64,:))
%figure(2)
%imagesc(I2),colormap gray
%For full width of airy pattern
% a=19;
% v1=k*w/z;
% d1=a/v1 % d1=1.605*10^-6m;
% For full width at half maximum
b=46;
v2=k*w/z;
d2=b/v2 %d2=6.760*10^-7m;
%%%%%%%%%%%
when you run the above code, you will find figure(1) and I am in need to find the half width full maximum(FWHM) of the said fig. using matlab. It will be a great help for me if anyone help me out in this regard...
Thanking You!
  2 Kommentare
Eric
Eric am 29 Aug. 2012
You might do better by explaining what it is you're trying to do. It looks like you're trying to find the FWHM of the PSF of an optical system. It's not clear to me what the parameters of the optical system are. Perhaps the numerical aperture (N.A?) is 1/sqrt(2)? It's confusing because the variables w, z, z1, and N.A have no impact whatsoever on the plotted data. I don't think that's what you intended.
You might look at my answer at http://www.mathworks.com/matlabcentral/answers/36064-spherical-aberration-and-chromatic-aberration for a guide on how to calculate an optical PSF.
Also, bessel(1,v) should be besselj(1,v) unless you have written your own function called bessel().
-Eric
Eric
Eric am 29 Aug. 2012
One more thing: I'm assuming you've been tasked to do this numerically as part of a homework assignment. If you really just want the FWHM, you can solve for that in a more straightforward fashion by using the analytic form of the PSF. I did a quick calculation and get 1.03*lambda*f_number as the FWHM.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 29 Aug. 2012
MOHD: First change bessel to besselj like Eric advised. Then add this onto your code.
% Find the max
plot(I2(64,:), 'bo-')
grid on;
oneProfile = I2(64,:);
maxValue = max(oneProfile)
% Find where it's more than half the max.
aboveHalfMax = oneProfile > maxValue/2
% Get the first and last index where it's more than the half max.
firstIndex = find(aboveHalfMax, 1, 'first')
lastIndex = find(aboveHalfMax, 1, 'last')
% Draw lines there
hold on;
line([firstIndex firstIndex], [0 maxValue/2], 'Color', 'r', 'LineWidth', 2);
line([lastIndex lastIndex], [0 maxValue/2], 'Color', 'r', 'LineWidth', 2);
line([firstIndex lastIndex], [maxValue/2 maxValue/2], 'Color', 'r', 'LineWidth', 2);
  5 Kommentare
Image Analyst
Image Analyst am 3 Sep. 2012
See my image segmentation tutorial where I go over that. I find the area of coins. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Eric
Eric am 4 Sep. 2012
Here's what I would do:
First, use the example code from my link above to calculate the PSF. You need a PSF with a numerical aperture of 0.5. Pick an aperture size D (call it 1 inch if you like). Then set the focal length to D/2*tan(asin(NA)) where NA is the desired numerical aperture (0.5 in your case). Run my code to get the diffraction-limited PSF as a 2D array.
Next, use Image Analysts's code to analyze the PSF array. This will give you the FWHM in pixels. Multiply this value by psf_sampling in my code to get the FWHM in dimensioned units.
This is somewhat inelegant as you have to specify a physical size of the optical system (via the aperture diameter and focal length). The PSF is fully specified by only the numerical aperture. You could write code that could calculate the diffraction-limited PSF using only the NA if you wish.
Good luck,
Eric

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by