# veloVortPressForce
A suite of master scripts used to plot velocity and vorticity fields using masks when an object is in the field of view. Experimentally derived pressure fields are also computed and used to measure the force components (thrust, drag, lateral component) along the object's outline.
The following sets of MATLAB scripts compute and plot velocity, vorticity and pressure fields and measure experimentally derived forces along an object in the fluid. Specifically, the scripts compute the instantaneous masks and outlines of the object/animal, as well as its centerlines (if it is an elongated object) to compute reliable pressure estimates around the body and measure the resulting forces.
The scripts were written to be modular and can be reorganized as needed. Additionally, the scripts can be modified to perform calculations derived from the main features presented here. For instance, the centerlines are currently used to measure the heading of the organism in the field of view. However, the user can further develop the script by also finding the center of mass to perform torque calculations and determine the swimming speed of the object.
To perform the desired computations, proceed as follows:
1) Create a folder containing the following subfolders:
- Figures
- Forces
- Images
- masksBW
- outlines
- PIVclean
- PIVoriginal
- pressure
- centerlines
2) Load the raw PIV data (as .txt files) in the ‘PIVoriginal folder and the corresponding images in the ‘images’ folder. Make sure the number of files is the same in these two folders. Note: When compouting velocity fields in DaVis, it is important to remember Davis assigns a velocity field on the first image in a sequence but cannot compute the velocity field from the last images. Warning: Always set the (0,0) origin of the axes in DaVis to the bottom left corner of the frame. To do so, DaVis has a setting in the scaling tab to align the y-axis origin. Because image axes origins are set to the top left corner by default, the user must offset the origin in DaVis with the height of the image in pixel.
3) Load the ‘masterComputePressure’ script found in the ‘Master scripts’ folder.
- Load the paths and make the directories.
- Convert the raw PIV data to the .csv format for Queen2.
- Generate and export the image masks to isolate the object. Select the desired options depending on your case. Also change some of the contrast and binarization thresholding parameters in the ‘makeMask3’ function if necessary
- Load the scale (opts.scale) in px/mm (it will be converted to px/m) to scale the outlines properly.
- Generate and export the outlines from the BW masks.
- Repair the outlines manually if necessary. Follow the instructions at the top of the pop-up figure that appears upon initiating the ‘repairOutlines’ function.
- Optional: export clean BW masks using the cleaned outlines.
- Open the Queen2 ‘parameter2’ parameter file and change the parameters according to your case. Don’t forget to set your PIV and pressure file directories.
- Run ‘Queen2’
- Automatically move the pressure files Queen2 outputs from the ‘PIVclean’ folder to the ‘pressure’ folder.
4) Load the ‘masterPlotVeloVortPress’ script found in the ‘Master scripts’ folder to plot the velocity, vorticity, and pressure fields.
- Set the directories and paths.
- Load the scale to scale the figure axes properly.
- Import the velocity fields. This step takes a few seconds.
- Convert sections of the velocity fields falling outside the computation domain to NaN. This would be the case if your version of DaVis outputs vectors = 0 outside of the geometric masks defining the region of interest for computing (if applicable).
- Plot the mean velocity field and subtract the bulk flow if necessary. Note: change the opts.flowDirection if you need a different orientation or if there is no net bulk flow (1 = u (x direction); 2 = v (y direction); 3 = no flow).
- Plot the velocity and vorticity fields. Run a test frame first to check that the options you selected match your expectations. Once satisfied, export all the frames. All the frames will be output in the ‘figures’ folder. The user can choose between exporting simple .jpg figures and/or .svg vector files that can be reworked in Illustrator. Default options: velocity vectors overlaid on top of the vorticity fields. The plots use the real image of the object, and the vorticity and velocity fields are masked using the outlines. These options can be changed to plot the mask instead of the image or plot only the vorticity fields without the vectors. Also change the plotting parameters to control the vorticity magnitude of the colorbar (symmetrical) and the density of vectors in the velocity fields.
- Import the velocity fields. This step takes a few seconds.
- Plot the pressure fields. The process is the same as for the velocity fields. Select the plotting parameters you need and run a test frame. Once satisfied, export all the pressure fields. All the frames will be output in the ‘figures’ folder. The user can choose between exporting simple .jpg figures and/or .svg vector files that can be reworked in Illustrator.
5) Load the ‘masterCenterlineHeading’ script found in the ‘Master scripts’ folder to calculate the centerline and measure the heading of the object.
- Set the directories and paths.
- Load the scale to scale the figure axes properly.
- Load the outlines or clean masksBW. If selecting the option to load the outlines, then a sub-function converts the outlines to BW images to perform morphological operations to skeletonize the masks.
- Compute the centerlines. First, test a centerline to confirm that the centerlines are plotted properly. Then the script computes the centerlines for all the frames. At this stage, the centerline is re-scaled in pixels for convenience. Also, they may not be sorted properly, with the anterior point of the object identified as the first element in the centerline matrix.
- Finalize the centerlines by identifying the anterior point as the first point of the centerline matrix. This stage of the computation also measures the heading of the object in the field of view. The heading is the swimming direction relative to the true north in the image (+y-axis, top edge of the frame). This function triggers a pop-up figure where the user will be asked to click on the anterior section of the object. A search area is thus defined around that point to automatically track the anterior point of the object in every frame. This local search finds the element corresponding to this anterior point to re-organize the centerline with that point as the first element of the centerline matrix. The search is assisted by predicting the displacement of the anterior point over time based on the displacement of the previous frames. In the event that the script cannot find the anterior point, the user will be prompted to select it manually to re-start the search. Options: the radius of the search area is set to 100 pixels. The size of the search area depends on the image resolution and the time increment between the frames, The quality of the outlines, and this thew resulting centerlines can affect the precision on the prediction to find the anterior point. This parameter can be changed in the ‘cleanCenterlines’ function found in the ‘Functions’ folder.
- Convert the centerlines to meter.
- Export the centerlines as individual .csv files for each frame in the ‘centerlines’ folder. This step also saves a matrix containing the heading of the object.
- A last section allows you to plot individual centerlines along the mask that shows the identification of the anterior point and the position of the center of mass. In this case, the center of mass is located at a fixed distance from the anterior section, relative to the total length of the object. The default value is 30% of the length of the object.
6) Load the ‘masterFor
没有合适的资源?快使用搜索试试~ 我知道了~
当物体位于视野中时,用于使用掩模绘制速度和涡度场的matlab代码.zip
共73个文件
m:52个
png:13个
md:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 112 浏览量
2024-05-18
17:36:27
上传
评论
收藏 2.1MB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
收起资源包目录
当物体位于视野中时,用于使用掩模绘制速度和涡度场的matlab代码.zip (73个子文件)
当物体位于视野中时,用于使用掩模绘制速度和涡度场的matlab代码
veloVortPressForce-main
README.md 10KB
Master scripts
masterComputePressure.m 8KB
masterCenterlineHeading.asv 4KB
masterPlotVeloVortPress.m 8KB
masterCenterlineHeading.m 5KB
masterForcePlot.m 4KB
Functions
exportCenterlines.m 701B
veloZeros2NaN.m 178B
progressCount.m 581B
fileID.m 450B
forceComputation
alignPoints.m 1KB
plotForceLegend.m 1KB
forcesFromPressure.m 42KB
txt2csv.m 970B
importVeloFields.m 1KB
computeHeading.m 2KB
importPressFields.m 888B
makeCenterline.m 9KB
plotMeanVelo.m 2KB
ginputc.m 13KB
quickprofile.m 1KB
plotVeloVort.m 12KB
formatFigure.m 336B
quickfilepath.m 133B
cmocean
cmocean.png 78KB
LICENSE 1KB
cmocean_documentation.m 5KB
html
cmocean_documentation_10.png 157KB
cmocean_documentation_09.png 29KB
cmocean_documentation_03.png 53KB
cmocean_documentation_07.png 29KB
cmocean.png 78KB
cmocean_documentation_06.png 53KB
cmocean_documentation.png 5KB
cmocean_documentation_01.png 56KB
cmocean_documentation_04.png 13KB
cmocean_documentation_02.png 52KB
cmocean_documentation_08.png 28KB
cmocean_documentation_05.png 54KB
cmocean_documentation.html 17KB
cmocean.m 478KB
README.md 1KB
plotPress.m 10KB
cleanCenterlines.m 6KB
outline2masks.m 642B
importFrame.m 674B
importMasks.m 296B
queen2src
bishop2.m 39KB
README2.pdf 263KB
queen2.m 56KB
parameters2.m 5KB
README2.docx 960KB
makeOutlines.m 2KB
quiverColor.m 934B
MaskRepair2
interp2path.m 924B
fixOutlinePoints.m 2KB
figSize.m 355B
waitForKeyPress.m 497B
fixOutline.m 1011B
repairOutlines.m 3KB
plotFrameWithOutline.m 851B
curvspace
curvspace.m 3KB
license.txt 1KB
importData.m 143B
movePress.m 323B
masking
maskMasked.m 463B
FishMask.m 2KB
makeMask3.m 5KB
FishMask2.m 2KB
regiongrow.m 1KB
customcolormap.m 7KB
customcolormap_preset.m 2KB
exportCleanMasks.m 574B
共 73 条
- 1
资源评论
Matlab科研辅导帮
- 粉丝: 2w+
- 资源: 7668
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功