PixelTrackingDialog.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. using OpenCvSharp;
  2. using Resources;
  3. using SmartCoalApplication.Adjust.BaseImage;
  4. using SmartCoalApplication.Core;
  5. using SmartCoalApplication.Core.CustomControl;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. namespace SmartCoalApplication.AutomaticMeasurement
  16. {
  17. /// <summary>
  18. /// 像素跟踪
  19. /// </summary>
  20. internal class PixelTrackingDialog : FloatingToolForm
  21. {
  22. #region 控件
  23. private Label label6;
  24. private Label label5;
  25. private Label label4;
  26. private Label label3;
  27. private Label label2;
  28. private Label label1;
  29. private LinearColorPickerControl panel1;
  30. private PictureBox pictureBox1;
  31. private Label label7;
  32. private Label label8;
  33. private NumericUpDown numericUpDown1;
  34. private TrackBar trackBar1;
  35. private Label label9;
  36. #endregion
  37. private AppWorkspace appWorkspace;
  38. /// <summary>
  39. /// 原图、hls(可优化)、鹰眼图(从经过缩放的图片获取)、经过缩放的图片
  40. /// </summary>
  41. private Mat ImageROI, bmat = new Mat();
  42. /// <summary>
  43. /// rgb像素点
  44. /// </summary>
  45. private Vec3b bgr;
  46. /// <summary>
  47. /// hls像素点
  48. /// </summary>
  49. private double h, s, v;
  50. /// <summary>
  51. /// 缩放倍数
  52. /// </summary>
  53. private int scale;
  54. /// <summary>
  55. /// 中间十字和圆的颜色
  56. /// 根据左侧的panel的被选中的背景色变化
  57. /// </summary>
  58. private Color color = Color.Red;
  59. private Mat mat;
  60. // 创建委托
  61. public delegate void TransferDataDelegate();
  62. // 声明一个事件(本质是一个委托)
  63. public event TransferDataDelegate TransferEvent;
  64. public Mat Mat
  65. {
  66. set
  67. {
  68. this.mat = value;
  69. }
  70. }
  71. private void trackBar1_ValueChanged(object sender, EventArgs e)
  72. {
  73. if (mat != null)
  74. {
  75. scale = this.trackBar1.Value;
  76. this.numericUpDown1.Value = this.trackBar1.Value;
  77. //Cv2.Resize(mat, bmat, new OpenCvSharp.Size(mat.Width * scale, mat.Height * scale));
  78. //Mat temp = new Mat(new OpenCvSharp.Size(bmat.Width + 100, bmat.Height + 100), bmat.Type());
  79. //Cv2.CopyMakeBorder(bmat, temp, 50, 50, 50, 50, BorderTypes.Constant, Scalar.All(255));
  80. //bmat = temp;
  81. }
  82. }
  83. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  84. {
  85. if (mat != null)
  86. {
  87. scale = (int)this.numericUpDown1.Value;
  88. this.trackBar1.Value = scale;
  89. //Cv2.Resize(mat, bmat, new OpenCvSharp.Size(mat.Width * scale, mat.Height * scale));
  90. //Mat temp = new Mat(new OpenCvSharp.Size(bmat.Width + 100, bmat.Height + 100), bmat.Type());
  91. //Cv2.CopyMakeBorder(bmat, temp, 50, 50, 50, 50, BorderTypes.Constant, Scalar.All(255));
  92. //bmat = temp;
  93. }
  94. }
  95. /// <summary>
  96. /// 构造函数
  97. /// </summary>
  98. /// <param name="appWorkspace"></param>
  99. public PixelTrackingDialog(AppWorkspace appWorkspace)
  100. {
  101. this.appWorkspace = appWorkspace;
  102. InitializeComponent();
  103. this.label9.Text = PdnResources.GetString("Menu.Times.text");
  104. this.Text = PdnResources.GetString("Menu.Tools.PixelTracking.Text");
  105. this.label7.Parent = this.pictureBox1;
  106. this.label8.Parent = this.pictureBox1;
  107. this.label7.Location = new System.Drawing.Point(0, 0);
  108. this.label8.Location = new System.Drawing.Point(0, 17);
  109. this.pictureBox1.Paint += new PaintEventHandler(PictureBox1_Paint);
  110. }
  111. private void PixelTrackingDialog_FormClosing(object sender, FormClosingEventArgs e)
  112. {
  113. TransferEvent();
  114. }
  115. /// <summary>
  116. /// PictureBox的绘制事件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void PictureBox1_Paint(object sender, PaintEventArgs e)
  121. {
  122. e.Graphics.DrawLine(new Pen(color), 0, 50, 100, 50);
  123. e.Graphics.DrawLine(new Pen(color), 50, 0, 50, 100);
  124. e.Graphics.DrawEllipse(new Pen(color), new Rectangle(25, 25, 50, 50));
  125. }
  126. ///// <summary>
  127. ///// 左侧panel,渐变背景色
  128. ///// </summary>
  129. ///// <param name="sender"></param>
  130. ///// <param name="e"></param>
  131. //private void Panel1_Paint(object sender, PaintEventArgs e)
  132. //{
  133. // LinearGradientBrush brush = new LinearGradientBrush(e.ClipRectangle, Color.Yellow, Color.Blue, LinearGradientMode.Vertical);
  134. // ColorBlend colorBlend = new ColorBlend();
  135. // colorBlend.Colors = new Color[]{ Color.Yellow, Color.Red, Color.Green, Color.Blue };
  136. // colorBlend.Positions = new float[] { 0 / 3f, 1 / 3f, 2 / 3f, 3 / 3f };
  137. // brush.InterpolationColors = colorBlend;
  138. // e.Graphics.FillRectangle(brush, e.ClipRectangle);
  139. //}
  140. private void Panel1_ValueChanged(object sender, IndexEventArgs ce)
  141. {
  142. color = panel1.ValueToColor(panel1.Value);
  143. pictureBox1.Refresh();
  144. }
  145. private void InitializeComponent()
  146. {
  147. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  148. this.label6 = new System.Windows.Forms.Label();
  149. this.label5 = new System.Windows.Forms.Label();
  150. this.label4 = new System.Windows.Forms.Label();
  151. this.label3 = new System.Windows.Forms.Label();
  152. this.label2 = new System.Windows.Forms.Label();
  153. this.label1 = new System.Windows.Forms.Label();
  154. this.panel1 = new LinearColorPickerControl();
  155. this.label7 = new System.Windows.Forms.Label();
  156. this.label8 = new System.Windows.Forms.Label();
  157. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  158. this.trackBar1 = new System.Windows.Forms.TrackBar();
  159. this.label9 = new System.Windows.Forms.Label();
  160. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  161. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  162. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  163. this.SuspendLayout();
  164. //
  165. // pictureBox1
  166. //
  167. this.pictureBox1.Location = new System.Drawing.Point(21, 8);
  168. this.pictureBox1.Name = "pictureBox1";
  169. this.pictureBox1.Size = new System.Drawing.Size(100, 100);
  170. this.pictureBox1.TabIndex = 1;
  171. this.pictureBox1.TabStop = false;
  172. //
  173. // label6
  174. //
  175. this.label6.AutoSize = true;
  176. this.label6.Location = new System.Drawing.Point(124, 95);
  177. this.label6.Name = "label6";
  178. this.label6.Size = new System.Drawing.Size(11, 12);
  179. this.label6.TabIndex = 14;
  180. this.label6.Text = "V";
  181. //
  182. // label5
  183. //
  184. this.label5.AutoSize = true;
  185. this.label5.Location = new System.Drawing.Point(124, 79);
  186. this.label5.Name = "label5";
  187. this.label5.Size = new System.Drawing.Size(11, 12);
  188. this.label5.TabIndex = 13;
  189. this.label5.Text = "S";
  190. //
  191. // label4
  192. //
  193. this.label4.AutoSize = true;
  194. this.label4.Location = new System.Drawing.Point(124, 63);
  195. this.label4.Name = "label4";
  196. this.label4.Size = new System.Drawing.Size(11, 12);
  197. this.label4.TabIndex = 12;
  198. this.label4.Text = "H";
  199. //
  200. // label3
  201. //
  202. this.label3.AutoSize = true;
  203. this.label3.Location = new System.Drawing.Point(124, 41);
  204. this.label3.Name = "label3";
  205. this.label3.Size = new System.Drawing.Size(11, 12);
  206. this.label3.TabIndex = 11;
  207. this.label3.Text = "B";
  208. //
  209. // label2
  210. //
  211. this.label2.AutoSize = true;
  212. this.label2.Location = new System.Drawing.Point(124, 25);
  213. this.label2.Name = "label2";
  214. this.label2.Size = new System.Drawing.Size(11, 12);
  215. this.label2.TabIndex = 10;
  216. this.label2.Text = "G";
  217. //
  218. // label1
  219. //
  220. this.label1.AutoSize = true;
  221. this.label1.Location = new System.Drawing.Point(124, 9);
  222. this.label1.Name = "label1";
  223. this.label1.Size = new System.Drawing.Size(35, 12);
  224. this.label1.TabIndex = 9;
  225. this.label1.Text = "R=255";
  226. //
  227. // panel1
  228. //
  229. this.panel1.Count = 1;
  230. this.panel1.CustomGradient = new System.Drawing.Color[] {
  231. System.Drawing.Color.White,
  232. System.Drawing.Color.Yellow,
  233. System.Drawing.Color.Red,
  234. System.Drawing.Color.Green,
  235. System.Drawing.Color.Blue,
  236. System.Drawing.Color.Black};
  237. this.panel1.DrawFarNub = true;
  238. this.panel1.DrawNearNub = true;
  239. this.panel1.Location = new System.Drawing.Point(3, 8);
  240. this.panel1.MaxColor = System.Drawing.Color.White;
  241. this.panel1.MinColor = System.Drawing.Color.Black;
  242. this.panel1.Name = "panel1";
  243. this.panel1.Orientation = System.Windows.Forms.Orientation.Vertical;
  244. this.panel1.Size = new System.Drawing.Size(14, 100);
  245. this.panel1.TabIndex = 17;
  246. this.panel1.TabStop = false;
  247. this.panel1.Value = 153;
  248. this.panel1.ValueChanged += new IndexEventHandler(this.Panel1_ValueChanged);
  249. //
  250. // label7
  251. //
  252. this.label7.AutoSize = true;
  253. this.label7.BackColor = System.Drawing.Color.Transparent;
  254. this.label7.Location = new System.Drawing.Point(24, 11);
  255. this.label7.Name = "label7";
  256. this.label7.Size = new System.Drawing.Size(17, 12);
  257. this.label7.TabIndex = 18;
  258. this.label7.Text = "X=";
  259. //
  260. // label8
  261. //
  262. this.label8.AutoSize = true;
  263. this.label8.BackColor = System.Drawing.Color.Transparent;
  264. this.label8.Location = new System.Drawing.Point(24, 27);
  265. this.label8.Name = "label8";
  266. this.label8.Size = new System.Drawing.Size(17, 12);
  267. this.label8.TabIndex = 19;
  268. this.label8.Text = "Y=";
  269. //
  270. // numericUpDown1
  271. //
  272. this.numericUpDown1.Location = new System.Drawing.Point(4, 114);
  273. this.numericUpDown1.Maximum = new decimal(new int[] {
  274. 10,
  275. 0,
  276. 0,
  277. 0});
  278. this.numericUpDown1.Minimum = new decimal(new int[] {
  279. 1,
  280. 0,
  281. 0,
  282. 0});
  283. this.numericUpDown1.Name = "numericUpDown1";
  284. this.numericUpDown1.Size = new System.Drawing.Size(37, 21);
  285. this.numericUpDown1.TabIndex = 20;
  286. this.numericUpDown1.Value = new decimal(new int[] {
  287. 1,
  288. 0,
  289. 0,
  290. 0});
  291. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  292. //
  293. // trackBar1
  294. //
  295. this.trackBar1.Location = new System.Drawing.Point(68, 114);
  296. this.trackBar1.Minimum = 1;
  297. this.trackBar1.Name = "trackBar1";
  298. this.trackBar1.Size = new System.Drawing.Size(91, 45);
  299. this.trackBar1.TabIndex = 21;
  300. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  301. this.trackBar1.Value = 1;
  302. this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
  303. //
  304. // label9
  305. //
  306. this.label9.AutoSize = true;
  307. this.label9.Location = new System.Drawing.Point(45, 118);
  308. this.label9.Name = "label9";
  309. this.label9.Size = new System.Drawing.Size(0, 12);
  310. this.label9.TabIndex = 22;
  311. //
  312. // PixelTrackingDialog
  313. //
  314. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  315. this.ClientSize = new System.Drawing.Size(164, 141);
  316. this.Controls.Add(this.label9);
  317. this.Controls.Add(this.trackBar1);
  318. this.Controls.Add(this.numericUpDown1);
  319. this.Controls.Add(this.label8);
  320. this.Controls.Add(this.label7);
  321. this.Controls.Add(this.panel1);
  322. this.Controls.Add(this.label6);
  323. this.Controls.Add(this.label5);
  324. this.Controls.Add(this.label4);
  325. this.Controls.Add(this.label3);
  326. this.Controls.Add(this.label2);
  327. this.Controls.Add(this.label1);
  328. this.Controls.Add(this.pictureBox1);
  329. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  330. this.Name = "PixelTrackingDialog";
  331. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PixelTrackingDialog_FormClosing);
  332. this.Controls.SetChildIndex(this.pictureBox1, 0);
  333. this.Controls.SetChildIndex(this.label1, 0);
  334. this.Controls.SetChildIndex(this.label2, 0);
  335. this.Controls.SetChildIndex(this.label3, 0);
  336. this.Controls.SetChildIndex(this.label4, 0);
  337. this.Controls.SetChildIndex(this.label5, 0);
  338. this.Controls.SetChildIndex(this.label6, 0);
  339. this.Controls.SetChildIndex(this.panel1, 0);
  340. this.Controls.SetChildIndex(this.label7, 0);
  341. this.Controls.SetChildIndex(this.label8, 0);
  342. this.Controls.SetChildIndex(this.numericUpDown1, 0);
  343. this.Controls.SetChildIndex(this.trackBar1, 0);
  344. this.Controls.SetChildIndex(this.label9, 0);
  345. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  346. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  347. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  348. this.ResumeLayout(false);
  349. this.PerformLayout();
  350. }
  351. /// <summary>
  352. /// 设置像素跟踪的数据
  353. /// </summary>
  354. public unsafe void SetImageAndData(System.Drawing.Point point, DocumentView doc)
  355. {
  356. mat = doc.CompositionSurface.CreatedAliasedMat(mat);
  357. scale = int.Parse(this.numericUpDown1.Value.ToString());
  358. if (point.X >= 0 && point.Y >= 0 && point.X <= mat.Width && point.Y <= mat.Height)
  359. {
  360. if (point.X < 50 || point.X > mat.Width - 50 || point.Y < 50 || point.Y > mat.Height - 50)
  361. {
  362. int direction = CalcDirection(point, mat);
  363. Mat temp_1 = CalcCropMat(direction, point, mat);
  364. bmat = CalcCopyMakeBorder(direction, temp_1);
  365. }
  366. else
  367. {
  368. bmat = new Mat(mat, new Rect(point.X - 50, point.Y - 50, 100, 100));
  369. }
  370. }
  371. this.label7.Text = "X=" + point.X.ToString();
  372. this.label8.Text = "Y=" + point.Y.ToString();
  373. if (point.X > 0 && point.Y > 0 && point.X < mat.Width && point.Y < mat.Height)
  374. {
  375. bgr = mat.At<Vec3b>(point.Y, point.X);
  376. this.label1.Text = "R=" + bgr[2];
  377. this.label2.Text = "G=" + bgr[1];
  378. this.label3.Text = "B=" + bgr[0];
  379. BaseTools.RgbToHsv(bgr, out h, out s, out v);
  380. this.label4.Text = "H=" + (int)(h / 2);
  381. this.label5.Text = "S=" + (int)(s * 255);
  382. this.label6.Text = "V=" + (int)(v * 255);
  383. //设置源图像ROI
  384. //Rect roi = new Rect(point.X, point.Y, 100, 100);//首先要用个rect确定我们的兴趣区域在哪
  385. //ImageROI = new Mat(bmat, roi);
  386. ImageROI = bmat;
  387. //按缩放比例截取小图像
  388. Rect roi1 = new Rect((100 - 100 / scale) / 2, (100 - 100 / scale) / 2, 100 / scale, 100 / scale);
  389. ImageROI = new Mat(ImageROI, roi1);
  390. //按固定宽高放大图像
  391. Cv2.Resize(ImageROI, ImageROI, new OpenCvSharp.Size(100, 100));
  392. this.pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(ImageROI);
  393. }
  394. GC.Collect();
  395. this.Refresh();
  396. }
  397. /// <summary>
  398. /// 计算方向 1上 2右上 3右 4右下 5下 6左下 7左 8左上
  399. /// </summary>
  400. /// <returns></returns>
  401. private int CalcDirection(System.Drawing.Point point, Mat mat)
  402. {
  403. int direction = 1;
  404. if (point.Y < 100) direction = 1;
  405. if (point.X > mat.Width - 100) direction = 3;
  406. if (point.Y > mat.Height - 100) direction = 5;
  407. if (point.X < 100) direction = 7;
  408. if (point.Y < 100 && point.X > mat.Width - 100) direction = 2;
  409. if (point.X > mat.Width - 100 && point.Y > mat.Height - 100) direction = 4;
  410. if (point.X < 100 && point.Y > mat.Height - 100) direction = 6;
  411. if (point.Y < 100 && point.X < 100) direction = 8;
  412. return direction;
  413. }
  414. /// <summary>
  415. /// 截取部分mat
  416. /// 1上 2右上 3右 4右下 5下 6左下 7左 8左上
  417. /// </summary>
  418. /// <param name="direction"></param>
  419. /// <param name="point"></param>
  420. /// <param name="mat"></param>
  421. private Mat CalcCropMat(int direction, System.Drawing.Point point, Mat mat)
  422. {
  423. Mat temp = null;
  424. int x, y, x_off, y_off;
  425. switch (direction)
  426. {
  427. case 1: //上
  428. temp = new Mat(mat, new Rect(point.X - 50, point.Y, 100, point.Y < 50 ? 50 : point.Y));
  429. break;
  430. case 2: //右上
  431. x = point.X - 50;
  432. y = point.Y;
  433. x_off = (mat.Width - x) > 100 ? 100 : (mat.Width - x);
  434. y_off = 50;
  435. temp = new Mat(mat, new Rect(x, y, x_off, y_off));
  436. break;
  437. case 3: //右
  438. temp = new Mat(mat, new Rect(point.X - 50,
  439. point.Y - 50,
  440. point.X > mat.Width - 50 ? 50 : mat.Width - point.X,
  441. 100));
  442. break;
  443. case 4: //右下
  444. x = point.X - 50;
  445. y = point.Y - 50;
  446. x_off = (mat.Width - x) > 100 ? 100 : (mat.Width - x);
  447. y_off = (mat.Height - y) > 100 ? 100 : (mat.Height - y);
  448. temp = new Mat(mat, new Rect(x, y, x_off, y_off));
  449. break;
  450. case 5: //下
  451. y = point.Y - 50;
  452. temp = new Mat(mat, new Rect(point.X - 50, y, 100, (mat.Height - y) > 100 ? 100 : (mat.Height - y)));
  453. break;
  454. case 6: //左下
  455. x = point.X;
  456. y = point.Y - 50;
  457. x_off = 50;
  458. y_off = (mat.Height - y) > 100 ? 100 : (mat.Height - y);
  459. temp = new Mat(mat, new Rect(x, y, x_off, y_off));
  460. break;
  461. case 7: //左
  462. temp = new Mat(mat, new Rect(point.X, point.Y - 50, 50, 100));
  463. break;
  464. case 8: //左上
  465. temp = new Mat(mat, new Rect(point.X, point.Y, 50, 50));
  466. break;
  467. }
  468. return temp;
  469. }
  470. /// <summary>
  471. /// 扩展边界
  472. /// 1上 2右上 3右 4右下 5下 6左下 7左 8左上
  473. /// </summary>
  474. /// <param name="direction"></param>
  475. /// <param name="temp_1"></param>
  476. /// <returns></returns>
  477. private Mat CalcCopyMakeBorder(int direction, Mat temp_1)
  478. {
  479. switch (direction)
  480. {
  481. case 1:
  482. Cv2.CopyMakeBorder(temp_1, temp_1, 100 - temp_1.Height, 0, 0, 0, BorderTypes.Constant, Scalar.All(255));
  483. break;
  484. case 2:
  485. Cv2.CopyMakeBorder(temp_1, temp_1, 100 - temp_1.Height, 0, 0, 100 - temp_1.Width, BorderTypes.Constant, Scalar.All(255));
  486. break;
  487. case 3:
  488. Cv2.CopyMakeBorder(temp_1, temp_1, 0, 0, 0, 100 - temp_1.Width, BorderTypes.Constant, Scalar.All(255));
  489. break;
  490. case 4:
  491. Cv2.CopyMakeBorder(temp_1, temp_1, 0, 100 - temp_1.Height, 0, 100 - temp_1.Width, BorderTypes.Constant, Scalar.All(255));
  492. break;
  493. case 5:
  494. Cv2.CopyMakeBorder(temp_1, temp_1, 0, 100 - temp_1.Height, 0, 0, BorderTypes.Constant, Scalar.All(255));
  495. break;
  496. case 6:
  497. Cv2.CopyMakeBorder(temp_1, temp_1, 0, 100 - temp_1.Height, 100 - temp_1.Width, 0, BorderTypes.Constant, Scalar.All(255));
  498. break;
  499. case 7:
  500. Cv2.CopyMakeBorder(temp_1, temp_1, 0, 0, 100 - temp_1.Width, 0, BorderTypes.Constant, Scalar.All(255));
  501. break;
  502. case 8:
  503. Cv2.CopyMakeBorder(temp_1, temp_1, 100 - temp_1.Height, 0, 100 - temp_1.Width, 0, BorderTypes.Constant, Scalar.All(255));
  504. break;
  505. }
  506. return temp_1;
  507. }
  508. }
  509. }