Skip to content

Commit

Permalink
Added imageCoordinates function.
Browse files Browse the repository at this point in the history
Reverse of worldCoordinates.
  • Loading branch information
Jean-Francois Lalonde committed Jun 11, 2013
1 parent 0baac8a commit f62634d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions mycode/EnvironmentMap.m
Expand Up @@ -492,8 +492,8 @@ function display(e)
envMap = zeros(size(u, 1), size(u, 2), e.nbands);

% Interpolate at pixel _centers_
cols = linspace(0, 1, e.ncols*2+1); cols = cols(2:2:end);
rows = linspace(0, 1, e.nrows*2+1); rows = rows(2:2:end);
[cols, rows] = e.imageCoordinates();
cols = row(cols(1, 1:end)); rows = row(rows(1:end, 1));

% pad the image
tmpData = e.data;
Expand All @@ -517,20 +517,30 @@ function display(e)
end

function [x, y, z, valid] = worldCoordinates(e)
% Returns the [x,y,z] world coordinates for each pixel in the
% environment map
% Returns the [x,y,z] world coordinates for each pixel center
%
% [x, y, z, valid] = e.worldCoordinates()
%

% Compute coordinates of pixel _centers_
[u, v] = e.imageCoordinates();
[x, y, z, valid] = e.image2world(u, v);
end

function [u, v] = imageCoordinates(e)
% Returns the [u,v] coordinates for each pixel center
%
% [u, v] = e.imageCoordinates()
%
% Both [u,v] will be in the [0,1] interval
%

cols = linspace(0, 1, e.ncols*2+1); cols = cols(2:2:end);
rows = linspace(0, 1, e.nrows*2+1); rows = rows(2:2:end);

[u, v] = meshgrid(cols, rows);
[x, y, z, valid] = e.image2world(u, v);
end

function [u, v] = world2image(e, x, y, z)
% Returns the [u,v] coordinates (in the [0,1] interval)
%
Expand Down

0 comments on commit f62634d

Please sign in to comment.