Efficient way of gathering 4 point subimage, matrix transformation problems + antialiasing

86 Views Asked by At

QUICK RECAP OF THE PROJECT:

I'm making a car that would drive itself in between the obstacles of which picture will be taken by your phone. The picture should then be cropped to the size of the "area of movement" or the area where car can move. That should have been done automatically. In my case I’d do it like this:

  1. Before you would take picture of the "obstacle map", you would have to put a paper sheet on the ground, so the program would recognize the size of the area/the way image should be transformed to be "perpendicular" to the ground.
  2. In program you would mark the area where car can move and it would crop it. Then it would automatically transform the selected area to be as "perpendicular" as possible, so the obstacle map would be good enough for the car to move in it as it would be an obstacle map.

Then I have 2 options: either to automate obstacle recognition or to make it manual. If I would automate it, I would have to use some sort of OpenCV obstacle recognition. Else id just make a simple program for marking obstacles. After that you would mark a point, where the car should move to and it would calculate the most optimal path with A algorithm. This algorithm only gives the points where the car should move, so I connected with some professors in my school and they are now doing some help with steering of car and calculating the right angle the car should steer to come to certain location.*

I have 2 questions, both connected with BufferedImage.

  1. Two questions back in the past, I asked how to get a sub image that is defined by 4 random points. I got no answers for doing that so I did it myself, but I know that this method is VERY INEFFICIENT and I'd like to know how can it be done better?
  2. My second question is about matrix transformation. I have already been discussing about that and got this code which is basically a modded version of this one. The code is limiting me to the size of the input bufferedimage and i'd like to know how can I "remove" this limit, because in some cases the image needs to be upscaled, but the code keeps cropping it. Also I’d like to have some sort of AA (Anti Aliasing) on it, because the transformed image just looks weird/pixelated.

EDIT: In first question's code, there is a method line(Point p1, Point p2) in class Place_2D which basically creates an arraylist of points connecting 2 points in place, creating a line.

1

There are 1 best solutions below

2
On

Antialiasing will be achieved by a better sampling scheme than nearest-neighbor. You will get a nice improvement by switching to bilinear interpolation.

Every back-projected point falls between four pixels. The fractional part of the coordinates allow you to compute mixing weights to be assign to the color values of these four pixels.

If the scaling factor is small (transformed image being less than a quarter of the original), you can blur the image beforehand to avoid other artifacts.