摘要

小记一下第一次参加数模赛

思路

问题一

用高斯滤波对图像 Pic1_1 和 Pic1_2 进行降噪处理,用灰度值开运算降低图像 Pic1_ 3的噪声;对三个图像进行二值化处理,将灰度图像转化为二值化图像,其次用圆形元素对区域进行膨胀,再用改进的 canny 方法提取亚像素精确边缘,对 XLD 轮廓用最小二乘近似线平滑,再根据斜率以及拐点将 XLD 轮廓分割为直线段和圆弧段或椭圆弧,最后根据轮廓的相对位置对轮廓进行排序,并获取XLD轮廓的长度及区域位置

问题二

为达到自标定消除畸变的目的,通过最小二乘近似线平滑、均值滤波降噪、局部阈值分割等算法,将输出的XLD轮廓分割,连接两个标志性的对象元组重复问题一的步骤得到最佳的校准径向畸变参数,用来校准图像的径向畸变由轮廓的相对位置对轮廓进行排序并获取XLD轮廓的长度,最后根据轮廓长度以及实际的物理坐标计算出6个轮廓的真实长度

问题三

依据问题一的模型将 XLD 轮廓分割为直线段和圆弧段或椭圆弧。当分割轮廓为直线段时,用最小二乘法进行直线拟合并用多边形生成XLD轮廓;圆弧段或圆,用 algebraic 方法使轮廓点与生成的圆之间的代数距离最小化;椭圆弧或椭圆,基于 tukey 的算法对轮廓点进行加权并忽略异常值

结果

问题一

问题二

问题三

代码

问题一


