Public Sub get_2012_image_values(X_sol As Double, Y_sol As Double, Z_sol As Double) ' This routine reads the CSV with 2012 image data, solves the file position, gets the RGB-values, computes ' the angular observations then. Note, versions for RGB, RGBN, PAN versions Dim N_image As Long, C_image As String, p_x As Double, p_y As Double, hdrname As String, k As Double ReDim Ar(1 To 3, 1 To 3) As Double Dim paikka As Long, i As Long Close (22) Dim kuvatyyppi As String Target = "Puu1" kuvatyyppi = "RGB8" 'kuvatyyppi = "RGBN16" 'kuvatyyppi = "PAN16" SaveImage = False Select Case kuvatyyppi Case "RGBN16" Dim imdata As RGBNIR Open "c:\data\cam_data_2012_col_16.csv" For Input As 22 Case "PAN16" Dim PANpikseli As Integer Open "c:\data\cam_data_2012_pan_16.csv" For Input As 22 Case "RGB8" Dim pikseli As RGBtriplet Open "c:\data\cam_data_2012.csv" For Input As 22 End Select counter = 0 On Error Resume Next Kill "c:\data\Imafiles\*.txt" Do Until EOF(22) Input #22, N_image, Ndummy, c_, omega, phi, kappa, Xo, Yo, Zo, C_image, hdrname, c_year Close (1) Open hdrname For Input As 1 Call read_set_file_for_an_image(100) Call r_transform_ground_to_pixel(100, X_sol, Y_sol, Z_sol, p_x, p_y) Rem Check if the point falls to this image p_y = (image_info(100).Height - 1) - p_y If p_x > 3 And p_x < image_info(100).Width - 3 And p_y > 3 And p_y < image_info(100).Height - 3 Then Rem it does Open "c:\data\ImaFiles\" & c_year & "_" & C_image & ".txt" For Output As 3 Print #3, N_image & "," & hdrname & ","; X_sol & "," & Y_sol & "," & Z_sol Close (3) Call Open_An_image_and_Center_to_XYZ("c:\data\ImaFiles\" & c_year & "_" & C_image & ".txt") Open image_info(100).FileName For Binary As 5 p_y = CDbl(CLng(p_y)) p_x = CDbl(CLng(p_x)) Select Case kuvatyyppi Case "RGBN16" ' ********** RGBN16 Get #5, 1 + ((p_y) * 4) * image_info(100).Width * 2 + (p_x) * 4 * 2, imdata.r Get #5, 1 + ((p_y) * 4) * image_info(100).Width * 2 + (p_x) * 4 * 2 + 2, imdata.G Get #5, 1 + ((p_y) * 4) * image_info(100).Width * 2 + (p_x) * 4 * 2 + 4, imdata.B Get #5, 1 + ((p_y) * 4) * image_info(100).Width * 2 + (p_x) * 4 * 2 + 6, imdata.NIR Case "RGB8" ' ********* RGB8 Rsum = 0: gsum = 0: bsum = 0 For Ix = -1 To 1 For jx = -1 To 1 paikka = CLng(p_y + jx) * CLng(image_info(100).sub_width) * 3 + CLng(p_x + Ix) * 3 Get #5, paikka, pikseli Rsum = Rsum + pikseli.r gsum = gsum + pikseli.G bsum = bsum + pikseli.B Next jx Next Ix pikseli.r = Rsum / 9 pikseli.G = gsum / 9 pikseli.B = bsum / 9 Case "PAN16" ' ************ PAN16 Rsum = 0 For Ix = -1 To 1 For jx = -1 To 1 Get #5, 1 + ((p_y + jx) * 1) * image_info(100).Width * 2 + (p_x + Ix) * 1 * 2, PANpikseli Get #5, paikka, PANpikseli Rsum = Rsum + PANpikseli Next jx Next Ix PANpikseli = Rsum / 9 End Select Rem Compute the view-illuimnation geometry i = 100 Fii = (90 - image_info(i).Sun_azimuth * TO_DEGREES) * TO_RADIANS ' sun azimuth Theta = (90 - image_info(i).Sun_elevation * TO_DEGREES) * TO_RADIANS ' sun elevation Dim SunV As Vector3D, CamV As Vector3D, plumb As Vector3D, t1 As Vector3D, t2 As Vector3D SunV.X = 1 * Sin(Theta) * Cos(Fii): SunV.Y = 1 * Sin(Theta) * Sin(Fii): SunV.z = 1 * Cos(Theta) CamV.X = image_info(i).Xo - X_sol: CamV.Y = image_info(i).Yo - Y_sol: CamV.z = image_info(i).Zo - Z_sol t1.X = SunV.X: t1.Y = SunV.Y: t1.z = 0 t2.X = CamV.X: t2.Y = CamV.Y: t2.z = 0 plumb.X = 0: plumb.Y = 0: plumb.z = 1 Ai = TO_DEGREES * vector_angle(plumb, CamV) ' view zenith in degrees Bi = TO_DEGREES * vector_angle(t1, t2) ' azimuth difference in degrees Rem Store the data per image to this file Select Case kuvatyyppi Case "RGBN16" Open "c:\temp\" & Target & "_RGBN16.txt" For Append As 6 Print #6, Target, image_info(0).ImageCode, Ai, Bi, Theta * TO_DEGREES, Fii * TO_DEGREES, imdata.r, imdata.G, imdata.B, imdata.NIR If SaveImage = True Then SavePicture Form1.Picture1(0).Image, "c:\temp\" & Target & "_RGBN16_" & image_info(0).ImageCode & ".bmp" End If Case "RGB8" Open "c:\temp\" & Target & "_RGB8.txt" For Append As 6 Print #6, Target, image_info(0).ImageCode, Ai, Bi, Theta * TO_DEGREES, Fii * TO_DEGREES, pikseli.r, pikseli.G, pikseli.B If SaveImage = True Then SavePicture Form1.Picture1(0).Image, "c:\temp\" & Target & "_RGB8_" & image_info(0).ImageCode & ".bmp" End If Case "PAN16" Open "c:\temp\" & Target & "_PAN16.txt" For Append As 6 Print #6, Target, image_info(0).ImageCode, Ai, Bi, Theta * TO_DEGREES, Fii * TO_DEGREES, PANpikseli If SaveImage = True Then SavePicture Form1.Picture1(0).Image, "c:\temp\" & Target & "_PAN16_" & image_info(0).ImageCode & ".bmp" End If End Select Close (6) Close (5) counter = counter + 1 Rem Prepare for storing the images for later inspection ' SavePicture Form1.Picture1(0).Image, "c:\temp\" & image_info(0).ImageCode & ".bmp" ' SavePicture Form1.Picture1(0).Image, "c:\temp\avi\" & Format$(counter, "000") & ".bmp" End If Call Remove_all_images Loop ' Next image Close (22) If selection = False Then MsgBox ("Written " & Ntimes & " files in c:\Data\Imafiles") End Sub