[关闭]
@TangWill 2019-10-24T23:41:55.000000Z 字数 2638 阅读 729

算法排版

latex


  1. \documentclass[8pt,twocolumn]{ctexart}
  2. \usepackage{amssymb}
  3. \usepackage{bm}
  4. \usepackage{textcomp} %命令\textacutedbl的包,二阶导符号
  5. % Page length commands go here in the preamble
  6. \setlength{\oddsidemargin}{-0.25in} % Left margin of 1 in + 0 in = 1 in
  7. \setlength{\textwidth}{9in} % 纸张宽度Right margin of 8.5 in - 1 in - 6.5 in = 1 in
  8. \setlength{\topmargin}{-.75in} % Top margin of 2 in -0.75 in = 1 in
  9. \setlength{\textheight}{9.2in} % Lower margin of 11 in - 9 in - 1 in = 1 in
  10. \setlength{\parindent}{0in}
  11. \makeatletter
  12. %\newif\if@restonecol
  13. \makeatother
  14. \let\algorithm\relax
  15. \let\endalgorithm\relax
  16. \usepackage[linesnumbered,ruled,vlined]{algorithm2e}%[ruled,vlined]{
  17. \usepackage{algpseudocode}
  18. \usepackage{amsmath}
  19. \renewcommand{\algorithmicrequire}{\textbf{Input:}}
  20. \renewcommand{\algorithmicensure}{\textbf{Output:}}
  21. \begin{document}
  22. \begin{algorithm}
  23. \caption{GF(4) 3D reconstruction}
  24. \LinesNumbered
  25. \KwIn{$\mathcal{X}\in\mathbb{R}^{l_1\times l_2\times l_3},K_c,K_p,R,T$}
  26. \KwOut{$Coord_{i,j}$}
  27. \textbf{Initialize} all $GF^{(i,j)}s$
  28. \For{ each $X_{i_j}^k(N_0\le i\le N_1,M_0\le j\le M_1,k \in (r,g,b))$ }
  29. {
  30. $d=\max(|
  31. \sum_{i=-\epsilon}^\epsilon I(x^k +i,y^k)- \sum_{j=-\epsilon}^\epsilon I(x^k,y^k+j)
  32. |)$\;
  33. \If{$d > t$}
  34. {
  35. $C_{ij}=-1$
  36. }\Else{
  37. $Candidate_{ij}=-3$
  38. }
  39. }
  40. \For{ each $Candidate_{i_j}^k(N_0\le i\le N_1,M_0\le j\le M_1)$ }
  41. {
  42. \If {$Candidate_{ij}==-1$}
  43. {
  44. $\rho_C=\frac{n\sum_{i=1}^nM_{Ci}M_{Ci'}-\sum_{i=1}^nM_{Ci}\sum_{i=1}^nM_{Ci'}}{\sqrt{n\sum_{i=1}^nM_{Ci}^2-(\sum_{i=1}^nM_{Ci})^2}\sqrt{n\sum_{i=1}^nM_{Ci}'^2-(\sum_{i=1}^nM_{Ci'})^2}}$\;
  45. \If{$\rho_C>t$}
  46. {
  47. $GridPoint_{ij}=-1$
  48. }
  49. }
  50. }
  51. \For{ each $GridPoint_{i_j}^k(N_0\le i\le N_1,M_0\le j\le M_1)$ }
  52. {
  53. $FeaturePoint_{i,j}=BFS(GridPoint_{i,j},FLAG)$\;
  54. \If{$FeaturePoint_{i,j}==-1$}{
  55. \If{$\sum_{i=-\epsilon}^\epsilon I(x^k +i,y^k)- \sum_{j=-\epsilon}^\epsilon I(x^k,y^k+j)>0$}
  56. {
  57. $FeaturePoint_{i,j}=-1$
  58. }\Else{
  59. $FeaturePoint_{i,j}=-2$
  60. }
  61. }
  62. }
  63. \For{ each $FeaturePoint_{i_j}^k(N_0\le i\le N_1,M_0\le j\le M_1)$ }
  64. {
  65. \If{$FeaturePoint_{i,j}\neq-1 and FeaturePoint_{i,j}\neq-2 $}{
  66. $s=\sqrt{1-\frac{rg+gb+rb}{r^2+g^2+b^2}}$\;
  67. $h_r=\frac{2r-g-b}{2\sqrt{(r-g)^2}+(r-b)(g-b)}$\;
  68. $h_g=\frac{2g-r-b}{2\sqrt{(g-r)^2}+(g-b)(r-b)}$\;
  69. $h_b=\frac{2b-g-r}{2\sqrt{(b-g)^2}+(b-r)(g-r)}$\;
  70. $k=s-\sqrt{1-\max(h_r,h_g,h_b)}$
  71. \If{$k<0.2$}
  72. {
  73. $FeaturePoint_{i,j}=0$
  74. }\Else
  75. {
  76. $FeaturePoint_{i,j}=\max(r,g,b)$
  77. }
  78. }
  79. }
  80. \For{ each $FeaturePoint_{i_j}^k(N_0\le i\le N_1,M_0\le j\le M_1)$ }
  81. {
  82. \If{$FeaturePoint_{i,j}==-1 or FeaturePoint_{i,j}==-2$}
  83. {
  84. $(u_1m_{31}^1-m_{11}^1)X_W+(u_1m_{32}^1-m_{12}^1)Y_W+(u_1m_{33}^1-m_{13}^1)Z_W=m_{14}^1-u_1m_{34}^1$\;
  85. $(v_1m_{31}^1-m_{21}^1)X_W+(v_1m_{32}^1-m_{22}^1)Y_W+(v_1m_{33}^1-m_{23}^1)Z_W=m_{24}^1-v_1m_{34}^1$\;
  86. $(u_1m_{31}^2-m_{11}^2)X_W+(u_1m_{32}^2-m_{12}^2)Y_W+(u_1m_{33}^2-m_{13}^2)Z_W=m_{14}^2-u_1m_{34}^2$\;
  87. $Coord_{i,j}=(X_W,Y_W,Z_W)$
  88. }
  89. }
  90. \end{algorithm}
  91. \end{document}
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注