// Specify the pixel coordinates from destination to target ArrayList<AssociatedPair> associatedPairs = new ArrayList<AssociatedPair>();
// Projection for the 4 Corners, DOES Work Point2D_F64 pointSource = new Point2D_F64(topLeft.x, topLeft.y); Point2D_F64 pointDest = new Point2D_F64(minX, minY); associatedPairs.add(new AssociatedPair(pointDest, pointSource)); pointSource = new Point2D_F64(topRight.x, topRight.y); pointDest = new Point2D_F64(maxX, minY); associatedPairs.add(new AssociatedPair(pointDest, pointSource)); pointSource = new Point2D_F64(bottomRight.x, bottomRight.y); pointDest = new Point2D_F64(maxX, maxY); associatedPairs.add(new AssociatedPair(pointDest, pointSource)); pointSource = new Point2D_F64(bottomLeft.x, bottomLeft.y); pointDest = new Point2D_F64(minX, maxY); associatedPairs.add(new AssociatedPair(pointDest, pointSource));
// Projection for all borders, does not work
int destX = topLeft.x;
int destY = topLeft.y;
for(Point2D_F64 pointSource: top) {
Point2D_F64 pointDest = new Point2D_F64(destX, destY);
associatedPairs.add(new AssociatedPair(pointDest, pointSource));
destX++;
}
// do that for top, right, left and right
// ....
// Compute the homography DenseMatrix64F H = new DenseMatrix64F(3,3); computeHomography.process(associatedPairs, H); // Create the transform for distorting the image PointTransformHomography_F32 homography = new PointTransformHomography_F32(H); PixelTransform_F32 pixelTransform = new PointToPixelTransform_F32(homography); // Apply distortion and show the results DistortImageOps.distortMS(input,output,pixelTransform,true, TypeInterpolate.BILINEAR);
Link: http://abload.de/image.php?img=image_with_corners_makzacf.jpg
--
You received this message because you are subscribed to the Google Groups "BoofCV" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boofcv+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Quote: assuming (minX,minY) = (0,0) and (maxX,maxY) = (width-1,height-1) of the output image
Sure could you post the code? Is the warping done by using the 4 corners of the book as control points?- Peter
On Tue, Aug 19, 2014 at 5:48 PM, sandreas <andreas....@googlemail.com> wrote:
Got it, i ported the papers warp algorithm and it works as expected. As you see in the image, the borders are warped correctly now and completely straight (disregarding the fingers and other little mistakes). I did not change my initial Algorithm to detect border points / calculate the warp associations, so the calculation here was correct.Unfortunately the resulting text is not straight at all because of the uneven borders, like you did already mention, but perhaps this "new" Warp-Algorithm is useful for boofcv. It'll need huge refactoring, but for now it seems to work. Additionally it could be a bit faster than the existing distortion removal algorithm in boofcv (my subjective impression, i did not measure it). If you wish to see it, I'll submit the code, as soon as it is ready refactored.For straightening the text I'm Working on a text-line-detection / line slope algorithm. I think this would be the right strategy for straighten up the text.In addition to that I ported back your Sauvola implementation (thanks man!) to my own code and combined it with a global otsu threshold. The thresholding result for text is impressive (no artefacts any more, as you see in the image) and quite fast, because no local thresholding is needed any more. Usage:- Apply Sauvola on original image (radius=15, k=0.1f)- Apply Otsu on original image- Make all pixels white, that are white on both images
Before doing the Thresholding, I apply an AutoContrast-Filter, which is based on YUV / YCbCr color model. It applies perfect for this image. Just ask, if you would like to see the code for it.
Point: InfintyNormDistanceTo, add, substract, etc.