-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathQ.m
36 lines (29 loc) · 901 Bytes
/
Q.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
29
30
31
32
33
34
35
36
function [ Q ] = Q(rows, cols)
%Q Summary of this function goes here
% Detailed explanation goes here
H = fspecial('laplacian');
[Hm,Hn] = size(H);
Hrad = 1;
N = rows*cols;
rowinds = ones(N, Hm*Hn);
colinds = ones(N,Hm*Hn);
data = zeros(N,Hm*Hn);
inds = reshape(1:N,rows,cols);
k = 1;
for i=1:rows
for j=1:cols
win = inds(max(1,i-Hrad):min(rows,i+Hrad),max(1,j-Hrad):min(cols,j+Hrad));
topcutoff = max(0,1-i+Hrad);
leftcutoff = max(0,1-j+Hrad);
bottomcutoff = max(0,i+Hrad-rows);
rightcutoff = max(0, j+Hrad-cols);
[r,s] = size(win);
data(k,1:r*s) = reshape( H((1+topcutoff):(Hm-bottomcutoff),(1+leftcutoff):(Hn-rightcutoff)), 1, r*s );
win = reshape(win,1,r*s);
colinds(k,1:r*s) = win;
rowinds(k,1:r*s) = repmat([k],1,r*s);
k = k + 1;
end
end
Q = sparse(rowinds,colinds,data, N, N);
end