计算角频率(以弧度/像素为单位):
angular_frequency = 2 * pi * cycles_per_pixel
生成一个二维网格,对应于每个像素的x坐标:
[x, y] = meshgrid(1:N, 1:N)
根据正弦函数生成光栅图像:
amplitude = 1% 光栅振幅
grating = amplitude * sin(angular_frequency * x)
显示生成的光栅图像:
figure
imshow(grating, [])
title('5 cpd Sine Grating')
现在就可以生成了一个正弦光栅图像,其空间频率为每度5个周期(5 cpd),具有指定的图像大小和振幅。
如果帮到您了,请采纳点赞哦~~谢谢(●'◡'●)
%模拟波浪图像clear all
tic
L=2000d=200f0=1/16w=2*pi*f0
x=1:512y=x
[x,y]=meshgrid(x,y)
z=3*peaks(512)
figure(1)mesh(z)axis on
xlabel('x(pixel)')ylabel('y(pixel)')zlabel('h(mm)')
%基准光栅
J0=128+127*cos(w*x)
J0=mat2gray(J0)
figure(2)imshow(J0)axis on
%变形光栅
J1=128+127*cos(w*(x+z*d./(L-z)))
J1=mat2gray(J1)
J1=imnoise(J1,'gaussian',0,0.001)
figure(3)imshow(J1)axis on
这里的变形光栅就是将基准光栅(正弦光栅)投射到模拟波浪图像(peaks函数生成的)后得到的变形光栅。
仅当参考,还要根据你的设计来。
In this work, the projected fringes were shifted using a mirror mounted on a rotary stage placed in the path of the illumination as shown schematically in Fig. 2(b). 在本文中,被投影的条纹用一个安装在旋转台上的反射镜偏移,而旋转台则放置在照明的路径上,就像图2(b)中示意的那样。The projector is a standard slide projector (Braun Novamat 130AF). 投影仪是一种标准的幻灯片投影仪(Braun Novamat 130 AF)。A sinusoidal grating was generated using a computer program written using Matlab and prepared onto a 35 mm slide. 用一个用Matlab编写的计算机程序产生一个正弦光栅,并被制备在一片35mm的幻灯片上。A 640×480 resolution monochrome CCD camera (JAI CV-M50) placed at approximately 600 mm from the object was used to capture the image. 采用一台放置在离物体约600mm处的640×480 分辨率的黑白CCD摄像机(JAI CV-M50)来捕集图像。Figures 3(a)–(c) show images of fringes projected on to the glass blocks and shifted by 2π/3 radians in three stages. 图3(a)-(c)示出了投射到玻璃块上,并在三个阶段中被偏移2 π/3弧度的条文的图像。The phase map obtained after applying Eq. (3) to these images is shown in Fig. 3(d). 在将式(3)用于这些图像后得到的相位图始于图3(d)。Phase value 0 corresponds to gray value 0 in the phase map image, whereas phase value 2π corresponds to gray value 255. 相位值0对应于相位图图像中的灰度值0,而相位值2π对应于灰度值255. Other phase values are linearly related to the pixel intensity from 0 to 255. 其他相位值与从0到255的像素强度成线性关系。The projection angles of the non-collimated light for a given height on the surface of the specimen block have to be determined before calculation of tilt can be performed. 对于在样本块表面上的某一给定高度来说,非准直光的投影角必须先确定,才能进行倾角的计算。To determine the relationship between θ and block distance L along a straight line from the origin O, a single glass block of dimensions 13.5 mm×152.0 mm×15.0 mm was used. 为了确定θ与从原点O起沿直线的玻璃块距离L之间的关系,采用了尺寸为13.5mm×152.0mm×15.0mm的单一玻璃块。The block was made from eight pieces of glass with an average thickness of 2 mm each, bonded together using adhesive compound. 该玻璃块由8片玻璃制成,每片的平均厚度为2mm,用黏结化合物黏结在一起。
Figure 4(a) shows the block with the projected fringe pattern and Fig. 4(b) is the phase map for the block. 图4(a)示出了带有投影条纹图形的玻璃块,图4(b)为该玻璃块的相位图。The position of the blocks is not identical in these two figures because the image in Fig. 4(a) was shifted to the left to show the shadow at the edge of the block. 玻璃块的位置在这两张图中不是同一的,因为图4(a)中的图像被偏移到左面,以显示玻璃块边缘处的阴影。The shadow was used to determine the location of the fringe break point from the background to the block surface. 该阴影被用来确定从背景到玻璃块表面,条纹中断点的位置。This information was used to determine the phase break points in the phase map. The dots in Fig. 4(b) show the phase breakpoints from block to background, where A1 corresponds to A2 and A′1 corresponds to A′2. The break points have the same gray values. 这一信息被用于确定相位图中的相位中断点。图4(b)中的圆点表示从玻璃块到背景的相位中断点,其中,A1对应于A2,而A’1对应于A’2。中断点都有相同的灰度值。
Once the corresponding break points on the block and the background were located the gray values along a horizontal line from both points were read using a C++ program linked to the Matrox Imaging libraries. The gray values were read from left to right using the edge of the block as the limit. Completion of this step resulted in two sets of data with gray values and coordinates along the block. The intensity distribution is represented by gray values ranging from 0 to 255.
一旦玻璃块上对应的中断点和背景被定位,那么沿来自两点的水平线的灰度值就可用链接到Matrox成像库的C++程序读出。灰度值用玻璃块的边缘作为极限而从左到右读出。这一步骤的完成能得到两组数据,即灰度值和沿玻璃块的坐标。光强分布用0到255范围的灰度值来表示。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)