1st idea: Use verbose to get the eight transformation coefficients, like in this code, but I have no clue where to find the message containing the coefficients. It shall go to “Standard error channel”, but what is that when running VBA-code?
Code: Select all
msgs = img.Convert(InputFile, "-virtual-pixel", "background", "-verbose", "+distort", "Projection", _
"0,0,0,0 800,0,800,-100 800,600,800,500 0,600,0,600", OutputFile)
2nd idea: Get the color of each pixel along the image frame to locate the corner. I tried this, but it is much too time consuming since I run the Convert command for each pixel.
Code: Select all
ImageHeight = img.Identify("-format", "%h", OutputFile)
X = 1
For Y = 1 To ImageHeight
PixelCoordinates = "%[pixel:p{" & X & "," & Y & "}]"
msgs = img.Convert(OutputFile, "-format", PixelCoordinates, "info:")
If msgs <> "white" Then
CornerY = Y
Exit Sub
End If
Next Y
4th idea: I write code that will calculate the eight transformation coefficients from the four sets of control points. This is my last option which I have not tried yet.