-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvect2rast.m
executable file
·28 lines (22 loc) · 912 Bytes
/
vect2rast.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
%% vect2rast.m
% Alistair Boettiger Date Begun: 01/30/11
%
%% Description
% Convert vector data to raster data
% Returns linear indices of points and Rastermap.
% x -- x coordinates of position vector
% y -- y coordinates of position vector
% w -- width of raster map
% h -- height of raster map
% % Sample data for troubleshooting
% x = D2(:,1); y = D2(:,2);
% h = 2048; w=h; h*w
function [rasterMap, inds] = vect2rast(x,y,w,h,scale)
x = x/scale;
y = y/scale;
h = ceil(h/scale);
w = ceil(w/scale);
inds = floor(y)+floor(x)*h; % convert x-y indexing to linear indexing
rasterMap = false(h,w);
rasterMap(inds) = 1; % raster map of RNA1 positions
% figure; imshow(rasterMap);