我用手机拍摄了倾斜图像。我想在两边的两个矩形之间切割图像的部分,找出它们之间的圆。我有中间部分的所有4个坐标,比如(x0,y0),(x1,y1),(x2,y2),(x3,y3)。
但是作物功能我有点像
public static Bitmap CropImage(int x, int y, int width, int height, Bitmap bitmap)
{
Bitmap croppedImage;
var originalImage = bitmap;
{
Rectangle crop = new Rectangle(x, y, width, height);
croppedImage = originalImage.Clone(crop, originalImage.PixelFormat);
} // Here we release the original resource - bitmap in memory and file on disk.
return croppedImage;
}
但上面的函数将部分剪切为矩形,如第一个和第二个红色框所示。
我正在寻找代码,以削减部分显示在第三个红色矩形。我搜索了代码,找到了下面的代码
List<IntPoint> corners = new List<IntPoint>();
corners.Add(new IntPoint(x0, y0));
corners.Add(new IntPoint(x3, y3));
corners.Add(new IntPoint(x1 + 30, y1 + 20));
corners.Add(new IntPoint(x2 + 30, y2 + 0));
AForge.Imaging.Filters.QuadrilateralTransformation filter = new AForge.Imaging.Filters.QuadrilateralTransformation(corners, WidthOfCut, HeightOfCut);
Bitmap newImage = filter.Apply(mainOuterWindow);
这就扰乱了圆的形状,使其成为椭圆,这就给其他计算带来了问题。
请让我知道如何裁剪图像使用4点。