Question

Need to create a function, which crops an image, given four points.

Input:---------->Image, four corner points

Output:------->Cropped image

I have come across two types of cropping functions so far,

1)which uses a point, Height & width

2)which uses a point, height, width & an angle However these functions don't seem to solve my issue completely.

In order to be more clear, I have tried to depict my intentions in the image below. Cropping an image, by specifying corner points

Était-ce utile?

La solution

Finally found the solution to my problem :)

// define quadrilateral's corners
List<IntPoint> corners = new List<IntPoint>( );
corners.Add( new IntPoint(  x1,  y1 ) );
corners.Add( new IntPoint( x2,  y2 ) );
corners.Add( new IntPoint( x3, y3 ) );
corners.Add( new IntPoint( x4, y4 ) );
// create filter
QuadrilateralTransformation filter=new QuadrilateralTransformationBilinear( corners, NewWidth, NewHeight );
// apply the filter
Bitmap newImage = filter.Apply( image );

This would convert any quadrilateral into a Rectangular one. It helped me, hope this information is helpful to others as well.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top