read_image (Img, 'Pic1_1.bmp')
dev_close_window ()
get_image_size (Img, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
gauss_filter(Img, ImgGauss, 11)
binary_threshold (ImgGauss, Region,  'smooth_histo', 'dark', UsedThreshold)
boundary (Region, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDread_image (Img, 'Pic1_1.bmp')
dev_close_window ()
get_image_size (Img, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
gauss_filter(Img, ImgGauss, 11)
binary_threshold (ImgGauss, Region,  'smooth_histo', 'dark', UsedThreshold)
boundary (Region, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDilation, 2.5)
reduce_domain (ImgGauss, RegionDilation, ImgReduced)
edges_sub_pix (ImgReduced, Edges, 'canny', 2, 20, 60)
smooth_contours_xld(Edges, ImgSmoothed, 9)
segment_contours_xld (ImgSmoothed, ContoursSplit, 'lines_circles', 5, 4, 3)
count_obj (ContoursSplit, Number)
dev_display (Img)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)
sort_contours_xld (ContoursSplit, SortedContours, 'upper_left', 'true', 'column')
count_obj (ContoursSplit, Number)
length_xld(SortedContours,Length)
gen_empty_obj (Line)
for i := 1 to 24 by 1select_obj (SortedContours, ObjectSelected, i)get_contour_xld (ObjectSelected, Row, Col)gen_region_polygon (Region, Row,Col)concat_obj (Line, Region, Line)
endfor
X := Col
Y := Rowilation, 2.5)
reduce_domain (ImgGauss, RegionDilation, ImgReduced)
edges_sub_pix (ImgReduced, Edges, 'canny', 2, 20, 60)
smooth_contours_xld(Edges, ImgSmoothed, 9)
segment_contours_xld (ImgSmoothed, ContoursSplit, 'lines_circles', 5, 4, 3)
count_obj (ContoursSplit, Number)
dev_display (Img)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)
sort_contours_xld (ContoursSplit, SortedContours, 'upper_left', 'true', 'column')
count_obj (ContoursSplit, Number)
length_xld(SortedContours,Length)
gen_empty_obj (Line)
for i := 1 to 24 by 1select_obj (SortedContours, ObjectSelected, i)get_contour_xld (ObjectSelected, Row, Col)gen_region_polygon (Region, Row,Col)concat_obj (Line, Region, Line)
endfor
X := Col
Y := Row
read_image (Img, 'Pic1_2.bmp')
dev_close_window ()
get_image_size (Img, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
gauss_filter(Img, ImgGauss, 11)
binary_threshold (ImgGauss, Region,  'smooth_histo', 'dark', UsedThreshold)
boundary (Region, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDilation, 2.5)
reduce_domain (ImgGauss, RegionDilation, ImgReduced)
edges_sub_pix (ImgReduced, Edges, 'canny', 2, 20, 60)
smooth_contours_xld(Edges, ImgSmoothed, 9)
segment_contours_xld (ImgSmoothed, ContoursSplit, 'lines_circles', 5, 4, 3)
count_obj (ContoursSplit, Number)
dev_display (Img)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)
sort_contours_xld (ContoursSplit, SortedContours, 'upper_left', 'true', 'column')
count_obj (ContoursSplit, Number)
length_xld(SortedContours,Length)
gen_empty_obj (Line)
for i := 1 to 84 by 1select_obj (SortedContours, ObjectSelected, i)get_contour_xld (ObjectSelected, Row, Col)gen_region_polygon (Region, Row,Col)concat_obj (Line, Region, Line)
endfor
x := round(Col)
y := round(Row)
read_image (Img, 'Pic1_3.bmp')
dev_close_window ()
get_image_size (Img, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
gray_opening_shape (Img, ImgOpen, 16, 16, 'octagon')
mean_image(ImgOpen, ImgMean, 9.3, 9.3)
binary_threshold (ImgMean, Region,  'smooth_histo', 'dark',  UsedThreshold)
boundary (Region, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDilation, 4.6)
reduce_domain (ImgMean, RegionDilation, ImgReduced)
edges_sub_pix (ImgReduced, Edges, 'canny', 2, 20, 60)
union_cotangential_contours_xld (Edges, UnionContours, 2, 5, 3.14, 25.0, 10, 2.0, 'attr_forget')
smooth_contours_xld(UnionContours, ImgSmoothed, 9)
segment_contours_xld (ImgSmoothed, ContoursSplit, 'lines_circles', 5, 4, 3)
count_obj (ContoursSplit, Number)
dev_display (Img)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)
sort_contours_xld (ContoursSplit, SortedContours, 'upper_left', 'true', 'column')
count_obj (ContoursSplit, Number)
length_xld(SortedContours,Length)
gen_empty_obj (Line)
for i := 1 to 120 by 1select_obj (SortedContours, ObjectSelected, i)get_contour_xld (ObjectSelected, Row, Col)gen_region_polygon (Region, Row,Col)concat_obj (Line, Region, Line)
endfor
x := round(Col)
y := round(Row)

问题二


