Commit e742b18e authored by Daniel Bourgault's avatar Daniel Bourgault

Addition of the function g_geotiff.m to help make geotif figures

parent 4f1faf35
......@@ -25,7 +25,7 @@ hfov = 62.00; % Field of view of the camera
lambda = 53.0; % Dip angle below horizontal (e.g. straight down = 90, horizontal = 0)
phi = 1.0; % Tilt angle (generally close to 0).
H = 1.755; % Camera altitude (m)
theta = 180.0; % View angle anticlockwise from North (e.g. straight East = 270)
theta = 180.0; % View angle clockwise from North (e.g. straight East = 90)
% Uncertainty in parameters. Set the uncertainty to 0.0 for fixed parameters.
dhfov = 5.0;
......
function [] = g_geotiff(LON,LAT,dx,lon_min,lon_max,lat_min,lat_max)
%
% This function creates geotiff images given the longitudes (LON)
% and latitudes (LAT) of every pixels of the associated jpeg images found
% in the current folder. The matrices LON and LAT typically come from the
% g_rect package.
%
% The geotiff images are constructed by interpolating on a regular grid of
% size dx (in m) the irregularly-spaced pixel intensities defined by the
% LON-LAT pair.
%
% INPUT PARAMETERS:
%
% LON: A matrix of size identical to the associated images in the current
% folder that gives the longitude of every pixel of those images.
% This matrix would typically come from the g_rect package.
%
% LAT: Same as LON but for the latitude.
%
% dx: The grid size (in m) of the regularly-spaced interpolated
% geotif image
%
% lon_min: The longitude of the southwest corner of the desired
% geotif image.
%
% lon_max: The longitude of the northeastcorner of the desired
% geotif image.
%
% lat_min: The latitude of the southwest corner of the desired
% geotif image.
%
% lat_max: The latitude of the northeastcorner of the desired
% geotif image.
%
% OUTPUT:
%
% This function writes geotiff images that have the same name as the
% jpeg images but with the extension .tif
%
% LAST REVISION: 5 May 2020
%
% AUTHOR:
% - Daniel Bourgault (daniel_bourgault@uqar.ca)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Construct the vectors 'lon' and 'lat' that define the interpolating
% grid of constant resolution dx (in m)
lat0 = (lat_min + lat_max)/2;
dlat = dx/(1852*60);
dlon = dlat/cosd(lat0);
lon = [lon_min:dlon:lon_max];
lat = [lat_min:dlat:lat_max];
% Find the indices of only the finite values in the matrix LON
% so that the interpolation is only done on finite values and does
% not spend time interpolating NaNs.
ifinite = find(isfinite(LON) == 1);
% Find all .jpg images in the current folder
img_fname = dir('*.jpg');
N_img = length(img_fname);
% Loop over all images
for i = 1:N_img
img = imread(img_fname(i).name);
% Convert to gray scale
img = rgb2gray(img);
img = double(img);
img = img';
% Interpolate on the regular grid defined above by the vector
% lon and lat
img_interp = griddata(LON(ifinite),LAT(ifinite),img(ifinite),lon,lat');
% Convert real numbers to unsigned integers
img_interp = uint8(img_interp);
% Write the geotiff file
geotif_img_fname = [img_fname(i).name(1:end-3),'tif']
bbox = [lon_min, lat_min; lon_max, lat_max];
geotiffwrite(geotif_img_fname, bbox, flipud(img_interp),8);
end
\ No newline at end of file
......@@ -116,7 +116,7 @@ end
fclose(fid);
%% Import the GCP data (4 column) at the end of the parameter file
gcp = importdata(inputFname,' ',nHeaderLine);
gcp = importdata(inputFname,' ',nHeaderLine)
i_gcp = gcp.data(:,1);
j_gcp = gcp.data(:,2);
lon_gcp = gcp.data(:,3);
......
This diff is collapsed.
Copyright (c) 2010, Jimmy Shen
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment