At 08:36 PM 11/30/1999 +1000, [EMAIL PROTECTED] wrote:
>just a quick question, has anyone had experience with trying to automate
>the image registration process, I have a table of co-ordinates representing
>the four corners of an image, and I want to write a program to generate
>the Registered TAB files, the snag is that I can't find a way of extracting
>the image size parameters that are present when using the registration tool
>inside MiPro, any help would be appreciated.
Here's a MapBasic routine that I wrote with some help from Dimitri
Bogdanov. In my case, my corners came from reading the object geometry in
another table (Labins 3m Key). This code was written to work with JPEG
files, but I have the rest of the routines for many other image formats if
you need them.
==================================================
Include "MapBasic.DEF"
Dim siWidth, siHeight, Val, i, n, j As SmallInt
Dim Offset As Integer
Dim sFilename as String
Dim x(4), y(4), cX, cY as Float
Close all interactive
Open Table "J:\DOQQ\Labins 3m Key.TAB" Interactive
Map From Labins_3m_Key
Select Key
from Labins_3m_Key
where JPEG= 1 and Table = 0
order by Key
into Build
i = TableInfo(Build, TAB_INFO_NROWS)
For n = 1 to i
Fetch Rec n From Build
sFileName = "j:\doqq\" + selection.key + ".jpg"
Print selection.key
'----- Get JPEG Width / Height -----
Open File sFileName For Binary Access Read As #1 ByteOrder HIGHLOW
Offset = 21
Do
Get #1, Offset, Val
If Val = -64 Then
Exit Do
End If
Get #1, Offset + 2, Val
Offset = Offset + Val + 2
Loop While TRUE
Get #1, Offset + 5, siHeight
Get #1, Offset + 7, siWidth
Close File #1
'----- Get map control points -----
For j = 1 to 4
cX = CentroidX(selection.obj)
cY = CentroidY(selection.obj)
If ObjectNodeX(selection.obj, 1, j) < cX and
ObjectNodeY(selection.obj, 1, j) > cY Then
x(1) = ObjectNodeX(selection.obj, 1, j)
y(1) = ObjectNodeY(selection.obj, 1, j)
ElseIf ObjectNodeX(selection.obj, 1, j) > cX and
ObjectNodeY(selection.obj, 1, j) > cY Then
x(2) = ObjectNodeX(selection.obj, 1, j)
y(2) = ObjectNodeY(selection.obj, 1, j)
ElseIf ObjectNodeX(selection.obj, 1, j) > cX and
ObjectNodeY(selection.obj, 1, j) < cY Then
x(3) = ObjectNodeX(selection.obj, 1, j)
y(3) = ObjectNodeY(selection.obj, 1, j)
ElseIf ObjectNodeX(selection.obj, 1, j) < cX and
ObjectNodeY(selection.obj, 1, j) < cY Then
x(4) = ObjectNodeX(selection.obj, 1, j)
y(4) = ObjectNodeY(selection.obj, 1, j)
End If
Next
'----- Print MapInfo TAB file with registry info -----
Open File "j:\doqq\" + selection.key + ".tab" For Output As #1
Print #1, "!table"
Print #1, "!version 300"
Print #1, "!charset WindowsLatin1"
Print #1, ""
Print #1, " Definition Table"
Print #1, " File """ + selection.key + ".jpg"""
Print #1, " Type ""Raster"""
Print #1, " (" + x(1) + "," + y(1) + ") (0,0) Label ""NW"","
Print #1, " (" + x(2) + "," + y(2) + ") ("+ siwidth +",0) Label ""NE"","
Print #1, " (" + x(3) + "," + y(3) + ") (" + siwidth + "," + siheight + ")
Label ""SE"","
Print #1, " (" + x(4) + "," + y(4) + ") (0," + siheight + ") Label ""SW"""
Print #1, " CoordSys Earth Projection 9, 33, ""m"", -84, 24, 24, 31.5,
400000, 0"
Print #1, " Units ""degree"""
Close File #1
Next
==================================================
Steve Wallace
GIS & Market Information Manager
Florida Farm Bureau Insurance Companies
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]