dev_update_off ()
read_image (Img, 'Pic2_4.bmp')
dev_close_window ()
dev_open_window_fit_image (Img, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_display (Img)
disp_message (WindowHandle, 'Img with radial distortions', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
gen_empty_obj (Borders)
for N := 1 to 4 by 1read_image (Img, 'Pic2_' + N$'d' + '.bmp')edges_sub_pix (Img, ImgBorders, 'canny', 1, 10, 40)smooth_contours_xld(ImgBorders, ImgSmoothed, 9)segment_contours_xld (ImgSmoothed, SplitBorders, 'lines_circles', 5, 4, 2)select_shape_xld (SplitBorders, SelectedBorders, 'contlength', 'and', 30, 100000)concat_obj (Borders, SelectedBorders, Borders)dev_display (Img)dev_set_colored (12)dev_display (SelectedBorders)disp_message (WindowHandle, 'Edges extracted from image ' + N$'d', 'window', 0, 0, 'black', 'true')
endfor
dev_clear_window ()
dev_set_colored (12)
dev_display (Borders)
disp_message (WindowHandle, 'Collected edges from multiple images', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
dev_clear_window ()
disp_message (WindowHandle, 'Performing self-calibration...', 'window', 0, 0, 'black', 'true')
radial_distortion_self_calibration (Borders, CalibrationBorders, 1296, 972, 0.08, 42, 'division', 'fixed', 0, CamParMultiImage)
dev_clear_window ()
dev_set_colored (12)
dev_display (CalibrationBorders)
disp_message (WindowHandle, 'Edges used for calibration', 'window', 0, 0, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
change_radial_distortion_cam_par ('fixed', CamParMultiImage, 0, CamParMultiImageRect)
read_image (ImgCir, 'Pic2_1.bmp')
get_domain (ImgCir, Domain)
change_radial_distortion_image (ImgCir, Domain, ImgCirRectified, CamParMultiImage, CamParMultiImageRect)
get_image_size (ImgCir, WidthCir, HeightCir)
dev_open_window_fit_image (ImgCir, 0, 0, -1, -1, WindowHandleCir)
set_display_font (WindowHandleCir, 16, 'mono', 'true', 'false')
dev_display (ImgCir)
mean_image(ImgCir, MeanCir, 61, 61)
dyn_threshold(ImgCir, MeanCir, SegCir, 5, 'dark')
fill_up(SegCir, SegFillUpCir)
connection(SegFillUpCir, segConnectCir)
select_shape(segConnectCir, SelectedRegionsCir, ['area','circularity'], 'and', [500, 0.7], [20000, 1])
smallest_circle(SelectedRegionsCir, RowCir, ColumnCir, RadiusCir)
area_center(SelectedRegionsCir, AreaCir, Row1Cir, Column1Cir)
CRadius:=sqrt(AreaCir/3.1415926)
RowSize := mean(0.5 / CRadius)
read_image (Img, 'Pic2_4.bmp')
get_domain (Img, Domain)
change_radial_distortion_image (Img, Domain, ImageRectified, CamParMultiImage, CamParMultiImageRect)
dev_close_window ()
get_image_size (ImageRectified, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
gauss_filter(Img, ImgGauss, 11)
binary_threshold (ImgGauss, Region,  'smooth_histo', 'dark', UsedThreshold)
boundary (Region, RegionBorder, 'inner')
dilation_circle (RegionBorder, RegionDilation, 2.5)
reduce_domain (ImgGauss, RegionDilation, ImgReduced)
edges_sub_pix (ImgReduced, Borders, 'canny', 2, 20, 60)
smooth_contours_xld(Borders, ImgSmoothed, 9)
dev_display (ImgSmoothed)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
dev_set_colored (12)
dev_set_line_width (3)
sort_contours_xld (ImgSmoothed, SortedContours, 'upper_left', 'true', 'column')
count_obj (ImgSmoothed, Number)
length_xld(SortedContours,Length)
RealSize := Length * RowSize
AllSzie := sum(RealSize)

问题三


read_contour_xld_dxf (DxfContours, 'EdgeContour.dxf', [], [], DxfStatus)
segment_contours_xld (DxfContours, ContoursSplit, 'lines_circles', 5, 4, 3)
sort_contours_xld (ContoursSplit, SortedContours, 'upper_left', 'true', 'column')
count_obj (SortedContours, Number)
dev_display (DxfContours)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
dev_set_colored (12)
dev_set_line_width (3)
dev_display (SortedContours)
dev_set_colored (3)
dev_set_line_width (3)
ColBL := []
RowsBL := []
ColEL := []
RowsEL := []
Lines := []
ColsC := []
RowsC := []
RadiiC := []
PhisC := []
ColsSC := []
RowsSC := []
ColsEC := []
RowsEC := []
ColsE := []
RowsE := []
RadiiE := []
PhisE := []
ColsSE := []
RowsSE := []
ColsEE := []
RowsEE := []
k:=0
J := []
for I := 1 to Number by 1select_obj (SortedContours, ObjectSelected, I)get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib)if(Attrib == -1)k := k+1J := [J,k]fit_line_contour_xld (ObjectSelected, 'tukey', -1, 2, 6, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)gen_contour_polygon_xld (ContLine, [RowBegin,RowEnd], [ColBegin,ColEnd])RowsBL := [RowsBL,RowBegin]RowsEL := [RowsEL,RowEnd]ColBL := [ColBL,ColBegin]ColEL := [ColEL,ColEnd]length_xld(ContLine,LengthL)Lines := [Lines, LengthL]dev_display (ContLine)elseif(Attrib == 1)J := [J,0]fit_circle_contour_xld (ObjectSelected, 'algebraic', -1, 6, 0, 3, 2, RowC, ColumnC, RadiusC, StartPhiC, EndPhiC, PointOrderC)gen_circle_contour_xld (ContCircle, RowC, ColumnC, RadiusC, 0, rad(360), PointOrderC, 1.0)RowsC := [RowsC,RowC]ColsC := [ColsC,ColumnC]RadiiC := [RadiiC,RadiusC]PhisC := [PhisC,(EndPhiC-StartPhiC)*180/3.14159]ColsSC := [ColsSC,ColumnC+RadiusC*cos(StartPhiC)]RowsSC := [RowsSC,RowC+RadiusC*sin(StartPhiC)]ColsEC := [ColsEC,ColumnC+RadiusC*cos(EndPhiC)]RowsEC := [RowsEC,RowC+RadiusC*sin(EndPhiC)]dev_display (ContCircle)elsefit_ellipse_contour_xld(ObjectSelected, 'ftukey',-1, 6, 0, 2, 3, 2, RowE, ColumnE, RadiusE, RaE, RbE, StartPhiE, EndPhiE, PointOrderE)gen_ellipse_contour_xld(ContEllipse, RowE, ColumnE, RadiusE, RaE, RbE, 0, rad(360), PointOrderE, 1.0)RowsE := [RowsE,RowE]ColsE := [ColsE,ColumnE]RadiiE := [RadiiE,RadiusE]PhisE := [PhisE,(EndPhiE-StartPhiE)*180/3.14159]ColsSE := [ColsSE,ColumnE+RadiusE*cos(StartPhiE)]RowsSE := [RowsSE,RowE+RadiusE*sin(StartPhiE)]ColsEE := [ColsEE,ColumnE+RadiusE*cos(EndPhiE)]RowsEE := [RowsEE,RowE+RadiusE*sin(EndPhiE)]dev_display (ContEllipse)J:=[J,-1]endif
endfor

matlab代码


clear;
clc;
a = xlsread('Edge1.xlsx');
b = xlsread('Edge2.xlsx');
FID = dxf_open('EdgeContour.dxf');
dxf_polyline(FID, a(:,1), a(:,2), zeros(length(a),1));
dxf_polyline(FID, b(:,1), b(:,2), zeros(length(b),1));
dxf_close(FID);

DXFLib 库地址: https://www.mathworks.com/matlabcentral/fileexchange/33884-dxflib

Reference

  • 康宇,赵冬青,上官鹏,储成群.基于FPGA的图像边缘保护高斯滤波算法实现[J].电子设计工程,2021,29(06):94-98+110.DOI:10.14022/j.issn1674-6236.2021.06.020.
  • 梁义涛,孟亚敏,朱玲艳,张猛,李永刚.二维Otsu拟合线阈值图像分割方法[J].科学技术与工程,2021,21(09):3689-3697.
  • 王先传,江岩,赵佳,张岩.基于切比雪夫多项式的函数插值逼近[J].阜阳师范学院学报(自然科学版),2017,34(04):7-11+20.DOI:10.14096/j.cnki.cn34-1069/n/1004-4329(2017)04-04-007-05.
  • 吴曦. 基于MATLAB的图像边缘检测算法的研究和实现[D].吉林大学,2014.
  • 苗莉,王昱煜,于小燕.基于FPGA的双线性插值视频缩放算法实现[J].信息与电脑(理论版),2021,33(08):84-86.

2021亚太数学建模竞赛A题简要思路相关推荐

  1. 2022 APMCM亚太数学建模竞赛 C题 全球是否变暖 问题一python代码实现(更新完毕)

    2022 APMCM亚太数学建模竞赛 C题 全球是否变暖 思路及代码实现(持续更新完毕) 更新信息 2022-11-24 10:00 更新问题1和问题2 思路 2022-11-24 23:20 更新问 ...

  2. 2021东三省数学建模竞赛a题

    2021东三省数学建模竞赛a题解题所需资料 内含火星高程图 模拟火星车着陆过程完整代码 动力学方程的建立过程及代码 一篇2014年国赛类似题的获奖论文及代码  10余篇相关研究论文pdf  没有思路的 ...

  3. 2022 APMCM亚太数学建模竞赛 C题 全球是否变暖 问题二python代码实现(更新完毕)

    更新信息 2022-11-24 10:00 更新问题1和问题2 思路 2022-11-24 23:20 更新问题一代码 2022-11-25 11:00 更新问题二代码 相关链接 [2022 APMC ...

  4. 2018 亚太数学建模大赛B题解题思路

    首先说明,本人不参赛.不出售论文,也不以任何形式参与任何商业活动.请不要以任何形式私聊我,这会给我造成困扰.我之所以写这篇博客,仅仅是因为参加了太多的数学建模比赛,知道没有思路的痛苦而已,所以相以学长 ...

  5. 2022 APMCM亚太数学建模竞赛 C题 全球是否变暖 27页论文及代码

    1 题目 全球变暖与否? 加拿大49.6°C的高温为地球北纬50°以上地区创造了新的气温记录,一周内就有数百人死于高温;美国加利福尼亚州死亡谷54.4°C,是地球上有记录以来的最高温度;科威特53.5 ...

  6. 2020年第十七届中国研究生数学建模竞赛B题 -解题思路

    题目B:汽油辛烷值建模 随着当今计算机与各类程序软件的开发使用,化学计量学不断发展,人们可以在近红外光谱区内采集大量的数据,并使用各种有效的统计方法,把近红外光谱技术应用于定性与定量.近红外光谱为分子 ...

  7. 2021美国大学生数学建模竞赛F题翻译

    2021             ICM问题F:检验高等教育的脉搏和温度   一个国家拥有一个健康.可持续的高等教育体系意味着什么?什么问题很重要?是成本.入学机会.公平.资金.学位价值.教育质量.研 ...

  8. 2022亚太数学杯数学建模竞赛C题(思路、程序......)

  9. 2021美国大学生数学建模竞赛赛题

                某盘链接:https://pan.baidu.com/s/1D7Zw_UDX_PwFr3TKhzfsEg  提取码:yyds                          ...

最新文章

  1. 智能车竞赛接入工程训练竞赛相关事项-建议稿件
  2. Ubuntu14.04安装编译ffmpeg
  3. mysql与Json学习总结
  4. 区块链】利用Node.js开发与合约交互的Web界面
  5. MySQL(4) 索引、事务与存储引擎
  6. STC用PCA测量脉宽_教你测量玉手镯圈号及如何轻松快速摘戴玉手镯?
  7. 程序安装mysql数据库_安装Mysql数据库
  8. 【转】国密算法sm4 CBC模式加解密
  9. android 远程下载与pull解析技术
  10. 金橙子激光打标机的二次开发(C#)
  11. html字体版权,字体在网站中的版权问题
  12. 智慧高校怎么做教育监控?Smartbi高校大数据服务平台来帮您
  13. 怎样让硬盘分区显示整数大小
  14. pdf-xchange pro注册码
  15. 华为云PBX_基于华为云客服平台打造的比特百灵鸟AI管家解决方案发布
  16. 后端实践:Nginx日志配置(超详细)
  17. ubuntu16 下安装 dnw 给开发板传输文件,出现的问题以及解决方法
  18. 若依如何手动修改项目包路径呢?
  19. MATLAB运行edge函数闪退
  20. 《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究

热门文章

  1. 小程序用什么开发?快速开发一个自己的微信小程序教程
  2. 大数据分析师·人才培养·高薪起航
  3. PVM and MPI 比较
  4. Open_cv中常用函数的原型及参数解释(一)
  5. [P1919 【模板】A*B Problem升级版(FFT快速傅里叶)(高精乘板子,FFT板子)
  6. 利用交通实时数据和社交媒体数据对飓风疏散期间的交通需求进行预测
  7. 锐捷(三)清除交换机的虚拟化(VSU)配置
  8. 从Dijkstra谈帅才的洞察力(王选)
  9. 移动硬盘文件丢失如何找回丨500G硬盘
  10. 【CTF】Misc4——多种方法解决+闪的好快+come_game+白哥的鸽子+linux