3

I need to perform image perspective operation from command line?

Is there any place where documentation is provided properly. I have asked this question on stack overflow, you can check here.

If any other tool is available which provides command line interface to do same thing then it will also good for me.

2

Probably the best tool for manipulating images would be ImageMagick. If you take a look at the documentation there are extensive examples that show how to use the -distort feature which I believe is what you're looking for.

Example

Before             ss #1                  After      enter image description here

Command line to perform the conversion:

$ convert checks.png -filter point           
    -virtual-pixel tile -mattecolor DodgerBlue
    -distort Perspective '0,0 20,60  90,0 70,63  0,90 5,83  90,90 85,88'
    horizon_tile_point.png

There are 2 other methods for doing the sampling to get the resulting image looking better. Specifically "Grid Super Sampling" & "Elliptical Weighted Area (EWA) Resampling". The latter is the default.

How do I calculate the coordinates?

There are 2 resources for getting a grasp of how to generate the series of coordinates to convert. The first is the one I gave above. The second is this SO Q&A titled: Understanding Perspective Projection Distortion ImageMagick, specifically @KurtPfeifle's answer.

The coordinates are as follows:

Sx1,Sy1 Dx1,Dy1   Sx2,Sy2 Dx2,Dy2   Sx3,Sy3 Dx3,Dy3   ...   Sxn,Syn Dxn,Dyn  
  • x is used to represent an X coordinate.
  • y is used to represent an Y coordinate.
  • 1, 2, 3, ... n is used to represent the 1st, 2nd, 3rd, ... nth pixel.
  • S is used here for the source pixel.
  • D is used here for the destination pixel.

References

  • I have gone through similar kind of process i guess, need one more help. can you tell the place of wiki where position of 16 points we are giving is specified. Its not on main site, I am using Imagick class' distortImage() – gkd May 14 '14 at 12:47
  • @mastkalandar - see updates. Take a look at the SO Q&A I linked, it has everything you need to understand the coordinates. – slm May 14 '14 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.