I'm creating a program that is designed to check multiple choice tests. My application is meant squares which will search the pixels of a different color than the background color (white). Stringbuilder I used to line up the position of individual points (square corners).
My question is: How the StringBuilder, which you can see in the codeblock below, first assign a value to a variable myPoint.X a second (separated by commas) to the variable myPoint.Y? In stringbuilder I separate the points by a semicolon?
Secondly: Is having these points I can draw squares, between which I will search the pixels?
Thanks for help.
public void ImageProcessing(PictureBox pbox, Bitmap bitmap, TextBox tb1)
{
//var nbitmap = UnmanagedImage.FromManagedImage(bitmap);
bitmap = (Bitmap)pbox.Image.Clone();
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width,
bitmap.Height),
ImageLockMode.ReadWrite, bitmap.PixelFormat);
ColorFiltering colorFiltering = new ColorFiltering();
colorFiltering.Red = new IntRange(0, 64);
colorFiltering.Green = new IntRange(0, 64);
colorFiltering.Blue = new IntRange(0, 64);
colorFiltering.FillOutsideRange = false;
colorFiltering.ApplyInPlace(bitmapData);
IntPoint myPoint = new IntPoint();
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 15;
blobCounter.MinWidth = 15;
blobCounter.ProcessImage(bitmapData);
Blob[] blobs = blobCounter.GetObjectsInformation();
bitmap.UnlockBits(bitmapData);
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
Graphics g = Graphics.FromImage(bitmap);
Pen redPen = new Pen(Color.Red, 3);
Pen bluePen = new Pen(Color.Blue, 3);
List<IntPoint> corners = new List<IntPoint>();
StringBuilder sb = new StringBuilder();
string stg = "";
List<IntPoint> zbior = new List<IntPoint>();
for (int i = 0, n = blobs.Length; i < n; i++)
{
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
if (shapeChecker.IsQuadrilateral(edgePoints, out corners))
{
PolygonSubType subType = shapeChecker.CheckPolygonSubType(corners);
Pen pen = null;
if (subType == PolygonSubType.Square)
{
pen = (corners.Count == 4) ? redPen : bluePen;
foreach (var item in corners)
{
sb.Append(item).Append(";");
}
}
g.DrawPolygon(pen, ToPointsArray(corners));
}
}
tb1.Text = stg;
redPen.Dispose();
bluePen.Dispose();
g.Dispose();
Clipboard.SetDataObject(bitmap);
pbox.Image = bitmap;
}
}