|
|
|
|
@ -6,6 +6,7 @@ using System.Drawing;
@@ -6,6 +6,7 @@ using System.Drawing;
|
|
|
|
|
using System.Drawing.Drawing2D; |
|
|
|
|
using System.Drawing.Imaging; |
|
|
|
|
using System.Reflection; |
|
|
|
|
using System.Security.Cryptography; |
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
using System.Windows.Forms.Design; |
|
|
|
|
using UTIL; |
|
|
|
|
@ -230,10 +231,12 @@ namespace Test_img
@@ -230,10 +231,12 @@ namespace Test_img
|
|
|
|
|
PointBmToPb(new Point(g_super_cluster_coords[m].rect.left, g_super_cluster_coords[m].rect.top)).Y, |
|
|
|
|
(g_super_cluster_coords[m].rect.right - g_super_cluster_coords[m].rect.left) * zoomFactor, |
|
|
|
|
(g_super_cluster_coords[m].rect.bottom - g_super_cluster_coords[m].rect.top) * zoomFactor); |
|
|
|
|
if (show_mass_center.Checked) |
|
|
|
|
} |
|
|
|
|
if (show_mass_center.Checked) |
|
|
|
|
{ |
|
|
|
|
foreach (var item in CalculateMassCentre()) |
|
|
|
|
{ |
|
|
|
|
Point r = CalcCenterMass(CLUSTER_COORD2Rect(g_super_cluster_coords[m])); |
|
|
|
|
Point rct = PointBmToPb(r); |
|
|
|
|
PointF rct = PointFBmToPb(item); |
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), rct.X, rct.Y - 20, rct.X, rct.Y + 20); |
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), rct.X - 20, rct.Y, rct.X + 20, rct.Y); |
|
|
|
|
} |
|
|
|
|
@ -243,7 +246,7 @@ namespace Test_img
@@ -243,7 +246,7 @@ namespace Test_img
|
|
|
|
|
{ |
|
|
|
|
foreach (var pnt in SearchPixel2(imgsearch)) |
|
|
|
|
e.Graphics.DrawEllipse(new Pen(Color.Red), |
|
|
|
|
PointBmToPb(pnt).X - 5 * zoomFactor, |
|
|
|
|
PointBmToPb(pnt).X - 5 * zoomFactor, |
|
|
|
|
PointBmToPb(pnt).Y - 5 * zoomFactor, |
|
|
|
|
10 * zoomFactor, |
|
|
|
|
10 * zoomFactor); |
|
|
|
|
@ -302,36 +305,36 @@ namespace Test_img
@@ -302,36 +305,36 @@ namespace Test_img
|
|
|
|
|
return new Rectangle(p3, new Size(p4.X - p3.X, p2.Y - p3.Y)); |
|
|
|
|
return r; |
|
|
|
|
} |
|
|
|
|
//private void SearchPixel() |
|
|
|
|
//{ |
|
|
|
|
// List<Point> points = new List<Point>(); |
|
|
|
|
// Stopwatch stopwatch = Stopwatch.StartNew(); |
|
|
|
|
// UnsafeBitmap btm = new UnsafeBitmap(bm); |
|
|
|
|
// btm.LockBitmap(); |
|
|
|
|
// for (int y = 0; y < bm.Height; y++) |
|
|
|
|
// { |
|
|
|
|
// for (int x = 0; x < bm.Width; x++) |
|
|
|
|
// { |
|
|
|
|
// PixelData c = btm.GetPixel(x, y); |
|
|
|
|
// if (c.blue >= imgsearch) |
|
|
|
|
// { |
|
|
|
|
// points.Add(new Point(x, y)); |
|
|
|
|
// //Console.WriteLine($"{x} {y}"); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// stopwatch.Stop(); |
|
|
|
|
// Console.WriteLine(stopwatch.Elapsed.ToString()); |
|
|
|
|
// btm.Dispose(); |
|
|
|
|
// using (Graphics g = Graphics.FromImage(newbm)) |
|
|
|
|
// { |
|
|
|
|
// //g.Clear(Color.White); |
|
|
|
|
// for (int i = 0; i < points.Count; i++) |
|
|
|
|
// g.DrawEllipse(new Pen(Color.Red), points[i].X - 5, points[i].Y - 5, 10, 10); |
|
|
|
|
private void SearchPixel() |
|
|
|
|
{ |
|
|
|
|
List<Point> points = new List<Point>(); |
|
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew(); |
|
|
|
|
UnsafeBitmap btm = new UnsafeBitmap(bm); |
|
|
|
|
btm.LockBitmap(); |
|
|
|
|
for (int y = 0; y < bm.Height; y++) |
|
|
|
|
{ |
|
|
|
|
for (int x = 0; x < bm.Width; x++) |
|
|
|
|
{ |
|
|
|
|
PixelData c = btm.GetPixel(x, y); |
|
|
|
|
if (c.blue >= imgsearch) |
|
|
|
|
{ |
|
|
|
|
points.Add(new Point(x, y)); |
|
|
|
|
//Console.WriteLine($"{x} {y}"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
stopwatch.Stop(); |
|
|
|
|
Console.WriteLine(stopwatch.Elapsed.ToString()); |
|
|
|
|
btm.Dispose(); |
|
|
|
|
using (Graphics g = Graphics.FromImage(newbm)) |
|
|
|
|
{ |
|
|
|
|
//g.Clear(Color.White); |
|
|
|
|
for (int i = 0; i < points.Count; i++) |
|
|
|
|
g.DrawEllipse(new Pen(Color.Red), points[i].X - 5, points[i].Y - 5, 10, 10); |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
// pictureBox1.Invalidate(); |
|
|
|
|
//} |
|
|
|
|
} |
|
|
|
|
pictureBox1.Invalidate(); |
|
|
|
|
} |
|
|
|
|
private Point CalcCenterMass(Rectangle r) |
|
|
|
|
{ |
|
|
|
|
Int32 sX = 0; |
|
|
|
|
@ -379,6 +382,10 @@ namespace Test_img
@@ -379,6 +382,10 @@ namespace Test_img
|
|
|
|
|
{ |
|
|
|
|
return new Point((int)(p.X * zoomFactor + movingPoint.X), (int)(p.Y * zoomFactor + movingPoint.Y)); |
|
|
|
|
} |
|
|
|
|
private PointF PointFBmToPb(PointF p) |
|
|
|
|
{ |
|
|
|
|
return new PointF(p.X * zoomFactor + movingPoint.X, p.Y * zoomFactor + movingPoint.Y); |
|
|
|
|
} |
|
|
|
|
private Rectangle RectBmToPb(Rectangle p) |
|
|
|
|
{ |
|
|
|
|
return new Rectangle((int)(p.X * zoomFactor + movingPoint.X), (int)(p.Y * zoomFactor + movingPoint.Y), (int)(p.Width * zoomFactor), (int)(p.Height * zoomFactor)); |
|
|
|
|
@ -537,25 +544,7 @@ namespace Test_img
@@ -537,25 +544,7 @@ namespace Test_img
|
|
|
|
|
|
|
|
|
|
private void img_fon_Click(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
UnsafeBitmap btm = new UnsafeBitmap(bm); |
|
|
|
|
btm.LockBitmap(); |
|
|
|
|
UInt32 sc = 0; |
|
|
|
|
for (int y = 0; y < bm.Height; y++) |
|
|
|
|
{ |
|
|
|
|
PixelData c = btm.GetPixel(y, y); |
|
|
|
|
sc += (UInt32)(c.blue * c.blue); |
|
|
|
|
c = btm.GetPixel(bm.Width - 1 - y, y); |
|
|
|
|
sc += (UInt32)(c.blue * c.blue); |
|
|
|
|
} |
|
|
|
|
Console.WriteLine(sc.ToString()); |
|
|
|
|
sc = (UInt32)Math.Sqrt(sc / bm.Height / 2); |
|
|
|
|
Console.WriteLine(sc.ToString()); |
|
|
|
|
|
|
|
|
|
img_srch.Text = $"Фон: {sc}"; |
|
|
|
|
btm.UnlockBitmap(); |
|
|
|
|
btm.Dispose(); |
|
|
|
|
fon = sc; |
|
|
|
|
StaticData.Fon?.Invoke(sc); |
|
|
|
|
imgfon(); |
|
|
|
|
} |
|
|
|
|
private void imgfon() |
|
|
|
|
{ |
|
|
|
|
@ -577,9 +566,9 @@ namespace Test_img
@@ -577,9 +566,9 @@ namespace Test_img
|
|
|
|
|
btm.UnlockBitmap(); |
|
|
|
|
btm.Dispose(); |
|
|
|
|
fon = sc; |
|
|
|
|
trackbar1.Value = (int)fon + 1; |
|
|
|
|
imgsearch = (int)fon; |
|
|
|
|
StaticData.Fon?.Invoke(sc); |
|
|
|
|
trackbar1.Value = (int)fon + 10; |
|
|
|
|
imgsearch = (int)fon + 10; |
|
|
|
|
//StaticData.Fon?.Invoke(sc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void img_timer_Click(object sender, EventArgs e) |
|
|
|
|
|