private void AssertComponent(IMagickImage <QuantumType> image, IConnectedComponent <QuantumType> component, int id, int x, int y, int width, int height, int area, IMagickColor <QuantumType> color, int centroidX, int centroidY) { var delta = 2; Assert.Equal(id, component.Id); Assert.InRange(component.X, x - delta, x + delta); Assert.InRange(component.Y, y - delta, y + delta); Assert.InRange(component.Width, width - delta, width + delta); Assert.InRange(component.Height, height - delta, height + delta); Assert.InRange(area, component.Area - delta, component.Area + delta); ColorAssert.Equal(color, component.Color); Assert.InRange(component.Centroid.X, centroidX - delta, centroidX + delta); Assert.InRange(component.Centroid.Y, centroidY - delta, centroidY + delta); using (var componentImage = image.Clone()) { componentImage.Crop(component.ToGeometry(10)); Assert.InRange(componentImage.Width, width + 20 - delta, width + 20 + delta); Assert.InRange(componentImage.Height, height + 20 - delta, height + 20 + delta); } }
private void AssertComponent(IMagickImage <QuantumType> image, IConnectedComponent <QuantumType> component, int id, int x, int y, int width, int height, int area, IMagickColor <QuantumType> color, int centroidX, int centroidY) { var delta = 2; Assert.AreEqual(id, component.Id); Assert.AreEqual(x, component.X, delta); Assert.AreEqual(y, component.Y, delta); Assert.AreEqual(width, component.Width, delta); Assert.AreEqual(height, component.Height, delta); Assert.AreEqual(area, component.Area, delta); ColorAssert.AreEqual(color, component.Color); Assert.AreEqual(centroidX, component.Centroid.X, delta); Assert.AreEqual(centroidY, component.Centroid.Y, delta); using (var componentImage = image.Clone()) { componentImage.Crop(component.ToGeometry(10)); Assert.AreEqual(width + 20, componentImage.Width, delta); Assert.AreEqual(height + 20, componentImage.Height, delta); } }