plateform
stringclasses
1 value
repo_name
stringlengths
13
113
name
stringlengths
3
74
ext
stringclasses
1 value
path
stringlengths
12
229
size
int64
23
843k
source_encoding
stringclasses
9 values
md5
stringlengths
32
32
text
stringlengths
23
843k
github
aghagol/caffe-ssd-master
classification_demo.m
.m
caffe-ssd-master/matlab/demo/classification_demo.m
5,412
utf_8
8f46deabe6cde287c4759f3bc8b7f819
function [scores, maxlabel] = classification_demo(im, use_gpu) % [scores, maxlabel] = classification_demo(im, use_gpu) % % Image classification demo using BVLC CaffeNet. % % IMPORTANT: before you run this demo, you should download BVLC CaffeNet % from Model Zoo (http://caffe.berkeleyvision.org/model_zoo.html) % % **************************************************************************** % For detailed documentation and usage on Caffe's Matlab interface, please % refer to Caffe Interface Tutorial at % http://caffe.berkeleyvision.org/tutorial/interfaces.html#matlab % **************************************************************************** % % input % im color image as uint8 HxWx3 % use_gpu 1 to use the GPU, 0 to use the CPU % % output % scores 1000-dimensional ILSVRC score vector % maxlabel the label of the highest score % % You may need to do the following before you start matlab: % $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda-5.5/lib64 % $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 % Or the equivalent based on where things are installed on your system % % Usage: % im = imread('../../examples/images/cat.jpg'); % scores = classification_demo(im, 1); % [score, class] = max(scores); % Five things to be aware of: % caffe uses row-major order % matlab uses column-major order % caffe uses BGR color channel order % matlab uses RGB color channel order % images need to have the data mean subtracted % Data coming in from matlab needs to be in the order % [width, height, channels, images] % where width is the fastest dimension. % Here is the rough matlab for putting image data into the correct % format in W x H x C with BGR channels: % % permute channels from RGB to BGR % im_data = im(:, :, [3, 2, 1]); % % flip width and height to make width the fastest dimension % im_data = permute(im_data, [2, 1, 3]); % % convert from uint8 to single % im_data = single(im_data); % % reshape to a fixed size (e.g., 227x227). % im_data = imresize(im_data, [IMAGE_DIM IMAGE_DIM], 'bilinear'); % % subtract mean_data (already in W x H x C with BGR channels) % im_data = im_data - mean_data; % If you have multiple images, cat them with cat(4, ...) % Add caffe/matlab to you Matlab search PATH to use matcaffe if exist('../+caffe', 'dir') addpath('..'); else error('Please run this demo from caffe/matlab/demo'); end % Set caffe mode if exist('use_gpu', 'var') && use_gpu caffe.set_mode_gpu(); gpu_id = 0; % we will use the first gpu in this demo caffe.set_device(gpu_id); else caffe.set_mode_cpu(); end % Initialize the network using BVLC CaffeNet for image classification % Weights (parameter) file needs to be downloaded from Model Zoo. model_dir = '../../models/bvlc_reference_caffenet/'; net_model = [model_dir 'deploy.prototxt']; net_weights = [model_dir 'bvlc_reference_caffenet.caffemodel']; phase = 'test'; % run with phase test (so that dropout isn't applied) if ~exist(net_weights, 'file') error('Please download CaffeNet from Model Zoo before you run this demo'); end % Initialize a network net = caffe.Net(net_model, net_weights, phase); if nargin < 1 % For demo purposes we will use the cat image fprintf('using caffe/examples/images/cat.jpg as input image\n'); im = imread('../../examples/images/cat.jpg'); end % prepare oversampled input % input_data is Height x Width x Channel x Num tic; input_data = {prepare_image(im)}; toc; % do forward pass to get scores % scores are now Channels x Num, where Channels == 1000 tic; % The net forward function. It takes in a cell array of N-D arrays % (where N == 4 here) containing data of input blob(s) and outputs a cell % array containing data from output blob(s) scores = net.forward(input_data); toc; scores = scores{1}; scores = mean(scores, 2); % take average scores over 10 crops [~, maxlabel] = max(scores); % call caffe.reset_all() to reset caffe caffe.reset_all(); % ------------------------------------------------------------------------ function crops_data = prepare_image(im) % ------------------------------------------------------------------------ % caffe/matlab/+caffe/imagenet/ilsvrc_2012_mean.mat contains mean_data that % is already in W x H x C with BGR channels d = load('../+caffe/imagenet/ilsvrc_2012_mean.mat'); mean_data = d.mean_data; IMAGE_DIM = 256; CROPPED_DIM = 227; % Convert an image returned by Matlab's imread to im_data in caffe's data % format: W x H x C with BGR channels im_data = im(:, :, [3, 2, 1]); % permute channels from RGB to BGR im_data = permute(im_data, [2, 1, 3]); % flip width and height im_data = single(im_data); % convert from uint8 to single im_data = imresize(im_data, [IMAGE_DIM IMAGE_DIM], 'bilinear'); % resize im_data im_data = im_data - mean_data; % subtract mean_data (already in W x H x C, BGR) % oversample (4 corners, center, and their x-axis flips) crops_data = zeros(CROPPED_DIM, CROPPED_DIM, 3, 10, 'single'); indices = [0 IMAGE_DIM-CROPPED_DIM] + 1; n = 1; for i = indices for j = indices crops_data(:, :, :, n) = im_data(i:i+CROPPED_DIM-1, j:j+CROPPED_DIM-1, :); crops_data(:, :, :, n+5) = crops_data(end:-1:1, :, :, n); n = n + 1; end end center = floor(indices(2) / 2) + 1; crops_data(:,:,:,5) = ... im_data(center:center+CROPPED_DIM-1,center:center+CROPPED_DIM-1,:); crops_data(:,:,:,10) = crops_data(end:-1:1, :, :, 5);
github
GWLee0524/AMTL-master
learn_B_regression.m
.m
AMTL-master/learn_B_regression.m
2,479
utf_8
b9961fadab09f242b82561681345cd57
function B = learn_B_regression(W,delta,param) maxiter = 500; eval_interval = maxiter / 20; T = size(W,2); if (isfield(param,'B')) B = param.B; else B = ones(T)/T; end G = ones(T); normG = Inf; iter = 0; alpha = 0.000001; %0.000001 maxlsiter = 100; tau = 0.5; b = 0.01; linesearch = 1; for t=1:T B(t,t) = 0; nont{t} = 1:T; nont{t}(t) = []; weight(:,t) = delta(nont{t}); c_t(:,t) = param.c_t(nont{t}); y(:,t) = W(:,t); end EPS = 0.001; while (iter <= maxiter && normG > EPS) iter = iter + 1; prevG = G; for t=1:T beta = B(nont{t},t); X = W(:,nont{t}); %g(:,t) = X'*(X*beta-y(:,t)) + param.lambda*weight(:,t).*beta.*weight(:,t); %g(:,t) = X'*(X*beta-y(:,t)) + param.lambda*weight(:,t).*(beta>0); %g(:,t) = param.lambda*X'*(X*beta-y(:,t)) + weight(:,t).*(beta>0); g(:,t) = param.lambda*X'*(X*beta-y(:,t)) + c_t(:,t).*weight(:,t).*beta.*weight(:,t); G(nont{t},t) = g(:,t); end grad = G(:); beta = B(:); gradnew = zeros(size(beta)); [maxval, mu] = max(beta); gradnew(find(grad-grad(mu) > 0 | beta==0)) = 0; idxusual = setdiff(find(beta>0),mu); gradnew(idxusual) = grad(idxusual)-grad(mu); nonzero = find(grad > 0); [minval, idx] = min(beta(nonzero)./grad(nonzero)); % what if there is no nonzero entry? v = nonzero(idx); gradnew(mu) = grad(mu)-grad(v); grad = gradnew; G = reshape(grad,size(G)); % search for step size using line search stepsize = alpha; finit = loss(W, B, weight, param.lambda,c_t); fnew = loss(W, B-stepsize*G, weight, param.lambda,c_t); lsiter = 0; if (linesearch) while (fnew > finit && lsiter < maxlsiter) lsiter = lsiter + 1; stepsize = tau*stepsize; fnew = loss(W, B-stepsize*G, weight, param.lambda,c_t); end end beta = beta - stepsize*grad; beta(v) = 0; %beta = max(0,beta); beta = param.lambda2*(beta./sum(beta)); %beta = beta./sum(beta); beta(find(beta<0)) = 0; B = reshape(beta,size(B)); %beta = max(0,beta); %beta = sign(beta).*(max(0,abs(beta) - param.lambda2)); normG = norm(G-prevG,'fro'); %beta = beta/sum(abs(beta)); if (mod(iter, eval_interval) == 1) f = fnew; fprintf('%d) %2.4f, ||G||=%2.4f, stepsize =%2.10f\n', iter, f, normG, stepsize); end end function f = loss(W, B, weight, lambda,c_t) T = size(W,2); f = 0; for t=1:T nont = 1:T; nont(t) = []; y = W(:,t); X = W(:,nont); beta = B(nont,t); f = f + lambda*norm(X*beta-y,2)^2 + norm(c_t(:,t).*weight(:,t).*beta,1); end f = f + sum(weight(:,1)) + weight(1,2);
github
GWLee0524/AMTL-master
learnB.m
.m
AMTL-master/learnB.m
2,347
utf_8
258ec55cf192db59b416fed1d8309702
function B = learnB(W, delta, param); maxiter = 1000; eval_interval = maxiter / 20; T = size(W,2); if (isfield(param,'B')) B = param.B; else B = ones(T)/T; end G = ones(T); normG = Inf; iter = 0; alpha = 0.0001; maxlsiter = 100; tau = 0.5; b = 0.01; linesearch = 1; for t=1:T B(t,t) = 0; nont{t} = 1:T; nont{t}(t) = []; weight(:,t) = delta(nont{t}); c_t(:,t) = param.c_t(nont{t}); y(:,t) = W(:,t); end EPS = 0; while (iter <= maxiter) iter = iter + 1; prevG = G; for t=1:T beta = B(nont{t},t); X = W(:,nont{t}); g(:,t) = param.lambda*X'*(X*beta-y(:,t)) +c_t(:,t).*weight(:,t).*beta.*weight(:,t); %g(:,t) = X'*(X*beta-y(:,t)) + param.lambda*weight(:,t).*(beta>0); G(nont{t},t) = g(:,t); end grad = G(:); beta = B(:); gradnew = zeros(size(beta)); [maxval, mu] = max(beta); gradnew(find(grad-grad(mu) > 0 | beta==0)) = 0; idxusual = setdiff(find(beta>0),mu); gradnew(idxusual) = grad(idxusual)-grad(mu); nonzero = find(grad > 0); [minval, idx] = min(beta(nonzero)./grad(nonzero)); % what if there is no nonzero entry? v = nonzero(idx); % if isempty(v) % grad' % v % mu % gradnew(mu) = grad(mu); % else gradnew(mu) = grad(mu)-grad(v); % error part % end grad = gradnew; G = reshape(grad,size(G)); % search for step size using line search stepsize = alpha; finit = loss(W, B, weight, param,c_t); fnew = loss(W, B-stepsize*G, weight, param,c_t); lsiter = 0; if (linesearch) while (fnew > finit && lsiter < maxlsiter) lsiter = lsiter + 1; stepsize = tau*stepsize; fnew = loss(W, B-stepsize*G, weight, param,c_t); end end beta = beta - stepsize*grad; beta(v) = 0; %sum(beta) beta = max(0,beta); beta = param.lambda2*beta./sum(beta); %beta = beta./sum(beta); B = reshape(beta,size(B)); %beta = max(0,beta); %beta = sign(beta).*(max(0,abs(beta) - param.lambda2)); normG = norm(G-prevG,'fro'); %beta = beta/sum(abs(beta)); if (mod(iter, eval_interval) == 1) f = fnew; fprintf('%d) %2.4f, ||G||=%2.4f\n', iter, f, normG); end end function f = loss(W, B, weight, param,c_t) T = size(W,2); f = 0; lambda = param.lambda; for t=1:T nont = 1:T; nont(t) = []; y = W(:,t); X = W(:,nont); beta = B(nont,t); f = f + lambda*norm(X*beta-y,2)^2 + norm(c_t(t).*weight(:,t).*beta,1); end f = f + sum(weight(:,1)) + weight(1,2);
github
umdrobotics/Rendezvous-master
calibrate_bundle.m
.m
Rendezvous-master/apriltags2_ros/scripts/calibrate_bundle.m
11,818
utf_8
791607e0f8b94445d20b83ee32cd2d9a
% Copyright (c) 2017, California Institute of Technology. % All rights reserved. % % Redistribution and use in source and binary forms, with or without % modification, are permitted provided that the following conditions are met: % % 1. Redistributions of source code must retain the above copyright notice, % this list of conditions and the following disclaimer. % 2. 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 HOLDER 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. % % The views and conclusions contained in the software and documentation are % those of the authors and should not be interpreted as representing official % policies, either expressed or implied, of the California Institute of % Technology. % %%% calibrate_bundle.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Script to determine AprilTag bundle relative poses to a "master" tag. % % Instructions: % Record a bagfile of the /tag_detections topic where you steadily % point the camera at the AprilTag bundle such that all the bundle's % individual tags are visible at least once at some point (the more the % better). Run the script, then copy the printed output into the tag.yaml % configuration file of apriltags2_ros. % % $Revision: 1.0 $ % $Date: 2017/12/17 13:37:34 $ % $Author: dmalyuta $ % % Originator: Danylo Malyuta, JPL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% User inputs % Relative directory of calibration bagfile calibration_file = 'data/calibration.bag'; % Bundle name bundle_name = 'my_bundle'; % Master tag's ID master_id = 0; %% Make sure matlab_rosbag is installed if ~exist('matlab_rosbag-0.5.0-linux64','file') websave('matlab_rosbag', ... ['https://github.com/bcharrow/matlab_rosbag/releases/' ... 'download/v0.5/matlab_rosbag-0.5.0-linux64.zip']); unzip('matlab_rosbag'); delete matlab_rosbag.zip end addpath('matlab_rosbag-0.5.0-linux64'); %% Load the tag detections bagfile bag = ros.Bag.load(calibration_file); tag_msg = bag.readAll('/tag_detections'); clear tag_data; N = numel(tag_msg); t0 = getBagTime(tag_msg{1}); for i = 1:N tag_data.t(i) = getBagTime(tag_msg{i})-t0; for j = 1:numel(tag_msg{i}.detections) detection = tag_msg{i}.detections(j); if numel(detection.id)>1 % Can only use standalone tag detections for calibration! % The math allows for bundles too (e.g. bundle composed of % bundles) but the code does not, and it's not that useful % anyway warning_str = 'Skipping tag bundle detection with IDs'; for k = 1:numel(detection.id) warning_str = sprintf('%s %d',warning_str,detection.id(k)); end warning(warning_str); continue; end tag_data.detection(i).id(j) = detection.id; tag_data.detection(i).size(j) = detection.size; % Tag position with respect to camera frame tag_data.detection(i).p(:,j) = detection.pose.pose.pose.position; % Tag orientation with respect to camera frame % [w;x;y;z] format tag_data.detection(i).q(:,j) = ... detection.pose.pose.pose.orientation([4,1,2,3]); end end %% Compute the measured poses of each tag relative to the master tag master_size = []; % Size of the master tag % IDs, sizes, relative positions and orientations of detected tags other % than master other_ids = []; other_sizes = []; rel_p = {}; rel_q = {}; createT = @(p,q) [quat2rotmat(q) p; zeros(1,3) 1]; invertT = @(T) [T(1:3,1:3)' -T(1:3,1:3)'*T(1:3,4); zeros(1,3) 1]; N = numel(tag_data.detection); for i = 1:N this = tag_data.detection(i); mi = find(this.id == master_id); if isempty(mi) % Master not detected in this detection, so this particular % detection is useless continue; end % Get the master tag's rigid body transform to the camera frame T_cm = createT(this.p(:,mi), this.q(:,mi)); % Get the rigid body transform of every other tag to the camera frame for j = 1:numel(this.id) % Skip the master, but get its size first if isempty(master_size) master_size = this.size(j); end % We already have the rigid body transform from the master tag to % the camera frame (T_cm) if j == mi continue; end % Add ID to detected IDs, if not already there id = this.id(j); if ~ismember(id, other_ids) other_ids(end+1) = id; other_sizes(end+1) = this.size(j); rel_p{end+1} = []; rel_q{end+1} = []; end % Find the index in other_ids corresponding to this tag k = find(other_ids == id); assert(numel(k) == 1, ... 'Tag ID must appear exactly once in the other_ids array'); % Get this tag's rigid body transform to the camera frame T_cj = createT(this.p(:,j), this.q(:,j)); % Deduce this tag's rigid body transform to the master tag's frame T_mj = invertT(T_cm)*T_cj; % Save the relative position and orientation of this tag to the % master tag rel_p{k}(:,end+1) = T_mj(1:3,4); rel_q{k}(:,end+1) = rotmat2quat(T_mj); end end assert(~isempty(master_size), ... sprintf('Master tag with ID %d not found in detections', master_id)); %% Compute (geometric) median position of each tag in master tag frame geometricMedianCost = @(x,y) sum(sqrt(sum((x-y).^2))); options = optimset('MaxIter',1000,'MaxFunEvals',1000, ... 'Algorithm','interior-point', ... 'TolFun', 1e-6, 'TolX', 1e-6); M = numel(rel_p); rel_p_median = nan(3, numel(other_ids)); for i = 1:M % Compute the mean position as the initial value for the minimization % problem p_0 = mean(rel_p{i},2); % Compute the geometric median [rel_p_median(:,i),~,exitflag] = ... fminsearch(@(x) geometricMedianCost(rel_p{i}, x), p_0, options); assert(exitflag == 1, ... sprintf(['Geometric median minimization did ' ... 'not converge (exitflag %d)'], exitflag)); end %% Compute the average orientation of each tag with respect to the master tag rel_q_mean = nan(4, numel(other_ids)); for i = 1:M % Use the method in Landis et al. "Averaging Quaternions", JGCD 2007 % Check the sufficient uniqueness condition % TODO this is a computational bottleness - without this check, script % returns much faster. Any way to speed up this double-for-loop? error_angle{i} = []; for j = 1:size(rel_q{i},2) q_1 = rel_q{i}(:,j); for k = 1:size(rel_q{i},2) if j==k continue; end q_2 = rel_q{i}(:,k); q_error = quatmult(quatinv(q_1),q_2); % Saturate to valid acos range, which prevents imaginary output % from acos due to q_error_w being infinitesimaly (to numerical % precision) outside of valid [-1,1] range q_error_w = min(1,max(q_error(1),-1)); error_angle{i}(end+1) = 2*acos(q_error_w); if 2*acos(q_error_w) >= pi/2 warning(['Quaternion pair q_%u and q_%u for tag ID %u ' ... 'are more than 90 degrees apart!'], ... j,k,other_ids(i)); end end end % Average quaternion method Q = rel_q{i}; [V, D] = eig(Q*Q.'); [~,imax] = max(diag(D)); % Get the largest eigenvalue rel_q_mean(:,i) = V(:,imax); % Corresponding eigenvector if rel_q_mean(1,i) < 0 rel_q_mean(:,i) = -rel_q_mean(:,i); % Ensure w positive end end %% Print output to paste in tags.yaml % Head + master tag fprintf([ ... 'tag_bundles:\n' ... ' [\n' ... ' {\n' ... ' name: ''%s'',\n' ... ' layout:\n' ... ' [\n'], bundle_name); % All other tags detected at least once together with master tag for i = 0:numel(other_ids) newline = ','; if i == numel(other_ids) newline = ''; end if i == 0 fprintf(' {id: %d, size: %.2f, x: %.4f, y: %.4f, z: %.4f, qw: %.4f, qx: %.4f, qy: %.4f, qz: %.4f}%s\n', ... master_id, master_size, 0, 0, 0, 1, 0, 0, 0, newline); else fprintf(' {id: %d, size: %.2f, x: %.4f, y: %.4f, z: %.4f, qw: %.4f, qx: %.4f, qy: %.4f, qz: %.4f}%s\n', ... other_ids(i), other_sizes(i), rel_p_median(1,i), ... rel_p_median(2,i), rel_p_median(3,i), rel_q_mean(1,i), ... rel_q_mean(2,i), rel_q_mean(3,i), rel_q_mean(4,i), newline); end end % Tail fprintf([ ... ' ]\n'... ' }\n'... ' ]\n']); %% Local functions function t = getBagTime(bagfile) t = double(bagfile.header.stamp.sec)+ ... double(bagfile.header.stamp.nsec)/1e9; end function R = quat2rotmat(q) % Creates an ACTIVE rotation matrix from a quaternion w = q(1); x = q(2); y = q(3); z = q(4); R = [1-2*(y^2+z^2) 2*(x*y-w*z) 2*(x*z+w*y) 2*(x*y+w*z) 1-2*(x^2+z^2) 2*(y*z-w*x) 2*(x*z-w*y) 2*(y*z+w*x) 1-2*(x^2+y^2)]; end function q = rotmat2quat(R) % Adapted for MATLAB from % http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ tr = R(1,1) + R(2,2) + R(3,3); if tr > 0 S = sqrt(tr+1.0) * 2; % S=4*qw qw = 0.25 * S; qx = (R(3,2) - R(2,3)) / S; qy = (R(1,3) - R(3,1)) / S; qz = (R(2,1) - R(1,2)) / S; elseif (R(1,1) > R(2,2)) && (R(1,1) > R(3,3)) S = sqrt(1.0 + R(1,1) - R(2,2) - R(3,3)) * 2; % S=4*qx qw = (R(3,2) - R(2,3)) / S; qx = 0.25 * S; qy = (R(1,2) + R(2,1)) / S; qz = (R(1,3) + R(3,1)) / S; elseif (R(2,2) > R(3,3)) S = sqrt(1.0 + R(2,2) - R(1,1) - R(3,3)) * 2; % S=4*qy qw = (R(1,3) - R(3,1)) / S; qx = (R(1,2) + R(2,1)) / S; qy = 0.25 * S; qz = (R(2,3) + R(3,2)) / S; else S = sqrt(1.0 + R(3,3) - R(1,1) - R(2,2)) * 2; % S=4*qz qw = (R(2,1) - R(1,2)) / S; qx = (R(1,3) + R(3,1)) / S; qy = (R(2,3) + R(3,2)) / S; qz = 0.25 * S; end q = [qw qx qy qz]'; end function c = quatmult(a,b) % More humanly understandable version: % Omegaa = [a((1)) -a((2):(4)).' % a((2):(4)) a((1))*eye((3))-[0 -a((4)) a((3)); a((4)) 0 -a((2));-a((3)) a((2)) 0]]; % c = Omegaa*b; % More optimized version: c_w = a(1)*b(1) - a(2)*b(2) - a(3)*b(3) - a(4)*b(4); c_x = a(1)*b(2) + a(2)*b(1) - a(3)*b(4) + a(4)*b(3); c_y = a(1)*b(3) + a(3)*b(1) + a(2)*b(4) - a(4)*b(2); c_z = a(1)*b(4) - a(2)*b(3) + a(3)*b(2) + a(4)*b(1); c = [c_w; c_x; c_y; c_z]; end function qinv = quatinv(q) qinv = [q(1); -q(2:4)]; end
github
aydindemircioglu/LIBLINEAR.gpu-master
make.m
.m
LIBLINEAR.gpu-master/matlab/make.m
1,417
utf_8
8eb6837e5929416359702df135e7403d
% This make.m is for MATLAB and OCTAVE under Windows, Mac, and Unix function make() try % This part is for OCTAVE if(exist('OCTAVE_VERSION', 'builtin')) mex libsvmread.c mex libsvmwrite.c setenv('CFLAGS', strcat(getenv('CFLAGS'), ' -fopenmp')) setenv('CXXFLAGS', strcat(getenv('CXXFLAGS'), ' -fopenmp')) mex -I.. -lgomp train.c linear_model_matlab.c ../linear.cpp ../tron.cpp ../blas/daxpy.c ../blas/ddot.c ../blas/dnrm2.c ../blas/dscal.c mex -I.. -lgomp predict.c linear_model_matlab.c ../linear.cpp ../tron.cpp ../blas/daxpy.c ../blas/ddot.c ../blas/dnrm2.c ../blas/dscal.c % This part is for MATLAB % Add -largeArrayDims on 64-bit machines of MATLAB else mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmread.c mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmwrite.c mex CFLAGS="\$CFLAGS -std=c99 -fopenmp" CXXFLAGS="\$CXXFLAGS -fopenmp" -I.. -largeArrayDims -lgomp train.c linear_model_matlab.c ../linear.cpp ../tron.cpp ../blas/daxpy.c ../blas/ddot.c ../blas/dnrm2.c ../blas/dscal.c mex CFLAGS="\$CFLAGS -std=c99" CXXFLAGS="\$CXXFLAGS -fopenmp" -I.. -largeArrayDims -lgomp predict.c linear_model_matlab.c ../linear.cpp ../tron.cpp ../blas/daxpy.c ../blas/ddot.c ../blas/dnrm2.c ../blas/dscal.c end catch err fprintf('Error: %s failed (line %d)\n', err.stack(1).file, err.stack(1).line); disp(err.message); fprintf('=> Please check README for detailed instructions.\n'); end
github
keileg/fvbiot-master
mpsaTest.m
.m
fvbiot-master/tests/mpsaTest.m
5,805
utf_8
3b8a062c99e96d2f30eb833962b4d608
function tests = mpsaTest % Unit tests for MPSA % %{ Copyright 2015-2016, University of Bergen. This file is part of FVBiot. FVBiot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. FVBiot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this file. If not, see <http://www.gnu.org/licenses/>. %} tests = functiontests(localfunctions); end function setupOnce(testCase) grids = {}; % 2D Cartesian, no perturbations Nx = [2 2]; Nd = numel(Nx); g = cartGrid(Nx); Nn = g.nodes.num; grids{1} = computeGeometry(g); % Perturbations g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{2} = computeGeometry(g); % 3D Cartesian, no perturbations Nx = [3 3 3]; Nd = numel(Nx); g = cartGrid(Nx); Nn = g.nodes.num; grids{3} = computeGeometry(g); % Perturbations g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{4} = computeGeometry(g); % Triangular grid Nx = [5 5]; Nd = numel(Nx); [X,Y] = meshgrid(linspace(0,Nx(1),Nx(1)+1), linspace(0,Nx(2),Nx(2)+1)); p = [X(:), Y(:)]; t = delaunayn(p); g = triangleGrid(p, t); Nn = g.nodes.num; grids{5} = computeGeometry(g); % Perturbed triangles g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{6} = computeGeometry(g); % Tetrahedral grid Nx = [2 2 2]; Nd = numel(Nx); [X,Y,Z] = meshgrid(linspace(0,Nx(1),Nx(1)+1), linspace(0,Nx(2),Nx(2)+1),linspace(0,Nx(3),Nx(3)+1)); p = [X(:), Y(:), Z(:)]; t = delaunayn(p); g = tetrahedralGrid(p, t); Nn = g.nodes.num; grids{7} = computeGeometry(g); % Perturbed triangles g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{8} = computeGeometry(g); testCase.TestData.grids = grids; end function translationTest(testCase) mu = 100; lambda = 100; phi = 0; grids = testCase.TestData.grids; for iter1 = 1 : numel(grids); % Not the most beautiful of setups, we could probably have used setup somehow G = grids{iter1}; Nc = G.cells.num; Nf = G.faces.num; Nd = G.griddim; xf = G.faces.centroids; xc = G.cells.centroids; % Pressure boundary conditions; bc = addBC([],find(any(G.faces.neighbors == 0,2)),'pressure',0); constit = shear_normal_stress(Nc, Nd, mu*ones(Nc,1), lambda*ones(Nc,1), phi*ones(Nc,1)); md = mpsa(G,constit,[],'bc',bc); % Translation r = rand(1,Nd); db = ones(Nf,1) * r; xan = ones(Nc,1) * r; boundVal = -md.div * md.boundStress * reshape(db',[],1); x = reshape((md.A \ boundVal)',Nd,[])'; assert(max(max(abs(x - xan)))<sqrt(eps),'MPSA failed on translation'); stress = md.stress * reshape(x',[],1) + md.boundStress * reshape(db',[],1); assert(norm(stress) < sqrt(eps),'MPSA gave stress for translation') end end function rotationTest(testCase) mu = 100; lambda = 100; phi = 0; grids = testCase.TestData.grids; for iter1 = 1 : numel(grids); % Not the most beautiful of setups, we could probably have used setup somehow G = grids{iter1}; Nc = G.cells.num; Nf = G.faces.num; Nd = G.griddim; xf = G.faces.centroids; xc = G.cells.centroids; % Pressure boundary conditions; bc = addBC([],find(any(G.faces.neighbors == 0,2)),'pressure',0); xn = G.nodes.coords; if Nd == 2 ang = 180*rand(1); rot = @(x) [x(:,1) * cosd(ang) - x(:,2) * sind(ang), x(:,1) * sind(ang) + x(:,2) * cosd(ang)]; else ang = 180 * rand(3,1); rotx = @(x) [x(:,1) , x(:,2) * cosd(ang(1)) - x(:,3) * sind(ang(1)), x(:,2) * sind(ang(1)) + x(:,3) * cosd(ang(1))]; roty = @(x) [x(:,1) * cosd(ang(2)) - x(:,3) * sind(ang(2)), x(:,2) , x(:,1) * sind(ang(2)) + x(:,3) * cosd(ang(2))]; rotz = @(x) [x(:,1) * cosd(ang(3)) - x(:,2) * sind(ang(3)), x(:,1) * sind(ang(3)) + x(:,3) * cosd(ang(3)), x(:,3)]; rot = @(x) rotz(roty(rotx(x))); end db = rot(xf) - xf; xan = rot(xc) - xc; constit = shear_normal_stress(Nc, Nd, mu*ones(Nc,1), lambda*ones(Nc,1), phi*ones(Nc,1)); md = mpsa(G,constit,[],'bc',bc,'eta',0); x = reshape(-(md.A) \ md.div * md.boundStress * reshape(db',[],1),Nd,[])'; assert(max(max(abs(x - xan)))<sqrt(eps),'MPSA failed on rotation'); end end function uniformStrainTest(testCase) mu = 100; lambda = 100; phi = 0; grids = testCase.TestData.grids; for iter1 = 1 : numel(grids); % Not the most beautiful of setups, we could probably have used setup somehow G = grids{iter1}; Nc = G.cells.num; Nf = G.faces.num; Nd = G.griddim; xf = G.faces.centroids; xc = G.cells.centroids; % Pressure boundary conditions; bc = addBC([],find(any(G.faces.neighbors == 0,2)),'pressure',0); xn = G.nodes.coords; % Uniform stress r = rand(Nd,1); db = bsxfun(@times,xf,r'); xan = bsxfun(@times,xc,r'); constit = shear_normal_stress(Nc, Nd, mu*ones(Nc,1), lambda*ones(Nc,1), phi*ones(Nc,1)); md = mpsa(G,constit,[], 'bc',bc); x = reshape(-full(md.A) \ md.div * md.boundStress * reshape(db',[],1),Nd,[])'; assert(max(max(abs(x - xan)))<sqrt(eps),'MPSA failed on uniform stress'); stress = md.stress * reshape(x',[],1) + md.boundStress * reshape(db',[],1); san = 2 * mu * r' + lambda * sum(r); san = (ones(Nf,1) * san).*G.faces.normals; s = reshape(stress',Nd,[])'; assert(max(max(abs(s - san))) < sqrt(eps),'MPSA failed on stress for uniform stretching') end end
github
keileg/fvbiot-master
mpfaTest.m
.m
fvbiot-master/tests/mpfaTest.m
4,091
utf_8
bc2e22591f3116236be0a635118d6421
function tests = mpfaTest % Unit tests for MPFA. % %{ Copyright 2015-2016, University of Bergen. This file is part of FVBiot. FVBiot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. FVBiot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this file. If not, see <http://www.gnu.org/licenses/>. %} tests = functiontests(localfunctions); end function setupOnce(testCase) grids = {}; % 2D Cartesian, no perturbations Nx = [4 3]; Nd = numel(Nx); g = cartGrid(Nx); Nn = g.nodes.num; grids{1} = computeGeometry(g); % Perturbations g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{2} = computeGeometry(g); % 3D Cartesian, no perturbations Nx = [3 3 3]; Nd = numel(Nx); g = cartGrid(Nx); Nn = g.nodes.num; grids{3} = computeGeometry(g); % Perturbations g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{4} = computeGeometry(g); % Triangular grid Nx = [5 5]; Nd = numel(Nx); [X,Y] = meshgrid(linspace(0,Nx(1),Nx(1)+1), linspace(0,Nx(2),Nx(2)+1)); p = [X(:), Y(:)]; t = delaunayn(p); g = triangleGrid(p, t); Nn = g.nodes.num; grids{5} = computeGeometry(g); % Perturbed triangles g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{6} = computeGeometry(g); % Tetrahedral grid Nx = [2 2 2]; Nd = numel(Nx); [X,Y,Z] = meshgrid(linspace(0,Nx(1),Nx(1)+1), linspace(0,Nx(2),Nx(2)+1),linspace(0,Nx(3),Nx(3)+1)); p = [X(:), Y(:), Z(:)]; t = delaunayn(p); g = tetrahedralGrid(p, t); Nn = g.nodes.num; grids{7} = computeGeometry(g); % Perturbed triangles g.nodes.coords = g.nodes.coords + 0.5 * rand(Nn,Nd); grids{8} = computeGeometry(g); testCase.TestData.grids = grids; end function dirichletBoundaryTest(testCase) grids = testCase.TestData.grids; for iter1 = 1 : numel(grids); % Not the most beautiful of setups, we could probably have used setup somehow G = grids{iter1}; Nc = G.cells.num; Nf = G.faces.num; Nd = G.griddim; xf = G.faces.centroids; xc = G.cells.centroids; % Pressure boundary conditions; bc = addBC([],find(any(G.faces.neighbors == 0,2)),'pressure',0); fd = mpfa(G,struct('perm',ones(Nc,1)),[],'bc',bc,'invertBlocks','matlab'); % First test no flow ub = ones(Nf,1); xan = ones(Nc,1); x = -fd.A \ (fd.div * fd.boundFlux * ub); assert(norm(x - xan) < sqrt(eps),'MPFA on no flow failed') % Then test uniform flow in x-direction ub = xf(:,1); xan = xc(:,1); x = -fd.A\fd.div * fd.boundFlux * ub; assert(norm(x - xan) < sqrt(eps),'MPFA on no flow in x-direction failed') % Flow in x+y direction r = rand(Nd,1); ub = xf * r; xan = xc * r; x = -fd.A\fd.div * fd.boundFlux * ub; assert(norm(x - xan) < sqrt(eps),'MPFA on no flow in x + y-direction failed') flux = fd.F * x + fd.boundFlux * ub; fan = sum(bsxfun(@times,G.faces.normals,-r'),2); assert(norm(flux - fan) < sqrt(eps),'MPFA flux error on random field') end end function mixedBoundaryTest(testCase) grids = testCase.TestData.grids; for iter1 = 7 : numel(grids); % Not the most beautiful of setups, we could probably have used setup somehow G = grids{iter1}; Nc = G.cells.num; Nf = G.faces.num; xf = G.faces.centroids; xc = G.cells.centroids; if any(strcmpi(G.type,'tensorGrid')) bc = fluxside([],G,'xmin',1); bc = pside(bc,G,'xmax',1); bc = pside(bc,G,'ymin',1); bc = pside(bc,G,'ymax',1); fd = mpfa(G,struct('perm',ones(Nc,1)),[],'bc',bc); fb = ones(Nf,1); x = -fd.A \ (fd.div * fd.boundFlux * fb); a=[]; end end end
github
neurolabusc/Clinical-master
clinical_h2c.m
.m
Clinical-master/clinical_h2c.m
2,016
utf_8
57731e8ebdc0c241c7f7b7065846fcd5
function clinical_h2c (fnms) % This script converts a CT scan from Hounsfield Units to Cormack % fnms: image name(s) [optional] % Example % clinical_h2c('C:\ct.nii'); fprintf('CT Hounsfield to Cormack version 4/4/2016\n'); if ~exist('fnms','var') fnms = spm_select(inf,'image','Select CT[s] to normalize'); end; for i=1:size(fnms,1) h2cSub( deblank(fnms(i,:)) ); end %end clinical_h2c - local functions follow function fnm = h2cSub (fnm) %converts a CT scan from Hounsfield Units to Cormack % fnm: image name [optional] %Example % h2c('C:\ct\script\ct.nii'); if ~exist('fnm','var') fnm = spm_select(1,'image','Select CT to convert'); end; hdr = spm_vol(deblank(fnm)); img = spm_read_vols(hdr); mx = max(img(:)); mn = min(img(:)); range = mx-mn; if (range < 1999) || (mn > -500) fprintf('Warning: image intensity range (%f) does not appear to be in Hounsfield units.\n',range); return; end %CR 5/5/2014: only scale if values are sensible! if (mn < -1024) %some GE scanners place artificial rim around air img(img < -1024) = -1024; mn = min(img(:)); range = mx-mn; end; fprintf('%s intensity range: %d\n',fnm,round(range)); fprintf(' Ignore QFORM0 warning if reported next\n'); %constants for conversion [kUninterestingDarkUnits, kInterestingMidUnits] = clinical_cormack(); kScaleRatio = 10;% increase dynamic range of interesting voxels by 3 %convert image img = img - mn; %transloate so min value is 0 extra1 = img - kUninterestingDarkUnits; extra1(extra1 <= 0) = 0; %clip dark to zero extra9=extra1; extra9(extra9 > kInterestingMidUnits) = kInterestingMidUnits; %clip bright extra9 = extra9 * (kScaleRatio-1); %boost mid range %transform image img = img+extra1+extra9; %dark+bright+boostedMidRange %save output [pth,nam,ext] = spm_fileparts(hdr.fname); hdr.fname = fullfile(pth, ['c' nam ext]); hdr.private.dat.scl_slope = 1; hdr.private.dat.scl_inter = 0; spm_write_vol(hdr,img); fnm = hdr.fname; %return new filename %end h2cSub()
github
neurolabusc/Clinical-master
tbx_cfg_clinical.m
.m
Clinical-master/tbx_cfg_clinical.m
15,296
utf_8
9ea71f1b53116e5b5440e8ea4be4f1c6
function clinical = tbx_cfg_clinical % Configuration file for toolbox 'Clinical' % Chris Rorden % $Id: tbx_cfg_clinical.m if ~isdeployed, addpath(fullfile(spm('Dir'),'toolbox','Clinical')); end % --------------------------------------------------------------------- % bb Bounding box % --------------------------------------------------------------------- bb = cfg_entry; bb.tag = 'bb'; bb.name = 'Bounding box'; bb.help = {'The bounding box (in mm) of the volume which is to be written (relative to the anterior commissure). Popular choices are [-78 -112 -50; 78 76 85] and [ -90 -126 -72; 90 90 108]'}; bb.strtype = 'e'; bb.val = {[-78 -112 -50; 78 76 85]}; %to match ch2 images bb.val = { [ -90 -126 -72; 90 90 108]}; bb.num = [2 3]; %bb.def = @(val)spm_get_defaults('normalise.write.bb', val{:}); % --------------------------------------------------------------------- % vox Voxel sizes % --------------------------------------------------------------------- vox = cfg_entry; vox.tag = 'vox'; vox.name = 'Voxel sizes'; vox.help = {'The voxel sizes (x, y & z, in mm) of the written normalised images. [1 1 1] and [2 2 2] are standard and more than sufficient for statistical analysis, but [0.735 0.735 0.735] provides nice volume rendering visualization.'}; vox.strtype = 'e'; vox.num = [1 3]; vox.val = {[1 1 1]}; %to match ch2 images vox.val = {[1 1 1]}; % [0.735 0.735 0.735] with the default bounding box yields a 213x256x184 voxel image that works well for rendering (some inexpensive GPUs limited to volumes with 256 voxels) %vox.def = @(val)spm_get_defaults('normalise.write.vox', val{:}); % --------------------------------------------------------------------- % Anat Volumes % --------------------------------------------------------------------- anat = cfg_files; anat.tag = 'anat'; anat.name = 'Anatomicals'; anat.help = {'Select anatomical scans (typically T1-weighted). These will be used to compute normalization parameters.'}; anat.filter = 'image'; anat.ufilter = '.*'; anat.num = [1 Inf]; % --------------------------------------------------------------------- % Lesion map Volumes % --------------------------------------------------------------------- les = cfg_files; les.tag = 'les'; les.name = 'Lesion maps'; les.help = {'Select lesions. Same order as anatomicals. If specified, lesions will be used to mask normalization, and will be resliced to standard space. Optional: e.g. not required for neurologically healthy controls'}; les.filter = 'image'; les.ufilter = '.*'; les.num = [1 Inf]; les.val = {''}; % --------------------------------------------------------------------- % T2 Volumes % --------------------------------------------------------------------- t2 = cfg_files; t2.tag = 't2'; t2.name = 'Pathological scans'; t2.help = {'Select pathological scans used to draw lesions (e.g. T2, FLAIR). Same order as anatomicals. Optional: only used if lesion maps are used, and only used if lesion maps are not drawn on anatomical images. Often the full extent of brain injury is better visualized on a T2 scan, but the T1 provides better resolution and tissue contrast. In this case, you can draw the lesion on the T2, coregister the T2 to T1, reslice lesion to T1 space and then normalize the T1.'}; t2.filter = 'image'; t2.ufilter = '.*'; t2.num = [0 Inf]; t2.val = {''}; % --------------------------------------------------------------------- % Template % --------------------------------------------------------------------- clinicalTemplate = cfg_menu; clinicalTemplate.tag = 'clinicaltemplate'; clinicalTemplate.name = 'Template'; clinicalTemplate.help = { 'Choose the template for your analyses. You can use the elderly template (which is based on older adults, and thus has large ventricles), or the young adult template (using the MNI152 template of young adults).' }'; clinicalTemplate.labels = { 'T1 younger' 'T1 older' }'; clinicalTemplate.values = { 0 1 }'; clinicalTemplate.val = {1}; % --------------------------------------------------------------------- % Cleanup % --------------------------------------------------------------------- clean = cfg_menu; clean.tag = 'clean'; clean.name = 'Cleanup level'; clean.help = { 'Choose tissue cleanup level: this attempts to remove islands of gray or white matter that are distant from gray matter.' }'; clean.labels = { 'none' 'light' 'thorough' }'; clean.values = { 0 1 2 }'; clean.val = {2}; % --------------------------------------------------------------------- %Enantiomorphic % --------------------------------------------------------------------- AutoSetOrigin = cfg_menu; AutoSetOrigin.tag = 'AutoSetOrigin'; AutoSetOrigin.name = 'Automatically Set Origin'; AutoSetOrigin.help = {'Normalization can fail if the origin is not near the anterior commissure. This option attempts to automatically adjust the origin. Try normalizing with this set to TRUE: if normalization fails next set the origin manually and re-run normalization with this feature switched to FALSE.'}; AutoSetOrigin.labels = { 'False' 'True' }'; AutoSetOrigin.values = { 0 1 }'; AutoSetOrigin.val = {1}; % --------------------------------------------------------------------- %Enantiomorphic % --------------------------------------------------------------------- Enantiomorphic = cfg_menu; Enantiomorphic.tag = 'Enantiomorphic'; Enantiomorphic.name = 'Enantiomorphic normalization'; Enantiomorphic.help = {'Enantiomorphic normalization can outperform lesion masking, especially for large lesions. Newer 6-tissue is probably better but disables ignores some options (tissue cleanup) and requires SPM12. See Nachev et al., 2008: http://www.ncbi.nlm.nih.gov/pubmed/18023365'}; Enantiomorphic.labels = { 'False' 'True(3-tissue old segment)' 'True(6-tissue new segment)' }'; Enantiomorphic.values = { 0 1 2 }'; Enantiomorphic.val = {2}; % --------------------------------------------------------------------- % Delete Intermediate % --------------------------------------------------------------------- DelIntermediate = cfg_menu; DelIntermediate.tag = 'DelIntermediate'; DelIntermediate.name = 'Intermediate images'; DelIntermediate.help = {'Many images are created during normalization that are often not required for final analyses. Do you wish to keep these intermediate images?'}; DelIntermediate.labels = { 'Keep' 'Delete' }'; DelIntermediate.values = { 0 1 }'; DelIntermediate.val = {0}; % --------------------------------------------------------------------- % T2 Input Images % --------------------------------------------------------------------- T2 = cfg_files; T2.tag = 'T2'; T2.name = 'Images'; T2.help = {'Select the scans you would like to normalize (each scan from a different participant).'}; T2.filter = 'image'; T2.ufilter = '.*'; T2.num = [1 Inf]; % --------------------------------------------------------------------- % modality % --------------------------------------------------------------------- modality = cfg_menu; modality.tag = 'modality'; modality.name = 'Modality'; modality.help = {'The template will be selected to match the tissue intensities of your images. Choose T1 if your scan is T1-weighted, T2 for T2-weighted, FLAIR for fluid-attenuated T2, else select Other [e.g. DWI]. This function always uses the default SPM templates that are based on young adults, except the FLAIR option that uses a symmetrical template from 181 people, Mean age: 39.9y, std dev: 9.3y, range: 26-76y, 102 females (see http://www.glahngroup.org/Members/anderson/flair-templates)' }'; modality.labels = { 'T1' 'T2' 'FLAIR' 'Other' }'; modality.values = { 1 2 3 4 }'; modality.val = {4}; % --------------------------------------------------------------------- % images Input Images % --------------------------------------------------------------------- images = cfg_files; images.tag = 'images'; images.name = 'Input Images'; images.help = {'Select the CT scans you would like to normalize.'}; images.filter = 'image'; images.ufilter = '.*'; images.num = [1 Inf]; % --------------------------------------------------------------------- % Lesions Input Images % --------------------------------------------------------------------- ctles = cfg_files; ctles.tag = 'ctles'; ctles.name = 'Input lesions'; ctles.help = {'Optional lesion maps. Must have same dimensions as CT scans. If multiple scans, order must be identical.'}; ctles.filter = 'image'; ctles.ufilter = '.*'; ctles.num = [1 Inf]; ctles.val = {''}; % --------------------------------------------------------------------- % brainmask - default switched on for CT scans, as skull has strong signal % --------------------------------------------------------------------- brainmaskct = cfg_menu; brainmaskct.tag = 'brainmaskct'; brainmaskct.name = 'Template mask'; brainmaskct.help = {'Apply a brain mask to the template? Initial coarse normalization is applied to the entire scan. However, it is often useful to apply a brain mask to the template for the subsequent fine normalization. This helps reduce the influence of skull and scalp features, improving the accuracy of the final normalization.' }'; brainmaskct.labels = { 'no template mask' 'apply template mask' }'; brainmaskct.values = { 0 1 }'; brainmaskct.val = {1}; % --------------------------------------------------------------------- % brainmask - default switched off for MRI, as low res scans often have poor coarse alignment % --------------------------------------------------------------------- brainmask = cfg_menu; brainmask.tag = 'brainmask'; brainmask.name = 'Template mask'; brainmask.help = {'Apply a brain mask to the template? Initial coarse normalization is applied to the entire scan. However, it is often useful to apply a brain mask to the template for the subsequent fine normalization. This helps reduce the influence of skull and scalp features, improving the accuracy of the final normalization.' }'; brainmask.labels = { 'no template mask' 'apply template mask' }'; brainmask.values = { 0 1 }'; brainmask.val = {0}; % --------------------------------------------------------------------- % Threshold for scalp strip % --------------------------------------------------------------------- ssthresh = cfg_entry; ssthresh.tag = 'ssthresh'; ssthresh.name = 'Scalp strip threshold'; ssthresh.help = { 'Enter threshold for scalp stripping. E.G. if set to 0.5 than only voxels deemed to have a combined gray+white matter probability of at least 50% will be included in the stripped image.' }'; ssthresh.strtype = 'e'; ssthresh.num = [1 1]; ssthresh.val = {0.005}; % --------------------------------------------------------------------- % MRsegnorm % --------------------------------------------------------------------- MRnormseg = cfg_exbranch; MRnormseg.tag = 'MRnormseg'; MRnormseg.name = 'MR segment-normalize'; MRnormseg.val = {anat les t2 clinicalTemplate clean bb vox ssthresh DelIntermediate, Enantiomorphic AutoSetOrigin}; MRnormseg.help = {'This procedure is designed for normalizing T1-weighted MRI scans from older people, including those with brain injury. This uses a unified segmentation-normalization algorithm. It can coregister a T2/FLAIR image to a T1 image and then normalize the T1 image. Vers 2/2/2012'}; MRnormseg.prog = @clinical_local_mrnormseg; %MRnormseg.vout = @vout_sextract; % --------------------------------------------------------------------- % CTnorm % --------------------------------------------------------------------- CTnorm = cfg_exbranch; CTnorm.tag = 'CTnorm'; CTnorm.name = 'CT normalize'; CTnorm.val = {images ctles brainmaskct bb vox DelIntermediate AutoSetOrigin}; CTnorm.help = {'This procedure is designed for normalizing CT scans from older people, including those with brain injury. Vers 2/2/2012'}; CTnorm.prog = @clinical_local_ctnorm; % --------------------------------------------------------------------- % MRnorm % --------------------------------------------------------------------- MRnorm = cfg_exbranch; MRnorm.tag = 'MRnorm'; MRnorm.name = 'MR normalize'; MRnorm.val = {anat les t2 modality brainmask bb vox DelIntermediate AutoSetOrigin}; MRnorm.help = {'This procedure is designed for normalizing MRI scans - it is useful when you only have low-resolution or low-quality scans. If you have a high-quality scans, use MR segment-normalize instead. Vers 2/2/2012'}; MRnorm.prog = @clinical_local_mrnorm; % --------------------------------------------------------------------- % clinical % --------------------------------------------------------------------- clinical = cfg_choice; clinical.tag = 'MRI'; clinical.name = 'Clinical'; clinical.help = {'Toolbox that aids in normalization of brain images of older individuals.'}; clinical.values = {MRnormseg CTnorm MRnorm}; %====================================================================== function clinical_local_mrnormseg(job) %if ~isdeployed, addpath(fullfile(spm('dir'),'toolbox','Clinical')); end set_pth('clinical_mrnormseg_job.m'); clinical_mrnormseg_job(job); %====================================================================== function clinical_local_ctnorm(job) %if ~isdeployed, addpath(fullfile(spm('dir'),'toolbox','Clinical')); end set_pth('clinical_ctnorm_job.m'); clinical_ctnorm_job(job); %====================================================================== function clinical_local_mrnorm(job) %if ~isdeployed, addpath(fullfile(spm('dir'),'toolbox','Clinical')); end set_pth('clinical_mrnorm_job.m'); clinical_mrnorm_job(job); function set_pth(mname) pth = fileparts(mfilename('fullpath')); [p,d] = fileparts(pth); if strcmpi(d,'Clinical-master') warning('Please rename folder "Clinical-master" to be "Clinical": %s\n', pth); end if exist(mname, 'file') return; end addpath(pth); %end set_pth()
github
neurolabusc/Clinical-master
clinical_h2c_old.m
.m
Clinical-master/clinical_h2c_old.m
2,761
utf_8
c5b4cfee74118c8f17ebeb3f05875425
function clinical_h2c (V); % This script converts a CT scan from Hounsfield Units to Cormack % V: image name(s) [optional] % Example % clinical_h2c('C:\ct.nii'); fprintf('CT normalization version 4/4/2016\n'); if nargin <1 %no files V = spm_select(inf,'image','Select CT[s] to normalize'); end; for i=1:size(V,1) ref = deblank(V(i,:)); [pth,nam,ext] = spm_fileparts(ref); ref= fullfile(pth,[nam ext]); if (exist(ref) ~= 2) fprintf('Error: unable to find source image %s.\n',ref); return; end; Vi = spm_vol(strvcat(V(i,:))); % determine range... clear img; %reassign for each image, in case dimensions differ mx = -Inf; mn = Inf; for p=1:Vi.dim(3), img = spm_slice_vol(Vi,spm_matrix([0 0 p]),Vi.dim(1:2),1); msk = find(isfinite(img)); mx = max([max(img(msk)) mx]); mn = min([min(img(msk)) mn]); end; range = mx-mn; %Hounsfield units, in theory % min = air = ~-1000 % max = bone = ~1000 % in practice, teeth fillings are often >3000 % Therefore, raise warning if range < 2000 % or Range > 6000 then generate warning: does not appear to be in Hounsfield units if (range < 1999) | (range > 8000) fprintf('Error: image intensity range (%f) does not appear to be in Hounsfield units.\n',range); %return end; fprintf('%s intensity range: %d\n',ref,round(range)); fprintf(' Ignore QFORM0 warning if reported next\n'); % next scale from Hounsfield to Cormack VO = Vi; [pth,nam,ext] = spm_fileparts(ref); VO.fname = fullfile(pth,['c' nam '.nii']); %spm_type(Vi.dt(1),'maxval') VO.pinfo(1) = 1; %2014 - change slope in pinfo as well as private VO.pinfo(2) = 0; %2014 - change intercept in pinfo as well as private VO.private.dat.scl_slope = 1; VO.private.dat.scl_inter = 0; if h2csub(mx,mn) > spm_type(Vi.dt(1),'maxval') fprintf('clinical_h2c: image data-type increased to 32-bit float %s\n',VO.fname); VO.dt(1) = 16; %2014 end; VO = spm_create_vol(VO); clipped = 0; for i=1:Vi.dim(3), img = spm_slice_vol(Vi,spm_matrix([0 0 i]),Vi.dim(1:2),0); for px=1:length(img(:)), img(px) = h2csub(img(px),mn); end; %for each pixel VO = spm_write_plane(VO,img,i); end; %for each slice end; %for each volume function out = h2csub(in,min); %====================== %Convert Hounsfiled to Cormack [kUninterestingDarkUnits, kInterestingMidUnits] = clinical_cormack(); kScaleRatio = 10;% increase dynamic range of interesting voxels by 3 v16 = in-min; lExtra = v16-kUninterestingDarkUnits; if lExtra > kInterestingMidUnits lExtra = kInterestingMidUnits; end; if lExtra > 0 lExtra = lExtra*kScaleRatio; else lExtra = 0; end; out = v16+lExtra;
github
neurolabusc/Clinical-master
clinical_c2h_old.m
.m
Clinical-master/clinical_c2h_old.m
2,019
utf_8
e19a920700331df68699e7bc74cf4d3d
function clinical_c2h (V); % This script converts a CT scan from Cormack to Hounsfield Units % V: image name(s) [optional] % Example % clinical_c2h('C:\ct\script\Pat1nolesion.nii'); fprintf('CT Cormack to Hounsfield version 2/2/2012\n'); if nargin <1 %no files V = spm_select(inf,'image','Select CT[s] to normalize'); end; for i=1:size(V,1) ref = deblank(V(i,:)); [pth,nam,ext] = spm_fileparts(ref); ref = fullfile(pth,[ nam ext]); if (exist(ref) ~= 2) fprintf('clinical_c2h error: unable to find source image %s.\n',ref); return; end; Vi = spm_vol(strvcat(V(i,:))); % next scale from Hounsfield to Cormack clear img; %reassign for each image, in case dimensions differ VO = Vi; [pth,nam,ext] = spm_fileparts(ref); VO.fname = fullfile(pth,['h' nam '.nii']); VO.private.dat.scl_slope = 1; VO.private.dat.scl_inter = -1024; VO.pinfo(1) = VO.private.dat.scl_slope; VO.pinfo(2) = VO.private.dat.scl_inter; VO = spm_create_vol(VO); for i=1:Vi.dim(3), img = spm_slice_vol(Vi,spm_matrix([0 0 i]),Vi.dim(1:2),0); for px=1:length(img(:)), img(px) = c2hsub(img(px)); end; %for each pixel VO = spm_write_plane(VO,img,i); end; %for each slice fprintf('Please check that the header sets the intercept to -1024\n'); end; %for each volume %end clinical_c2h() function x = c2hsub(x); %Convert Cormack to Hounsfield [kUninterestingDarkUnits, kInterestingMidUnits] = clinical_cormack(); kScaleRatio = 10;% increase dynamic range of interesting voxels by 3 kMax = kInterestingMidUnits * (kScaleRatio+1); if x > kUninterestingDarkUnits lExtra = x- kUninterestingDarkUnits; if (lExtra > kMax) lExtra = kInterestingMidUnits + (lExtra-kMax); else lExtra = round(lExtra/(kScaleRatio+1)); end; x = kUninterestingDarkUnits + lExtra; else x = x; % end; %if conditions x = x-1024; %air is darkest at ~-1000: most 12-bit CT systems encode as -1024
github
neurolabusc/Clinical-master
clinical_mrnormseg.m
.m
Clinical-master/clinical_mrnormseg.m
19,373
utf_8
fda504e687941af84a26b6637bff7e02
function clinical_mrnormseg (T1,lesion,T2, UseSCTemplates, vox, bb, DeleteIntermediateImages, ssthresh, cleanup, isEnantiomorphic, AutoSetOrigin) % This script normalizes MR scans using normalization-segmetnation %Inputs % T1 = Filename[s] for T1 scans % lesion = OPTIONAL Filename[s] for lesion maps [drawn on T2 if is T2 is specified, otherwise drawn on T1] % T2 = OPTIONAL Filename[s] for T2 weighted images % UseSCTemplates = OPTIONAL 0=normalize to young individuals, else normalize to template based on older adults % vox = OPTIONAL Voxel size in mm, multiple rows for multiple resolutions (e.g. [3 3 3; 1 1 1]) % bb = OPTIONAL Bounding box % DeleteIntermediateImages= OPTIONAL Should files used inbetween stages be saved? % ssthresh = OPTIONAL Thresold for brain extraction, e.g. 0.1 will have tissue that has combine GM+WM probability >10% % cleanup = Tissue cleanup level % isEnantiomorphic = if true then Enantiomorphic rather than lesion-masked normalization % Example: Normalize T1 scan from elderly person % clinical_mrnormseg('c:\dir\t1.nii'); % Example: Normalize T1 scan from elderly person to 1mm isotropic % clinical_mrnormseg('c:\dir\t1.nii','','',1,[1 1 1]); % Example: Normalize T1 scan and lesion from person with stroke, with lesion drawn on T1 % clinical_mrnormseg('c:\dir\t1.nii','c:\dir\t1lesion.nii' ); % Example: Normalize T1 scan and lesion from person with stroke, with lesion drawn on T2 % clinical_mrnormseg('c:\dir\t1.nii','c:\dir\t2lesion.nii','c:\dir\t2.nii' ); % Note: could be T2, FLAIR, etc. but second image (lesion) is aligned to third image ("T2") % clinical_mrnormseg('C:\t1','C:\lesion.nii','C:\flair.nii'); % UseSCTemplates = If 1, uses 'stroke control' template (good for elderly), if 0 then uses SPM's default tissue templates % Set to 0.0 if you do not want a brain extracted T1 fprintf('MR normalization-segmentation version 7/7/2016 - for use with high-resolution images that allow accurate segmentation\n'); lesionname = ''; if nargin <1 %no files T1 = spm_select(inf,'image','Select T1 images'); end; if nargin < 1 %no files lesion = spm_select(inf,'image','Optional: select lesion maps (same order as T1)'); else if nargin <2 %T1 specified, no lesion map specified lesion = ''; end; end; if (nargin < 1 & length(lesion) > 1) %no files passed, but user has specified both T1 and lesion images... T2 = spm_select(inf,'image','Select T2 images (only if lesions are not drawn on T1, same order as T1)'); else %T1 specified, no T2 specified if nargin <3 %no files T2 = ''; end; end; if nargin < 4 %no template specified UseSCTemplates= 1; %assume old individual end; if nargin < 5 %no voxel size vox = [2 2 2]; end; if nargin < 6 %no bounding box bb = [-78 -112 -50; 78 76 85]; end; % std tight (removes some cerebellum) -> [-78 -112 -50; 78 76 85] ch2 -> [ -90 -126 -72; 90 90 108] if nargin < 7 %delete images DeleteIntermediateImages = 1; end; if nargin < 8 %brain extraction threshold ssthresh = 0.005; %0.1; end; if nargin < 9 %cleanup not specified cleanup = 2; %2= thorough cleanup; 1=light cleanup, 0= nocleanup end; if ~exist('isEnantiomorphic','var') isEnantiomorphic = true; end if isempty(lesion) isEnantiomorphic = false; end if exist('AutoSetOrigin', 'var') && (AutoSetOrigin) for i=1:size(T1,1) v = deblank(T1(i,:)); if ~isempty(lesion) v = strvcat(v, deblank(lesion(i,:)) ); end if ~isempty(T2) v = strvcat(v, deblank(T2(i,:)) ); end clinical_setorigin(v,1); %coregister to T1 end; end; smoothlesion = true; tic if (length(lesion) < 1) && (~isempty(T2)) fprintf('You can not process T2 images without T1 scans\n'); return; end; for i=1:size(T1,1), %repeat for each image the user selected [pth,nam,ext] = spm_fileparts(deblank(T1(i,:))); T1name = fullfile(pth,[ nam ext]); %the T1 image has no prefix if (clinical_filedir_exists(T1name ) == 0) %report if files do not exist disp(sprintf(' No T1 image found named: %s', T1name )) return end; if length(lesion) > 0 [pthL,namL,extL] = spm_fileparts(deblank(lesion(i,:))); lesionname = fullfile(pthL,[namL extL]); if (clinical_filedir_exists(lesionname ) == 0) %report if files do not exist disp(sprintf(' No lesion image found named: %s', lesionname )) return end; end; if length(T2) > 0 %if 3rd image (T2) exists - use it to coreg 2nd (lesion) to 1st (T1) [pth2,nam2,ext2] = spm_fileparts(deblank(T2(i,:))); T2name = fullfile(pth2,[nam2 ext2]); %the T2 pathological image has the prefix 'p' if (clinical_filedir_exists(T2name ) == 0) %report if files do not exist disp(sprintf(' No T2/FLAIR/DWI image found named: %s', T2name )) return end; if ~lesionMatchT2Sub (T2name,lesionname) return; end %next coreg coregbatch{1}.spm.spatial.coreg.estwrite.ref = {[T1name ,',1']}; coregbatch{1}.spm.spatial.coreg.estwrite.source = {[T2name ,',1']}; coregbatch{1}.spm.spatial.coreg.estwrite.other = {[lesionname ,',1']}; coregbatch{1}.spm.spatial.coreg.estwrite.eoptions.cost_fun = 'nmi'; coregbatch{1}.spm.spatial.coreg.estwrite.eoptions.sep = [4 2]; coregbatch{1}.spm.spatial.coreg.estwrite.eoptions.tol = [0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001 0.001]; coregbatch{1}.spm.spatial.coreg.estwrite.eoptions.fwhm = [7 7]; coregbatch{1}.spm.spatial.coreg.estwrite.roptions.interp = 1; coregbatch{1}.spm.spatial.coreg.estwrite.roptions.wrap = [0 0 0]; coregbatch{1}.spm.spatial.coreg.estwrite.roptions.mask = 0; coregbatch{1}.spm.spatial.coreg.estwrite.roptions.prefix = 'r'; spm_jobman('run',coregbatch); namL = ['r' namL]; %resliced data now has prefix 'r' lesionname = fullfile(pthL,[namL extL]); %the lesion image has the prefix 'l' if (DeleteIntermediateImages == 1) clinical_delete(fullfile(pth2,['r' nam2 ext2])); end; elseif length(lesionname) > 0 %if no T2, but lesion, make sure lesion matches T1 if ~lesionMatchT2Sub (T1name,lesionname) return; end end;%if lesion present %next - generate mask if length(lesion) > 0 if isEnantiomorphic maskname = fullfile(pthL,[ namL extL]); else clinical_smoothmask(lesionname); maskname = fullfile(pthL,['x' namL extL]); end; if smoothlesion == true slesionname = clinical_smooth(lesionname, 3); %lesions often drawn in plane, with edges between planes - apply 3mm smoothing else slesionname = lesionname; end; %if smooth lesion end; %if lesion available %next normalize... if UseSCTemplates == 1 % disp(sprintf('Using stroke control tissue probability maps')); gtemplate = fullfile(fileparts(which(mfilename)),'scgrey.nii'); wtemplate= fullfile(fileparts(which(mfilename)),'scwhite.nii'); ctemplate = fullfile(fileparts(which(mfilename)),'sccsf.nii'); else disp(sprintf('Using default SPM tissue probability maps')); gtemplate = fullfile(spm('Dir'),'tpm','grey.nii'); wtemplate = fullfile(spm('Dir'),'tpm','white.nii'); ctemplate = fullfile(spm('Dir'),'tpm','csf.nii'); if ~exist(gtemplate,'file') gtemplate = fullfile(spm('Dir'),'toolbox','OldSeg','grey.nii'); end; if ~exist(wtemplate,'file') wtemplate = fullfile(spm('Dir'),'toolbox','OldSeg','white.nii'); end; if ~exist(ctemplate,'file') ctemplate = fullfile(spm('Dir'),'toolbox','OldSeg','csf.nii'); end; end; %report if templates are not found if (clinical_filedir_exists(gtemplate) == 0) || (clinical_filedir_exists(wtemplate) == 0) || (clinical_filedir_exists(ctemplate) == 0) %report if files do not exist disp(sprintf('Unable to find templates')); return end; if isEnantiomorphic eT1name = entiamorphicSub(T1name, maskname); normbatch{1}.spm.spatial.preproc.data = {[eT1name ,',1']}; %6/2014 added [] else normbatch{1}.spm.spatial.preproc.data = {[T1name ,',1']}; %6/2014 added [] end if ssthresh > 0 normbatch{1}.spm.spatial.preproc.output.GM = [0 0 1]; normbatch{1}.spm.spatial.preproc.output.WM = [0 0 1]; normbatch{1}.spm.spatial.preproc.output.CSF = [0 0 1]; %CR 2013 else normbatch{1}.spm.spatial.preproc.output.GM = [0 0 0]; normbatch{1}.spm.spatial.preproc.output.WM = [0 0 0]; normbatch{1}.spm.spatial.preproc.output.CSF = [0 0 0]; end; normbatch{1}.spm.spatial.preproc.output.biascor = 1; normbatch{1}.spm.spatial.preproc.output.cleanup = cleanup; normbatch{1}.spm.spatial.preproc.opts.tpm = { gtemplate wtemplate ctemplate }; normbatch{1}.spm.spatial.preproc.opts.ngaus = [2; 2; 2; 4]; normbatch{1}.spm.spatial.preproc.opts.regtype = 'mni'; normbatch{1}.spm.spatial.preproc.opts.warpreg = 1; normbatch{1}.spm.spatial.preproc.opts.warpco = 25; normbatch{1}.spm.spatial.preproc.opts.biasreg = 0.0001; normbatch{1}.spm.spatial.preproc.opts.biasfwhm = 60; normbatch{1}.spm.spatial.preproc.opts.samp = 3; if ~isempty(lesion) && ~isEnantiomorphic normbatch{1}.spm.spatial.preproc.opts.msk = {[maskname ,',1']}; else normbatch{1}.spm.spatial.preproc.opts.msk = {''}; end; fprintf('Unified segmentation of %s with cleanup level %d threshold %f, job %d/%d\n', T1name, cleanup, ssthresh, i, size(T1,1)); fprintf(' If segmentation fails: use SPM''s DISPLAY tool to set the origin as the anterior commissure\n'); spm_jobman('run',normbatch); %next reslice... if isEnantiomorphic reslicebatch{1}.spm.spatial.normalise.write.subj.matname = {fullfile(pth,['e' nam '_seg_sn.mat'])}; biasPrefix = ''; tissuePrefix = 'e'; else reslicebatch{1}.spm.spatial.normalise.write.subj.matname = {fullfile(pth,[ nam '_seg_sn.mat'])}; biasPrefix = 'm'; tissuePrefix = ''; end reslicebatch{1}.spm.spatial.normalise.write.roptions.preserve = 0; reslicebatch{1}.spm.spatial.normalise.write.roptions.bb = bb; reslicebatch{1}.spm.spatial.normalise.write.roptions.interp = 1; reslicebatch{1}.spm.spatial.normalise.write.roptions.wrap = [0 0 0]; for res = 1:size(vox,1) if res > 1 pref = ['w' num2str(res-1)]; else pref = 'w'; end %next lines modified 7/7/2016 for SPM12 compatibility if length(T2) > 0 reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {[fullfile(pth,[biasPrefix nam ext]) ,',1']; [slesionname ,',1']; [fullfile(pth2,[ nam2 ext2]),',1']}; %reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {fullfile(pth,[biasPrefix nam ext]) ,',1; ',slesionname ,',1; ', fullfile(pth2,[ nam2 ext2]),',1'}; elseif length(lesion) > 0 reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {[fullfile(pth,[biasPrefix nam ext]) ,',1']; [slesionname ,',1']} %reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {fullfile(pth,[biasPrefix nam ext]) ,',1; ',slesionname ,',1;'}; else reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {[fullfile(pth,[biasPrefix nam ext]) ,',1']}; %m is bias corrected end; reslicebatch{1}.spm.spatial.normalise.write.roptions.prefix = pref; reslicebatch{1}.spm.spatial.normalise.write.roptions.vox = vox(res,:) ; spm_jobman('run',reslicebatch); %next: reslice tissue maps if ssthresh > 0 c1 = fullfile(pth,['c1' tissuePrefix nam ext]); c2 = fullfile(pth,['c2' tissuePrefix nam ext]); c3 = fullfile(pth,['c3' tissuePrefix nam ext]); reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {[c1 ,',1']; [c2,',1']; [c3,',1']}; %reslicebatch{1}.spm.spatial.normalise.write.subj.resample = {c1 ,',1; ',c2,',1;' ,c3,',1'}; spm_jobman('run',reslicebatch); if (res == length(vox)) && (DeleteIntermediateImages == 1) clinical_delete(c1); clinical_delete(c2); clinical_delete(c3); end; if length(lesion) > 0 %we have a lesion [pthLs,namLs,extLs] = spm_fileparts(slesionname); clinical_binarize(fullfile(pthLs,[pref namLs extLs])); %lesion maps are considered binary (a voxel is either injured or not) les = fullfile(pthLs,['b' pref namLs extLs]); else les = ''; end; c1 = fullfile(pth,[pref 'c1' tissuePrefix nam ext]); c2 = fullfile(pth,[pref 'c2' tissuePrefix nam ext]); extractsub(ssthresh, fullfile(pth,[pref biasPrefix nam ext]), c1, c2, '', les); if (DeleteIntermediateImages == 1) clinical_delete(c1); clinical_delete(c2); %clinical_delete(c3); end; end; %thresh > 0 end; %for each resolution %we now have our normalized images with the 'w' prefix. %The optional next lines delete the intermediate images if (DeleteIntermediateImages == 1) if isEnantiomorphic clinical_delete(fullfile(pth,['e' nam ext])); end clinical_delete(fullfile(pth,['m' nam ext])); end; %mT1 is the bias corrected T1 if length(lesion) > 0 %we have a lesion if (DeleteIntermediateImages == 1) clinical_delete(maskname ); end; %lesion mask [pthLs,namLs,extLs] = spm_fileparts(slesionname); %clinical_binarize(fullfile(pthLs,['w' namLs extLs])); %lesion maps are considered binary (a voxel is either injured or not) if (DeleteIntermediateImages == 1) clinical_delete(fullfile(pthLs,['w' namLs extLs])); end; %we can delete the continuous lesion map clinical_nii2voi(fullfile(pthLs,['bw' namLs extLs])); end; if length(T2) > 0 %We have a T2, and resliced T2->T1->MNI, delete intermediate image in T1 space if (DeleteIntermediateImages == 1) clinical_delete(lesionname ); end; %intermediate lesion in T1 space if smoothlesion if (DeleteIntermediateImages == 1) clinical_delete(slesionname); end; end; end; end; %for each image in T1name toc function extractsub(thresh, t1, c1, c2, c3, PreserveMask) %subroutine to extract brain from surrounding scalp % t1: anatomical scan to be extracted % c1: gray matter map % c2: white matter map % c3: [optional] spinal fluid map % PreserveMask: [optional] any voxels with values >0 in this image will be spared [pth,nam,ext] = spm_fileparts(t1); %load headers mi = spm_vol([t1 ,',1']);%bias corrected T1 gi = spm_vol(c1);%Gray Matter map wi = spm_vol(c2);%White Matter map %load images m = spm_read_vols(mi); g = spm_read_vols(gi); w = spm_read_vols(wi); if length(c3) > 0 ci = spm_vol(c3);%CSF map c = spm_read_vols(ci); w = c+w; end; w = g+w; if (length(PreserveMask) >0) mski = spm_vol(PreserveMask);%bias corrected T1 msk = spm_read_vols(mski); w(msk > 0) = 1; end; if thresh <= 0 m=m.*w; else mask= zeros(size(m)); for px=1:length(w(:)), if w(px) >= thresh mask(px) = 255; end; end; spm_smooth(mask,mask,1); %feather the edges mask = mask / 255; m=m.*mask; end; mi.fname = fullfile(pth,['render', nam, ext]); mi.dt(1) = 4; %16-bit precision more than sufficient uint8=2; int16=4; int32=8; float32=16; float64=64 spm_write_vol(mi,m); %end for extractsub function dimsMatch = lesionMatchT2Sub (T2,lesion) dimsMatch = true; if (length(T2) < 1) || (length(lesion) < 1), return; end lhdr = spm_vol(lesion); %lesion header t2hdr = spm_vol(T2); %pathological scan header if ~isequal(lhdr.dim,t2hdr.dim); dimsMatch = false; fprintf('%s ERROR: Dimension mismatch %s %s: %dx%dx%d %dx%dx%d\n',mfilename, T2,lesion, t2hdr.dim(1),t2hdr.dim(2),t2hdr.dim(3), lhdr.dim(1),lhdr.dim(2),lhdr.dim(3)); end %end dimsMatch() function intactImg = entiamorphicSub (anatImg, lesionImg) %Generates image suitable for Enantiomorphic normalization, see www.pubmed.com/18023365 % anatImg : filename of anatomical scan % lesionImg : filename of lesion map in register with anatomical %returns name of new image with two 'intact' hemispheres if ~exist('anatImg','var') %no files specified anatImg = spm_select(1,'image','Select anatomical image'); end if ~exist('lesionImg','var') %no files specified lesionImg = spm_select(1,'image','Select anatomical image'); end if (exist(anatImg,'file') == 0) || (exist(lesionImg,'file') == 0) error('%s unable to find files %s or %s',mfilename, anatImg, lesionImg); end %create flipped image hdr = spm_vol([anatImg ,',1']); img = spm_read_vols(hdr); [pth, nam, ext] = spm_fileparts(anatImg); fname_flip = fullfile(pth, ['LR', nam, ext]); hdr_flip = hdr; hdr_flip.fname = fname_flip; hdr_flip.mat = [-1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1] * hdr_flip.mat; spm_write_vol(hdr_flip,img); %coregister data hdr_flip = spm_vol(fname_flip); x = spm_coreg(hdr_flip,hdr); %apply half of transform to find midline x = (x/2); M = spm_matrix(x); MM = spm_get_space(fname_flip); spm_get_space(fname_flip, M*MM); %reorient flip M = inv(spm_matrix(x)); MM = spm_get_space(hdr.fname); spm_get_space(hdr.fname, M*MM); %#ok<MINV> %reorient original so midline is X=0 %reorient the lesion as well MM = spm_get_space(lesionImg); spm_get_space(lesionImg, M*MM); %#ok<MINV> %reorient lesion so midline is X=0 %reslice to create a mirror image aligned in native space P = char([hdr.fname,',1'],[hdr_flip.fname,',1']); flags.mask = 0; flags.mean = 0; flags.interp = 1; flags.which = 1; flags.wrap = [0 0 0]; flags.prefix = 'r'; spm_reslice(P,flags); delete(fname_flip); %remove flipped file fname_flip = fullfile(pth,['rLR' nam ext]);%resliced flip file %load lesion, blur hdrLesion = spm_vol(lesionImg); imgLesion = spm_read_vols(hdrLesion); rdata = +(imgLesion > 0); %binarize raw lesion data, + converts logical to double spm_smooth(rdata,imgLesion,4); %blur data rdata = +(imgLesion > 0.1); %dilate: more than 20% spm_smooth(rdata,imgLesion,8); %blur data %now use lesion map to blend flipped and original image hdr = spm_vol([anatImg ,',1']); img = spm_read_vols(hdr); hdr_flip = spm_vol(fname_flip); imgFlip = spm_read_vols(hdr_flip); rdata = (img(:) .* (1.0-imgLesion(:)))+ (imgFlip(:) .* imgLesion(:)); rdata = reshape(rdata, size(img)); delete(fname_flip); %remove resliced flipped file hdr_flip.fname = fullfile(pth,['e' nam ext]);%image with lesion filled with intact hemisphere spm_write_vol(hdr_flip,rdata); intactImg = hdr_flip.fname; %end entiamorphicSub()
github
neurolabusc/Clinical-master
clinical_ctnorm.m
.m
Clinical-master/clinical_ctnorm.m
9,015
utf_8
3cb7f1aae5ec3278cf558bf8b21f905b
function clinical_ctnorm(V, lesion, vox, bb, DeleteIntermediateImages, UseTemplateMask, UseStrippedTemplate, AutoSetOrigin) % This script attempts to normalize a CT scan % V = filename[s] of CT scan[s] to normalize % lesion = filename[s] of lesion maps. Optional: binary images drawn in same dimensions as CT. For multiple CTs, order of V and lesion must be the same % vox = voxel size of normalized image[s] % bb = bounding box of normalized image[s] % DeleteIntermediateImages = if 1, then temporary images used between steps are deleted % UseStrippedTemplate = Normalize to scalp-stripped template (only if your data is already scalp stripped) % Prior to running this script, use SPM's DISPLAY % Use this to set "0 0 0"mm to point to the Anterior Commissure % Version notes % 07072016 : improved support for SPM12 (finding brainmask.nii) % Example % clinical_ctnorm ('C:\dir\img.nii'); % clinical_ctnorm('ct.nii', '', [1 1 1], [-78 -112 -50; 78 76 85], true, true); fprintf('CT normalization version 7/7/2016\n'); if exist('UseStrippedTemplate','var') && (UseStrippedTemplate == true) cttemplate = fullfile(fileparts(which(mfilename)),'scct_stripped.nii'); else cttemplate = fullfile(fileparts(which(mfilename)),'scct.nii'); end %use custom 'stroke control' CT templates %cttemplate = fullfile(spm('Dir'),'templates','Transm.nii');%SPM8 default template %report if templates are not found if (clinical_filedir_exists(cttemplate) == 0) %report if files do not exist fprintf('Please put the CT template in the SPM template folder\n'); return end; if nargin <1 %no files V = spm_select(inf,'image','Select CT[s] to normalize'); end; if nargin < 1 %no files lesion = spm_select(inf,'image','Optional: select lesion maps (same order as CTs)'); else if nargin <2 %T1 specified, no lesion map specified lesion = ''; end; end; if nargin < 3 %no voxel size vox = [2 2 2]; end; if nargin < 4 %no bounding box bb = [-78 -112 -50; 78 76 85];%[ -90 -126 -72; 90 90 108]; end; if nargin < 5 %delete images DeleteIntermediateImages = 1; end; if nargin < 6 %UseTemplateMask UseTemplateMask= 0; end; if UseTemplateMask== 1 TemplateMask = fullfile(spm('Dir'),'apriori','brainmask.nii'); if ~exist(TemplateMask, 'file') TemplateMask = fullfile(spm('Dir'),'toolbox','FieldMap','brainmask.nii'); end if ~exist(TemplateMask, 'file') error('Unable to find %s', TemplateMask); end if (clinical_filedir_exists(TemplateMask ) == 0) %report if files do not exist fprintf('%s error: Mask not found %s\n',mfilename, TemplateMask ); return end; end; if (size(lesion) > 1) if (size(lesion) ~= size(V)) fprintf('You must specify the same number of lesions as CT scans\n'); return; end; end; for i=1:size(V,1) %fix GE images prior to attempting to set origins clinical_fix_ge_ct (deblank(V(i,:))); end if exist('AutoSetOrigin', 'var') && (AutoSetOrigin) for i=1:size(V,1) r = deblank(V(i,:)); if ~isempty(lesion) r = strvcat(r, deblank(lesion(i,:)) ); end clinical_setorigin(r,3); %coregister to CT end; end; smoothlesion = true; %spm_jobman('initcfg'); %<- resets batch editor for i=1:size(V,1) r = deblank(V(i,:)); [pth,nam,ext, ~] = spm_fileparts(r); ref = fullfile(pth,[nam ext]); if (exist(ref,'file' ) ~= 2) fprintf('Error: unable to find source image %s.\n',ref); return; end; cref = h2cSub (ref); %next - prepare lesion mask if ~isempty(lesion) [pthL,namL,extL] = spm_fileparts(deblank(lesion(1,:))); lesionname = fullfile(pthL,[namL extL]); if (clinical_filedir_exists(lesionname ) == 0) %report if files do not exist fprintf(' No lesion image found named: %s\n', lesionname ); return end; clinical_smoothmask(lesionname); maskname = fullfile(pthL,['x' namL extL]); if smoothlesion == true slesionname = clinical_smooth(lesionname, 3); %lesions often drawn in plane, with edges between planes - apply 3mm smoothing else slesionname = lesionname; end; %if smooth lesion matlabbatch{1}.spm.spatial.normalise.estwrite.subj.wtsrc = {[maskname ,',1']}; %to turn off lesion masking replacing previous line with next line: %matlabbatch{1}.spm.spatial.normalise.estwrite.subj.wtsrc = ''; matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample = {[slesionname ,',1'];[ref,',1']}; fprintf('masking %s with %s using template %s.\n',ref, slesionname, cttemplate); else % if no lesion matlabbatch{1}.spm.spatial.normalise.estwrite.subj.wtsrc = ''; matlabbatch{1}.spm.spatial.normalise.estwrite.subj.resample = {[ref,',1']}; fprintf('normalizing %s without a mask using template %s.\n',ref, cttemplate); end; %next normalize matlabbatch{1}.spm.spatial.normalise.estwrite.subj.source = {[cref,',1']}; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.template = {[cttemplate ,',1']}; %matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.weight = ''; if UseTemplateMask == 1 matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.weight = {[TemplateMask ,',1']}; else matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.weight = ''; end; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.smosrc = 8; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.smoref = 0; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.regtype = 'mni'; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.cutoff = 25; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.nits = 16; matlabbatch{1}.spm.spatial.normalise.estwrite.eoptions.reg = 1; matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.preserve = 0; matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.bb = bb; matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.vox = vox; %2x2x2mm isotropic %matlabbatch{1}.spm.spatial.normalise.write.roptions.bb = [ -90 -126 -72; 90 90 108]; %matlabbatch{1}.spm.spatial.normalise.write.roptions.vox = [2 2 2]; %2x2x2mm isotropic %matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.vox = [1 1 1]; matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.interp = 1; matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.wrap = [0 0 0]; matlabbatch{1}.spm.spatial.normalise.estwrite.roptions.prefix = 'w'; spm_jobman('run',matlabbatch); if (DeleteIntermediateImages == 1) clinical_delete(cref); %delete cormack image if ~isempty(lesion) clinical_delete(maskname); if smoothlesion == true clinical_delete(slesionname); end; %if smoothed lesions end; %if lesions end;% if delete %make lesion binary, create voi if ~isempty(lesion) %we have a lesion clinical_binarize(fullfile(pthL,['ws' namL extL])); %lesion maps are considered binary (a voxel is either injured or not) if (DeleteIntermediateImages == 1) clinical_delete(fullfile(pthL,['ws' namL extL])); end; %we can delete the continuous lesion map clinical_nii2voi(fullfile(pthL,['bws' namL extL])); end; end; %for each volume %clinical_ctnorm function fnm = h2cSub (fnm) %converts a CT scan from Hounsfield Units to Cormack % fnm: image name [optional] %Example % h2c('C:\ct\script\ct.nii'); if ~exist('fnm','var') fnm = spm_select(1,'image','Select CT to convert'); end; hdr = spm_vol(deblank(fnm)); img = spm_read_vols(hdr); mx = max(img(:)); mn = min(img(:)); range = mx-mn; if (range < 1999) || (mn > -500) fprintf('Warning: image intensity range (%f) does not appear to be in Hounsfield units.\n',range); return; end %CR 5/5/2014: only scale if values are sensible! if (mn < -1024) %some GE scanners place artificial rim around air img(img < -1024) = -1024; mn = min(img(:)); range = mx-mn; end; fprintf('%s intensity range: %d\n',fnm,round(range)); fprintf(' Ignore QFORM0 warning if reported next\n'); %constants for conversion [kUninterestingDarkUnits, kInterestingMidUnits] = clinical_cormack(); kScaleRatio = 10;% increase dynamic range of interesting voxels by 3 %convert image img = img - mn; %transloate so min value is 0 extra1 = img - kUninterestingDarkUnits; extra1(extra1 <= 0) = 0; %clip dark to zero extra9=extra1; extra9(extra9 > kInterestingMidUnits) = kInterestingMidUnits; %clip bright extra9 = extra9 * (kScaleRatio-1); %boost mid range %transform image img = img+extra1+extra9; %dark+bright+boostedMidRange %save output [pth,nam,ext] = spm_fileparts(hdr.fname); hdr.fname = fullfile(pth, ['c' nam ext]); hdr.private.dat.scl_slope = 1; hdr.private.dat.scl_inter = 0; spm_write_vol(hdr,img); fnm = hdr.fname; %return new filename %end h2cSub()
github
neurolabusc/Clinical-master
clinical_c2h.m
.m
Clinical-master/clinical_c2h.m
2,519
utf_8
29509e31a5236c2335080a5db93557dc
function clinical_c2h (V) % This script converts a CT scan from Cormack to Hounsfield Units % V: image name(s) [optional] % Example % clinical_c2h('C:\ct\script\Pat1nolesion.nii'); fprintf('CT Cormack to Hounsfield version 4/4/2016\n'); if nargin <1 %no files V = spm_select(inf,'image','Select CT[s] to normalize'); end; for i=1:size(V,1) ref = deblank(V(i,:)); [pth,nam,ext] = spm_fileparts(ref); ref= fullfile(pth,[nam ext]); if (exist(ref,'file') ~= 2) fprintf('Error: unable to find source image %s.\n',ref); return; end; hdr = spm_vol(deblank(V(i,:))); % determine range... img = spm_read_vols(hdr); img(~isfinite(img)) = 0; fprintf('%s input intensity range %.0f %.0f\n',ref,round(min(img(:))),round(max(img(:)))); fprintf(' Ignore QFORM0 warning if reported next\n'); % next scale from Hounsfield to Cormack [pth,nam,ext] = spm_fileparts(hdr.fname); hdr.fname = fullfile(pth,['h' nam ext]); img = c2hsub(img(:)); img = reshape(img,hdr.dim); if spm_type(hdr.dt(1),'minval') >= 0 slope = 1; hdr.dt(1) = 16; %2014 fprintf('Saving %s as 32-bit floating point\n',hdr.fname); elseif spm_type(hdr.dt(1),'intt') %Hounsfield values -1024...max(img) mx = max(max(img(:)), abs(min(img(:))) ); slope = mx/ spm_type(hdr.dt(1),'maxval') ; else slope = 1; end hdr.pinfo(1) = slope; %2014 - change slope in pinfo as well as private hdr.pinfo(2) = 0; %2014 - change intercept in pinfo as well as private spm_write_vol(hdr,img); end; %for each volume %end clinical_c2h() function out = c2hsub(img) %Convert Cormack to Hounsfield [kUninterestingDarkUnits, kInterestingMidUnits] = clinical_cormack(); kScaleRatio = 10;% increase dynamic range of interesting voxels by 3 kMax = kInterestingMidUnits * (kScaleRatio+1); if (min(img(:)) < 0) error('c2h error: negative brightnesses impossible in the Cormack scale'); end img = img-kUninterestingDarkUnits; %out now correct for 0..UninterestingUnits out = img; %out now correct for 0..UninterestingUnits v = img/(kScaleRatio+1); idx = intersect (find(img > 0),find(img <= kMax)); %end c2hsub() out(idx) = v(idx); %out now correct for 0..UninterestingUnits+kInterestingMidUnits v = img - kMax + (kMax/(kScaleRatio+1)); %compute voxels brighter than interesting idx = find(img > kMax); out(idx) = v(idx); %out now correct for all intensities out = out+(kUninterestingDarkUnits-1024); %air is darkest at ~-1000: most 12-bit CT systems encode as -1024 %end c2hsub()
github
neurolabusc/Clinical-master
clinical_mrnormseg12.m
.m
Clinical-master/clinical_mrnormseg12.m
20,699
utf_8
cfe8526928e343dc16153dbf4e355c3d
function clinical_mrnormseg12(T1,lesion,T2, UseXTemplate, vox, bb, DeleteIntermediateImages, ssthresh, autoOrigin) %Known as either clinical_mrnormseg12 or nii_enat_norm depending on if it %is part of the clinical toolbox % see Nachev et al. (2008) http://www.ncbi.nlm.nih.gov/pubmed/18023365 % T1: filename of T1 image % Lesion: filename of lesion map % T2: (optional) filename of image used to draw lesion, if '' then lesion drawn on T1 % UseXTemplate: if false (default) standard SPM template is used, else special template %Examples % clinical_mrnormseg12('T1_LM1054.nii','LS_LM1054.nii','') %lesion drawn on T1 scan % clinical_mrnormseg12('T1_LM1054.nii','LS_LM1054.nii',''T2_LM1054.nii') %lesion drawn on T2 scan % clinical_mrnormseg12('MB_T1.nii','',''); %no lesion - control participant % clinical_mrnormseg12 %use graphical interface %STEP 0: check inputs isSPM12orNewerSub; if isempty(spm_figure('FindWin','Graphics')), spm fmri; end; %launch SPM if it is not running T1param = exist('T1','var'); %did the user provide a T1 scan if ~T1param, T1 = spm_select(1,'image','Select T1 images'); end; if isempty(T1), return; end; if ~exist('lesion','var') && ~T1param, lesion = spm_select(1,'image','Optional: select lesion map'); end; if ~exist('lesion','var'), lesion = ''; end; if ~isempty(lesion) && ~exist('T2','var'), T2 = spm_select(1,'image','Optional: Select image used to draw lesion (if not T1)'); end; if ~exist('T2','var'), T2 = ''; end; if ~exist('UseXTemplate','var'),UseXTemplate = 0; end; if ~exist('vox','var'), vox = [1 1 1]; end; if ~exist('bb','var'), bb = [-78 -112 -70; 78 76 85]; end; if ~exist('DeleteIntermediateImages','var'), DeleteIntermediateImages = true; end; if ~exist('ssthresh','var'), ssthresh = 0.005; end; %with SPM12, better GM, so threshold of 1% if ~exist('autoOrigin','var') %ButtonName = questdlg('Automatic origin detection?','Preferences', 'Yes', 'No', 'No'); %autoOrigin = strcmpi(ButtonName,'Yes'); autoOrigin = false; end T1 = stripVolSub(T1); lesion = stripVolSub(lesion); T2 = stripVolSub(T2); if isDoneSub(T1), fprintf('Already done: skipping normalization of %s\n',T1); return; end; if ~isempty(lesion), [T1,lesion,T2] = checkDimsSub(T1, lesion, T2); end; %check alignment %0: rough estimate for origin and alignment if autoOrigin setOriginSub({T1, T2, lesion}, 1); end if isempty(lesion) %if no lesion - standard normalization newSegSub(T1,'', UseXTemplate); %2: create 'b' (brain extracted) image without scalp signal bT1 = extractSub(ssthresh, T1, prefixSub('c2', T1), prefixSub('c1', T1)); rT1 = newSegWriteSub(T1, bT1, vox, bb); %#ok<NASGU> %wT1 = newSegWriteSub(T1, T1, vox, bb); %#ok<NASGU> return; end %1: align lesion/t2 to match T1 [rT2, rlesion] = coregEstWriteSub(T1,T2,lesion); %#ok<ASGLU> rlesion = smoothSub(rlesion, 3); %2: make image without lesion eT1 = entiamorphicSub (T1, rlesion); %[eT1, erT2] = entiamorphicSub (T1, rlesion, rT2); %for multichannel %3: new-segment image newSegSub(eT1,'', UseXTemplate); %newSegSub(eT1, erT2, UseXTemplate); %for multichannel %4: create 'b' (brain extracted) image without scalp signal bT1 = extractSub(ssthresh, T1, prefixSub('c2', eT1), prefixSub('c1', eT1)); %5: warp render image to standard space rT1 = newSegWriteSub(eT1, bT1, vox, bb); %#ok<NASGU> %6: warp lesion to standard space wrlesion = newSegWriteSub(eT1, rlesion, vox, bb, true); %#ok<NASGU> wT1 = newSegWriteSub(eT1, T1, vox, bb); %#ok<NASGU> if DeleteIntermediateImages, deleteSub(T1); end; %end nii_enat_norm() %--- local functions follow %function img = smoothSub(img, FWHM) %[pth,nam,ext] = spm_fileparts(img); %smth = fullfile(pth, ['s' nam ext]); %spm_smooth(img, smth, FWHM, 0); %img = smth; %end smoothSub() function isDone = isDoneSub(T1) isDone = false; [pth,nam,ext] = fileparts(T1); b = fullfile(pth,['b', nam, ext]); %brain extracted image if ~exist(b,'file'), return; end; defname = fullfile(pth,['y_' nam ext]); %control normalization edefname = fullfile(pth,['y_e' nam ext]); %patient normalization if exist(defname,'file') || exist(edefname,'file'), isDone = true; end; %end isDoneSub() function img = smoothSub(img, FWHM) if isempty(img), return; end; hdr = spm_vol(img); im = spm_read_vols(hdr); if (spm_type(hdr.dt,'intt')) %integer data mn = min(im(:)); range = max(im(:)) - mn; if range < 10 && range > 0 im = (im - mn) * 255/range; end hdr.pinfo(1) = 1; %slope hdr.pinfo(2) = 0; %intercept end smoothFWHMmm = [FWHM FWHM FWHM]; VOX = sqrt(sum(hdr.mat(1:3,1:3).^2)); smoothFWHMvox = smoothFWHMmm/VOX; %for 3D arrays the FWHM is specified in voxels presmooth = im+0; %+0 forces new matrix spm_smooth(presmooth,im,smoothFWHMvox,0); [pth,nam,ext] = spm_fileparts(img); img = fullfile(pth, ['s' nam ext]); hdr.fname = img; spm_write_vol (hdr, squeeze (im )); function img = stripVolSub(img) %strip volume from lesion name, 'img.nii,1' -> 'img.nii' if isempty(img), return; end; [n,m,x] = spm_fileparts(img); %we ignore the volume img = fullfile(n, [m, x]); %end stripVolSub() function [T1,lesion,T2] = checkDimsSub(T1, lesion, T2) if ~exist(T1,'file'), error('T1 image required %s', T1); end; if ~exist('lesion','var'), return; end; if isempty(lesion), return; end; if ~exist(lesion,'file'), error('Lesion image not found %s', lesion); end; hdrT1 = spm_vol(T1); hdrLS = spm_vol(lesion); mmLS = (hdrLS.mat * [0 0 0 1]'); %vox2mm, [0 0 0 1; 0 0 1 1]' mmT1 = (hdrT1.mat * [0 0 0 1]'); dxT1 = sqrt(sum((mmT1(1:3)-mmLS(1:3)).^2)); %error between T1 and lesion if exist('T2','var') && ~isempty(T2) if ~exist(T2,'file'), error('T2 image not found %s', T2); end; hdrT2 = spm_vol(T2); %we compute distance differently for T2/Lesion as these will be resliced... [mnT2, mxT2] = bbSub(hdrT2); %range of T2 bounding box [mnLS, mxLS] = bbSub(hdrLS); %range of Lesion bounding box dxMn = sqrt(sum((mnT2(1:3)-mnLS(1:3)).^2)); %error between T2 and lesion dxMx = sqrt(sum((mxT2(1:3)-mxLS(1:3)).^2)); %error between T2 and lesion if (dxMn > 1) || (dxMx > 1) if (dxT1 < 0.25) T2 = ''; fprintf('WARNING: T2 dimensions do not match lesion - ASSUME lesion drawn on T1'); else fprintf('WARNING: Neither T2 nor T1 aligned to lesion.'); end end return; end %if T2 is present if ~all(hdrT1.dim == hdrLS.dim) error('WARNING: T1 dimensions do not match lesion %s %s',T1, lesion); end if (dxT1 > 0.25) fprintf('WARNING: T1 poorly aligned to lesion.'); end %end checkDimsSub() function [mn, mx] = bbSub(hdr) %return range for image bounding box d = hdr.dim(1:3); c = [ 1 1 1 1 1 1 d(3) 1 1 d(2) 1 1 1 d(2) d(3) 1 d(1) 1 1 1 d(1) 1 d(3) 1 d(1) d(2) 1 1 d(1) d(2) d(3) 1 ]'; tc = hdr.mat(1:3,1:4)*c; % bounding box (world) min and max mn = min(tc,[],2)'; mx = max(tc,[],2)'; %end bbSub() function deleteSub(T1) deletePrefixSub ('LR', T1) deletePrefixSub ('rLR', T1) %deleteSub function deletePrefixSub (pre, nam) nam = prefixSub (pre, nam); if exist(nam, 'file'), delete(nam); end; %end deletePrefixSub() function isSPM12orNewerSub %check that SPM is installed and is at least release 6225 if exist('spm','file') ~= 2, error('Please install SPM12 or later'); end; [v,r] = spm('Ver','',1); r = str2double(r); %#ok<ASGLU> if r < 6225, error('Please update your copy of SPM'); end; %end isSPM12orNewer() function t1Bet = extractSub(thresh, t1, c1, c2, c3) %subroutine to extract brain from surrounding scalp % t1: anatomical scan to be extracted % c1: gray matter map % c2: white matter map % c3: [optional] spinal fluid map fprintf('Brain extraction of %s\n', t1); [pth,nam,ext] = spm_fileparts(t1); %load headers mi = spm_vol(t1);%bias corrected T1 gi = spm_vol(c1);%Gray Matter map wi = spm_vol(c2);%White Matter map %load images m = spm_read_vols(mi); g = spm_read_vols(gi); w = spm_read_vols(wi); if nargin > 4 && ~isempty(c3) ci = spm_vol(c3);%CSF map c = spm_read_vols(ci); w = c+w; end; w = g+w; if thresh <= 0 m=m.*w; else mask= zeros(size(m)); mask(w >= thresh) = 255; spm_smooth(mask,mask,1); %feather the edges mask = mask / 255; m=m.*mask; end; mi.fname = fullfile(pth,['b', nam, ext]); mi.dt(1) = 4; %16-bit precision more than sufficient uint8=2; int16=4; int32=8; float32=16; float64=64 spm_write_vol(mi,m); t1Bet = mi.fname; %end extractSub() function targetname = newSegWriteSub(t1name, targetname, vox, bb, binarize) %reslice img using pre-existing new-segmentation deformation field if isempty(targetname) || isempty(t1name), return; end; if ~exist('bb','var'), bb = [-78 -112 -50; 78 76 85]; end; warning('yy');bb if ~exist('vox','var'), vox =[2 2 2]; end; [pth,nam,ext, vol] = spm_fileparts(t1name); %#ok<NASGU> defname = fullfile(pth,['y_' nam ext]); if ~exist(defname,'file') error('Unable to find new-segment deformation image %s',defname); end fprintf('Warping %s based on NewSegment of %s\n', targetname, t1name); matlabbatch{1}.spm.spatial.normalise.write.subj.def = {defname}; matlabbatch{1}.spm.spatial.normalise.write.subj.resample = {targetname}; matlabbatch{1}.spm.spatial.normalise.write.woptions.bb = bb; matlabbatch{1}.spm.spatial.normalise.write.woptions.vox = vox; matlabbatch{1}.spm.spatial.normalise.write.woptions.interp = 1; %4; //trilinear avoids ringing spm_jobman('run',matlabbatch); targetname = prefixSub('w', targetname); if ~exist('binarize','var') || ~binarize, return; end; hdr = spm_vol(targetname); img = spm_read_vols(hdr); mn = min(img(:)); mx = max(img(:)); thresh = ((mx-mn)*0.5) + mn; spm_write_vol(hdr,+(img > thresh)); %end newSegWriteSub() function newSegSub(t1, t2, UseXTemplate) %apply new segment - return name of warping matrix template = fullfile(spm('Dir'),'tpm','TPM.nii'); if nargin > 2 && UseXTemplate xtemplate = fullfile(spm('Dir'),'toolbox','Clinical','TPM4mm.nii'); if exist(xtemplate,'file') template = xtemplate; else fprintf('WARNING: unable to find template named %s\n', xtemplate); end end if ~exist(template,'file') error('Unable to find template named %s',template); end fprintf('NewSegment of %s\n', t1); matlabbatch{1}.spm.spatial.preproc.channel(1).vols = {t1}; matlabbatch{1}.spm.spatial.preproc.channel(1).biasreg = 0.001; matlabbatch{1}.spm.spatial.preproc.channel(1).biasfwhm = 60; matlabbatch{1}.spm.spatial.preproc.channel(1).write = [0 0]; if nargin > 1 && ~isempty(t2) matlabbatch{1}.spm.spatial.preproc.channel(2).vols = {t2}; matlabbatch{1}.spm.spatial.preproc.channel(2).biasreg = 0.0001; matlabbatch{1}.spm.spatial.preproc.channel(2).biasfwhm = 60; matlabbatch{1}.spm.spatial.preproc.channel(2).write = [0 0]; end; matlabbatch{1}.spm.spatial.preproc.tissue(1).tpm = {[template ',1']}; matlabbatch{1}.spm.spatial.preproc.tissue(1).ngaus = 1; matlabbatch{1}.spm.spatial.preproc.tissue(1).native = [1 1]; matlabbatch{1}.spm.spatial.preproc.tissue(1).warped = [0 0]; matlabbatch{1}.spm.spatial.preproc.tissue(2).tpm = {[template ',2']}; matlabbatch{1}.spm.spatial.preproc.tissue(2).ngaus = 1; matlabbatch{1}.spm.spatial.preproc.tissue(2).native = [1 1]; matlabbatch{1}.spm.spatial.preproc.tissue(2).warped = [0 0]; matlabbatch{1}.spm.spatial.preproc.tissue(3).tpm = {[template ',3']}; matlabbatch{1}.spm.spatial.preproc.tissue(3).ngaus = 2; matlabbatch{1}.spm.spatial.preproc.tissue(3).native = [1 0]; matlabbatch{1}.spm.spatial.preproc.tissue(3).warped = [0 0]; matlabbatch{1}.spm.spatial.preproc.tissue(4).tpm = {[template ',4']}; matlabbatch{1}.spm.spatial.preproc.tissue(4).ngaus = 3; matlabbatch{1}.spm.spatial.preproc.tissue(4).native = [1 0]; matlabbatch{1}.spm.spatial.preproc.tissue(4).warped = [0 0]; matlabbatch{1}.spm.spatial.preproc.tissue(5).tpm = {[template ',5']}; matlabbatch{1}.spm.spatial.preproc.tissue(5).ngaus = 4; matlabbatch{1}.spm.spatial.preproc.tissue(5).native = [1 0]; matlabbatch{1}.spm.spatial.preproc.tissue(5).warped = [0 0]; matlabbatch{1}.spm.spatial.preproc.tissue(6).tpm = {[template ',6']}; matlabbatch{1}.spm.spatial.preproc.tissue(6).ngaus = 2; matlabbatch{1}.spm.spatial.preproc.tissue(6).native = [0 0]; matlabbatch{1}.spm.spatial.preproc.tissue(6).warped = [0 0]; matlabbatch{1}.spm.spatial.preproc.warp.mrf = 1; matlabbatch{1}.spm.spatial.preproc.warp.cleanup = 1; matlabbatch{1}.spm.spatial.preproc.warp.reg = [0 0.001 0.5 0.05 0.2]; matlabbatch{1}.spm.spatial.preproc.warp.affreg = 'mni'; matlabbatch{1}.spm.spatial.preproc.warp.fwhm = 0; matlabbatch{1}.spm.spatial.preproc.warp.samp = 3; matlabbatch{1}.spm.spatial.preproc.warp.write = [1 1]; spm_jobman('run',matlabbatch); %end newSegSub() function [intactT1, intactT2] = entiamorphicSub (T1, lesionNam, T2) %Generates image suitable for Enantiomorphic normalization, see www.pubmed.com/18023365 % anatNam : filename of anatomical scan % lesionNam : filename of lesion map in register with anatomical %returns name of new image with two 'intact' hemispheres if ~exist('T1','var') %no files specified T1 = spm_select(1,'image','Select anatomical image'); end if ~exist('lesionNam','var') %no files specified lesionNam = spm_select(1,'image','Select lesion image'); end if isempty(lesionNam) intactT1 = T1; fprintf('entiamorphicSub skipped: no lesion\n'); return; end if (exist(T1,'file') == 0) || (exist(lesionNam,'file') == 0) error('%s unable to find files %s or %s',mfilename, T1, lesionNam); end if nargin < 3, T2 = ''; end; fprintf('Using lesion %s to substitute %s\n', lesionNam, T1); %create flipped image T1lr = flipSub(T1); T2lr = flipSub(T2); [T1lr, T2lr] = coregEstWriteSub(T1, T1lr, T2lr); %reslice mirror intactT2 = insertSub(T2, T2lr, lesionNam); intactT1 = insertSub(T1, T1lr, lesionNam); %end entiamorphicSub() function namFilled = insertSub(nam, namLR, lesion) %namLR donates voxels masked by lesion to image nam if isempty(nam), namFilled =''; return; end; hdrLesion = spm_vol(lesion); imgLesion = spm_read_vols(hdrLesion); rdata = +(imgLesion > (max(imgLesion(:))/2)); %binarize raw lesion data, + converts logical to double spm_smooth(rdata,imgLesion,4); %blur data rdata = +(imgLesion > 0.05); %dilate: more than 5% spm_smooth(rdata,imgLesion,8); %blur data %now use lesion map to blend flipped and original image hdr = spm_vol(nam); img = spm_read_vols(hdr); hdr_flip = spm_vol(namLR); imgFlip = spm_read_vols(hdr_flip); if ~isequal(size(img), size(imgLesion)), error('Dimensions do not match %s %s', lesion, nam); end; rdata = (img(:) .* (1.0-imgLesion(:)))+ (imgFlip(:) .* imgLesion(:)); rdata = reshape(rdata, size(img)); [pth, nam, ext] = spm_fileparts(hdr.fname); hdr_flip.fname = fullfile(pth,['e' nam ext]);%image with lesion filled with intact hemisphere spm_write_vol(hdr_flip,rdata); namFilled = hdr_flip.fname; %insertSub() function namLR = flipSub (nam) if isempty(nam), namLR = ''; return; end; hdr = spm_vol(nam); img = spm_read_vols(hdr); [pth, nam, ext] = spm_fileparts(hdr.fname); namLR = fullfile(pth, ['LR', nam, ext]); hdr_flip = hdr; hdr_flip.fname = namLR; hdr_flip.mat = [-1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1] * hdr_flip.mat; spm_write_vol(hdr_flip,img); %end flipSub() function [T2, lesion] = coregEstWriteSub(T1, T2, lesion) %coregister T2 to match T1 image, apply to lesion if isempty(T1) || isempty(T2), return; end; fprintf('Coregistering %s to match %s\n',T2,T1); matlabbatch{1}.spm.spatial.coreg.estwrite.ref = {T1}; matlabbatch{1}.spm.spatial.coreg.estwrite.source = {T2}; matlabbatch{1}.spm.spatial.coreg.estwrite.other = {lesion}; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.cost_fun = 'nmi'; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.sep = [4 2]; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.tol = [0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001 0.001]; matlabbatch{1}.spm.spatial.coreg.estwrite.eoptions.fwhm = [7 7]; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.interp = 1; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.wrap = [0 0 0]; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.mask = 0; matlabbatch{1}.spm.spatial.coreg.estwrite.roptions.prefix = 'r'; spm_jobman('run',matlabbatch); T2 = prefixSub('r',T2); if ~isempty(lesion), lesion = prefixSub('r',lesion); end; %end coregEstSub() function nam = prefixSub (pre, nam) [p, n, x] = spm_fileparts(nam); nam = fullfile(p, [pre, n, x]); %end prefixSub() function coivox = setOriginSub(vols, modality) %Align images so that origin and alignment roughly match MNI space % vols : cell string of image name(s) - first image used for estimate, others yoked % modality : modality of first image 1=T1, 2=T2, 3=EPI %Example % setOrigin('T1.nii',1); %align T1 scan % setOrigin({'T1s005.nii', 'fmriblocks009.nii'},1); %use T1 to align T1 and fMRI data % setOrigin %use graphical interface %Chris Rorden 12/2014 (now supports SPM12) if ~exist('vols','var') %no files specified vols = spm_select(inf,'image','Reset origin for selected image(s) (estimated from 1st)'); end if ischar(vols) vols = cellstr(vols); end if ~exist('modality','var') %no files specified modality = 1; fprintf('%s Modality not specified, assuming T1\n', mfilename); end coivox = ones(4,1); %extract filename [pth,nam,ext, ~] = spm_fileparts(deblank(vols{1})); fname = fullfile(pth,[nam ext]); %strip volume label %report if filename does not exist... if (exist(fname, 'file') ~= 2) fprintf('%s error: unable to find image %s.\n',mfilename,fname); return; end; hdr = spm_vol([fname,',1']); %load header img = spm_read_vols(hdr); %load image data img = img - min(img(:)); img(isnan(img)) = 0; %find center of mass in each dimension (total mass divided by weighted location of mass % img = [1 2 1; 3 4 3]; sumTotal = sum(img(:)); coivox(1) = sum(sum(sum(img,3),2)'.*(1:size(img,1)))/sumTotal; %dimension 1 coivox(2) = sum(sum(sum(img,3),1).*(1:size(img,2)))/sumTotal; %dimension 2 coivox(3) = sum(squeeze(sum(sum(img,2),1))'.*(1:size(img,3)))/sumTotal; %dimension 3 XYZ_mm = hdr.mat * coivox; %convert from voxels to millimeters fprintf('%s center of brightness differs from current origin by %.0fx%.0fx%.0fmm in X Y Z dimensions\n',fname,XYZ_mm(1),XYZ_mm(2),XYZ_mm(3)); for v = 1: numel(vols) fname = deblank(vols{v}); if ~isempty(fname) [pth,nam,ext, ~] = spm_fileparts(fname); fname = fullfile(pth,[nam ext]); hdr = spm_vol([fname ',1']); %load header of first volume fname = fullfile(pth,[nam '.mat']); if exist(fname,'file') destname = fullfile(pth,[nam '_old.mat']); copyfile(fname,destname); fprintf('%s is renaming %s to %s\n',mfilename,fname,destname); end hdr.mat(1,4) = hdr.mat(1,4) - XYZ_mm(1); hdr.mat(2,4) = hdr.mat(2,4) - XYZ_mm(2); hdr.mat(3,4) = hdr.mat(3,4) - XYZ_mm(3); spm_create_vol(hdr); if exist(fname,'file') delete(fname); end end end%for each volume coregEstTemplateSub(vols, modality); for v = 1: numel(vols) [pth, nam, ~, ~] = spm_fileparts(deblank(vols{v})); fname = fullfile(pth,[nam '.mat']); if exist(fname,'file') delete(fname); end end %for each volume %end setOriginSub() function coregEstTemplateSub(vols, modality) if modality == 2 template = fullfile(spm('Dir'),'canonical','avg152T2.nii'); elseif modality == 3 template = fullfile(spm('Dir'),'toolbox','OldNorm','EPI.nii'); else template = fullfile(spm('Dir'),'canonical','avg152T1.nii'); end if ~exist(template,'file') error('Unable to find template named %s\n', template); end if ischar(vols) vols = cellstr(vols); end vols(strcmp('',vols)) = []; %remove empty strings %matlabbatch{1}.spm.spatial.coreg.estimate.ref = {'/Users/Shared/spm12/canonical/avg152PD.nii,1'}; matlabbatch{1}.spm.spatial.coreg.estimate.ref = {template}; %matlabbatch{1}.spm.spatial.coreg.estimate.source = {'/Users/rorden/Desktop/pre/bvisiblehuman.nii,1'}; matlabbatch{1}.spm.spatial.coreg.estimate.source = {[deblank(vols{1}),',1']};%{'/Users/rorden/Desktop/3D.nii,1'}; if numel(vols) > 1 matlabbatch{1}.spm.spatial.coreg.estimate.other = vols(2:end); else matlabbatch{1}.spm.spatial.coreg.estimate.other = {''}; end if size(matlabbatch{1}.spm.spatial.coreg.estimate.other,2) > 1, %must be column matlabbatch{1}.spm.spatial.coreg.estimate.other = matlabbatch{1}.spm.spatial.coreg.estimate.other'; end matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.cost_fun = 'nmi'; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.sep = [4 2]; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.tol = [0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001 0.001]; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.fwhm = [7 7]; spm_jobman('run',matlabbatch); %end coregEstTemplateSub()
github
neurolabusc/Clinical-master
clinical_setorigin.m
.m
Clinical-master/clinical_setorigin.m
5,123
utf_8
8af9a012335cf5865248e789ddd4e729
function coivox = clinical_setorigin(vols, modality) %Sets position and orientation of input image(s) to match SPM's templates % vols: filenames for all images from a session. % -if multiple images, the first image is used to determine transforms % -if any images are 4D, only supply the file name %Examples % clinical_setorigin('T1.nii',1); % clinical_setorigin(strvcat('T1.nii','fMRI.nii'),1); %estimate from T1, apply to both T1 and all fMRI volumes %spm_jobman('initcfg'); if ~exist('vols','var') %no files specified vols = spm_select(inf,'image','Select images (first image is high resolution)'); end; if ~exist('modality','var') %modality not specified prompt = {'Enter modality (1=T1,2=T2,CT=3,fMRI(T2*)=4'}; dlg_title = 'Specify contrast of 1st image'; num_lines = 1; def = {'1'}; answer = inputdlg(prompt,dlg_title,num_lines,def); modality = str2double(answer{1}); end coivox = ones(4,1); %center of intensity if ~exist('vols','var') %no files specified vols = spm_select(inf,'image','Reset origin for selected image(s) (estimated from 1st)'); end vols = vol1OnlySub(vols); %only process first volume of 4D datasets... [pth,nam,ext, ~] = spm_fileparts(deblank(vols(1,:))); %extract filename fname = fullfile(pth,[nam ext]); %strip volume label %report if filename does not exist... if (exist(fname, 'file') ~= 2) fprintf('%s error: unable to find image %s.\n',mfilename,fname); return; end; hdr = spm_vol([fname,',1']); %load header img = spm_read_vols(hdr); %load image data img = img - min(img(:)); img(isnan(img)) = 0; %find center of mass in each dimension (total mass divided by weighted location of mass % img = [1 2 1; 3 4 3]; sumTotal = sum(img(:)); coivox(1) = sum(sum(sum(img,3),2)'.*(1:size(img,1)))/sumTotal; %dimension 1 coivox(2) = sum(sum(sum(img,3),1).*(1:size(img,2)))/sumTotal; %dimension 2 coivox(3) = sum(squeeze(sum(sum(img,2),1))'.*(1:size(img,3)))/sumTotal; %dimension 3 XYZ_mm = hdr.mat * coivox; %convert from voxels to millimeters fprintf('%s center of brightness differs from current origin by %.0fx%.0fx%.0fmm in X Y Z dimensions\n',fname,XYZ_mm(1),XYZ_mm(2),XYZ_mm(3)); for v = 1: size(vols,1) fname = deblank(vols(v,:)); if ~isempty(fname) [pth,nam,ext, ~] = spm_fileparts(fname); fname = fullfile(pth,[nam ext]); hdr = spm_vol([fname ',1']); %load header of first volume fname = fullfile(pth,[nam '.mat']); if exist(fname,'file') destname = fullfile(pth,[nam '_old.mat']); copyfile(fname,destname); fprintf('%s is renaming %s to %s\n',mfilename,fname,destname); end hdr.mat(1,4) = hdr.mat(1,4) - XYZ_mm(1); hdr.mat(2,4) = hdr.mat(2,4) - XYZ_mm(2); hdr.mat(3,4) = hdr.mat(3,4) - XYZ_mm(3); spm_create_vol(hdr); if exist(fname,'file') delete(fname); end end end%for each volume coregSub(vols, modality); for v = 1: size(vols,1) [pth, nam, ~, ~] = spm_fileparts(deblank(vols(v,:))); fname = fullfile(pth,[nam '.mat']); if exist(fname,'file') delete(fname); end end%for each volume %end nii_setOrigin() function coregSub(vols, modality) %subroutine coregisters vols to template of specified modality if modality == 2 template = fullfile(spm('Dir'),'templates','T2.nii'); if ~exist(template, 'file') template = fullfile(spm('Dir'),'toolbox','OldNorm','T2.nii'); end elseif modality == 3 tbx = 'Clinical-master'; if ~exist(fullfile(spm('Dir'),'toolbox',tbx), 'dir') tbx = 'Clinical'; end template = fullfile(spm('Dir'),'toolbox',tbx,'scct.nii'); elseif modality == 4 template = fullfile(spm('Dir'),'templates','EPI.nii'); if ~exist(template, 'file') template = fullfile(spm('Dir'),'toolbox','OldNorm','EPI.nii'); end else template = fullfile(spm('Dir'),'templates','T1.nii'); if ~exist(template, 'file') template = fullfile(spm('Dir'),'toolbox','OldNorm','T1.nii'); end end if ~exist(template,'file') error('%s Unable to find template named %s\n', mfilename, template); end matlabbatch{1}.spm.spatial.coreg.estimate.ref = {template}; matlabbatch{1}.spm.spatial.coreg.estimate.source = {[deblank(vols(1,:)),',1']};%{'/Users/rorden/Desktop/3D.nii,1'}; matlabbatch{1}.spm.spatial.coreg.estimate.other = cellstr(vols(2:end,:));% {''}; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.cost_fun = 'nmi'; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.sep = [4 2]; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.tol = [0.02 0.02 0.02 0.001 0.001 0.001 0.01 0.01 0.01 0.001 0.001 0.001]; matlabbatch{1}.spm.spatial.coreg.estimate.eoptions.fwhm = [7 7]; spm_jobman('run',matlabbatch); %end coregSub() function vols = vol1OnlySub(vols) %only select first volume of multivolume images '/dir/img.nii' -> '/dir/img.nii,1', '/dir/img.nii,33' -> '/dir/img.nii,1' oldvols = vols; vols = []; for v = 1: size(oldvols,1) [pth,nam,ext, ~] = spm_fileparts(deblank(oldvols(v,:))); vols = strvcat(vols, fullfile(pth, [ nam ext ',1']) ); %#ok<REMFF1> end %end vol1OnlySub()
github
neurolabusc/Clinical-master
clinical_fix_ge_ct.m
.m
Clinical-master/clinical_fix_ge_ct.m
991
utf_8
934ded9b73952366587245d3d3aefa0d
function clinical_fix_ge_ct (fnms) % Fixes GE CT images with intensities of -3024 for regions outside imaging radius % These artificial rims disrupt normalization and coregistration % fnms: image name(s) [optional] % Example % ge_fix_ct('C:\ct.nii'); if ~exist('fnms','var') fnms = spm_select(inf,'image','Select CT[s] to normalize'); end; for i=1:size(fnms,1) geFixSub( deblank(fnms(i,:)) ); end %end clinical_h2c - local functions follow function geFixSub (fnm) hdr = spm_vol(deblank(fnm)); img = spm_read_vols(hdr); mn = min(img(:)); if (mn >= -1024) fprintf('%s skipped: This image does not have unusual image intensities: %s.\n',mfilename, fnm); return; end fprintf('%s version 8/8/2014: clipping artificially dark values in %s\n',mfilename, fnm); [pth,nam,ext] = spm_fileparts(hdr.fname); movefile(hdr.fname, fullfile(pth, [ nam '_pre_fix_ge_ct' ext]) ); img(img < -1024) = -1024; %hdr.fname = fullfile(pth, ['f' nam ext]); spm_write_vol(hdr,img); %end geFixSub()
github
urbste/MLPnP_matlab_toolbox-master
MLPnP.m
.m
MLPnP_matlab_toolbox-master/MLPnP/MLPnP.m
7,826
utf_8
15b113f908d73d9cc201205d217d0c6d
% Steffen Urban email: [email protected] % Copyright (C) 2016 Steffen Urban % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % 28.06.2016 by Steffen Urban % if you use this file it would be neat to cite our paper: % @INPROCEEDINGS {mlpnp2016, % author = "Urban, S.; Leitloff, J.; Hinz, S.", % title = "MLPNP - A REAL-TIME MAXIMUM LIKELIHOOD SOLUTION TO THE PERSPECTIVE-N-POINT PROBLEM.", % booktitle = "ISPRS Annals of Photogrammetry, Remote Sensing \& Spatial Information Sciences", % year = "2016", % volume = "3", % pages = "131-138"} %% MLPnP - Maximum Likelihood Perspective-N-Point % input: 1. points3D - a 3xN matrix of N 3D points in the object coordinate system % 2. v - a 3xN matrix of N bearing vectors (camera rays) % ||v|| = 1 % 3. cov - if covariance information of bearing vectors if % available then cov is a 9xN matrix. % e.g. it can be computed from image plane variances % sigma_x and sigma_y (in case of perspective cameras): % cov = K\diag([sigma_x sigma_y 0])/K' % cov = reshape(cov,9,1) % here K\ and /K' are the Jacobians of the image to % bearing vector transformation (inverse calibration % matrix K. Details in the paper. % output: 1. T - 4x4 transformation matrix [R T;0 0 0 1] % 2. statistics - contains statistics after GN refinement, see % optim_GN.m for details function [T, statistics] = MLPnP(points3D, v, cov) use_cov = 1; % if cov is not given don't use it if nargin < 3 use_cov = 0; end nrPts = size(points3D,2); % matrix of null space vectors r and s r = zeros(3,nrPts); s = zeros(3,nrPts); cov_reduced = zeros(2,2,nrPts); % test planarity, only works well if the scene is really planar % quasi-planar won't work very well S = points3D*points3D'; [eigRot,~] = eig(S); planar = 0; % create full design matrix A = zeros(nrPts,12); if (rank(S) == 2) planar = 1; points3D1 = eigRot'*(points3D); points3Dn = [points3D1;ones(1,nrPts)]; % create reduced design matrix A = zeros(nrPts,9); else points3Dn = [points3D;ones(1,nrPts)]; end % compute null spaces of bearing vector v: null(v') for i=1:nrPts null_2d = null(v(1:3,i)'); r(:,i) = null_2d(:,1); s(:,i) = null_2d(:,2); if use_cov tmp = reshape(cov(:,i),3,3); cov_reduced(:,:,i) = (null_2d'*tmp*null_2d)^-1; end end % stochastic model Kll = eye(2*nrPts,2*nrPts); % if (normalize) % points3Dn = normc(points3Dn); % end if planar % build reduces system for i=1:nrPts if (use_cov) Kll(2*i-1:2*i,2*i-1:2*i) = cov_reduced(:,:,i); end % r12 A (2*i-1,1) = r(1,i)*points3Dn(2,i); A (2*i,1) = s(1,i)*points3Dn(2,i); % r13 A (2*i-1,2) = r(1,i)*points3Dn(3,i); A (2*i,2) = s(1,i)*points3Dn(3,i); % r22 A (2*i-1,3) = r(2,i)*points3Dn(2,i); A (2*i,3) = s(2,i)*points3Dn(2,i); % r23 A (2*i-1,4) = r(2,i)*points3Dn(3,i); A (2*i,4) = s(2,i)*points3Dn(3,i); % r31 A (2*i-1,5) = r(3,i)*points3Dn(2,i); A (2*i,5) = s(3,i)*points3Dn(2,i); % r32 A (2*i-1,6) = r(3,i)*points3Dn(3,i); A (2*i,6) = s(3,i)*points3Dn(3,i); % t1 A (2*i-1,7) = r(1,i); A (2*i,7) = s(1,i); % t2 A (2*i-1,8) = r(2,i); A (2*i,8) = s(2,i); % t3 A (2*i-1,9) = r(3,i); A (2*i,9) = s(3,i); end else % build full system for i=1:nrPts if (use_cov) Kll(2*i-1:2*i,2*i-1:2*i) = cov_reduced(:,:,i); end % r11 A (2*i-1,1) = r(1,i)*points3Dn(1,i); A (2*i,1) = s(1,i)*points3Dn(1,i); % r12 A (2*i-1,2) = r(1,i)*points3Dn(2,i); A (2*i,2) = s(1,i)*points3Dn(2,i); % r13 A (2*i-1,3) = r(1,i)*points3Dn(3,i); A (2*i,3) = s(1,i)*points3Dn(3,i); % r21 A (2*i-1,4) = r(2,i)*points3Dn(1,i); A (2*i,4) = s(2,i)*points3Dn(1,i); % r22 A (2*i-1,5) = r(2,i)*points3Dn(2,i); A (2*i,5) = s(2,i)*points3Dn(2,i); % r23 A (2*i-1,6) = r(2,i)*points3Dn(3,i); A (2*i,6) = s(2,i)*points3Dn(3,i); % r31 A (2*i-1,7) = r(3,i)*points3Dn(1,i); A (2*i,7) = s(3,i)*points3Dn(1,i); % r32 A (2*i-1,8) = r(3,i)*points3Dn(2,i); A (2*i,8) = s(3,i)*points3Dn(2,i); % r33 A (2*i-1,9) = r(3,i)*points3Dn(3,i); A (2*i,9) = s(3,i)*points3Dn(3,i); % t1 A (2*i-1,10) = r(1,i); A (2*i,10) = s(1,i); % t2 A (2*i-1,11) = r(2,i); A (2*i,11) = s(2,i); % t3 A (2*i-1,12) = r(3,i); A (2*i,12) = s(3,i); end end % do least squares AtPAx=0 b = A'*A; [~,~,v1] = svd(b); if planar tout1 = v1(7:9,end); P = zeros(3,3); P(:,2:3) = reshape(v1(1:6,end),2,3)'; scalefact = sqrt(abs(norm(P(:,2))*norm(P(:,3)))); P(:,1) = cross(P(:,2),P(:,3)); P = P'; %SVD to find the best rotation matrix in the Frobenius sense [U2,~,V2] = svd(P(1:3,1:3)); R = U2*V2'; if det(R) < 0 R = -1*R; end % rotate solution back (see paper) R = eigRot*R; % recover translation tout = (tout1./scalefact); R = -R'; R1 = [R(:,1) R(:,2) R(:,3)]; R2 = [-R(:,1) -R(:,2) R(:,3)]; Ts = zeros(4,4,4); Ts(:,:,1) = [R1 tout;0 0 0 1]; Ts(:,:,2) = [R1 -tout;0 0 0 1]; Ts(:,:,3) = [R2 tout;0 0 0 1]; Ts(:,:,4) = [R2 -tout;0 0 0 1]; % find the best solution with 6 correspondences diff1 = zeros(4,1); for te = 1:6 for ba = 1:4 testres1 = Ts(:,:,ba)*[points3D(:,te);1]; testres11 = normc(testres1(1:3)); diff1(ba) = diff1(ba) + (1-dot(testres11,v(:,te))); end end [~,idx] = min(diff1); T = Ts(:,:,idx); else tout1 = v1(10:12,end); P = reshape(v1(1:9,end),3,3); scalefact = (abs(norm(P(:,1))*norm(P(:,2))*norm(P(:,3))))^(1/3); %SVD to find the best rotation matrix in the Frobenius sense [U2,~,V2] = svd(P(1:3,1:3)); R = U2*V2'; if det(R) < 0 R = -1*R; end % recover translation tout = R*(tout1./scalefact); T1 = [R tout;0 0 0 1]^-1; T2 = [R -tout;0 0 0 1]^-1; diff1 = 0; diff2 = 0; % find the best solution with 6 correspondences for te = 1:6 testres1 = T1*[points3D(:,te);1]; testres2 = T2*[points3D(:,te);1]; testres1 = normc(testres1(1:3)); testres2 = normc(testres2(1:3)); diff1 = diff1+(1-dot(testres1,v(:,te))); diff2 = diff2+(1-dot(testres2,v(:,te))); end if diff1 < diff2 T = T1(1:3,1:4); else T = T2(1:3,1:4); end end optimFlags.epsP = 1e-6; optimFlags.epsF = 1e-6; optimFlags.maxit = 5; optimFlags.tau = 1e-4; [T, statistics] = optim_MLPnP_GN(T, points3D, r, s, Kll, optimFlags); end
github
urbste/MLPnP_matlab_toolbox-master
optim_MLPnP_GN.m
.m
MLPnP_matlab_toolbox-master/MLPnP/optim_MLPnP_GN.m
2,228
utf_8
af445840b833a0de35d6d61ca9922e25
% Steffen Urban email: [email protected] % Copyright (C) 2016 Steffen Urban % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % 28.06.2016 Steffen Urban function [Tout, statistic] = optim_MLPnP_GN(Tinit, points3D, ... rnull, snull, P, optimFlags) % homogeneous to minimal x = [Rodrigues2(Tinit(1:3,1:3))', Tinit(1:3,4)']'; nrL = size(rnull,2); % redundancy redundanz = 2*nrL - length(x); % optim params epsParam = optimFlags.epsP; epsFunc = optimFlags.epsF; % iteration params cnt = 0; stop = false; invKll = P; while cnt < optimFlags.maxit && stop == 0 [r, J] = residualsAndJacobian(x, rnull, snull, points3D); % design matrix N = J.'*invKll*J; % System matrix g = J.'*invKll*r; dx = pinv(N)*g; if (max(abs(dx)) > 20 || min(abs(dx)) > 1) break; end dl = J*dx(1:end); if max(abs(dl)) < epsFunc || max(abs(dx(1:end))) < epsParam x = x-dx; break; else % update parameter vector x = x-dx; end cnt = cnt+1; end % while loop % minimal to homogeneous Tout = [Rodrigues2(x(1:3)) x(4:6)]; % empirical variance factor resV = r.'*invKll*r; if redundanz > 0 if redundanz < nrL s0 = 1; else s0 = resV / redundanz; end else s0 = NaN; end % variance-covariance matrix Qxx = pinv(N); % cofactor matrix of "adjusted observations" Qldld = J*Qxx*J'; statistic = {resV, r, J, Qxx, s0, Qldld, sqrt(s0.*diag(Qxx))}; end
github
urbste/MLPnP_matlab_toolbox-master
jacobians_Rodrigues.m
.m
MLPnP_matlab_toolbox-master/MLPnP/jacobians_Rodrigues.m
13,690
utf_8
4493413b9b6e5b3fa9e0813528b5875d
% Steffen Urban email: [email protected] % Copyright (C) 2016 Steffen Urban % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % 28.06.2016 Steffen Urban % file was created with the Matlab symbolic toolbox % todo: jacobians would probably a lot easier if I'd use expmap and % optimize near the identity... % would need to change the update step from x+dx to exp(dx)*exp(x) or sth function jacs = jacobians_Rodrigues(X1,Y1,Z1,r1,r2,r3,s1,s2,s3,t1,t2,t3,w1,w2,w3) t5 = w1.^2; t6 = w2.^2; t7 = w3.^2; t8 = t5+t6+t7; t9 = sqrt(t8); t10 = sin(t9); t11 = 1.0./sqrt(t8); t12 = cos(t9); t13 = t12-1.0; t14 = 1.0./t8; t16 = t10.*t11.*w3; t17 = t13.*t14.*w1.*w2; t19 = t10.*t11.*w2; t20 = t13.*t14.*w1.*w3; t24 = t6+t7; t27 = t16+t17; t28 = Y1.*t27; t29 = t19-t20; t30 = Z1.*t29; t31 = t13.*t14.*t24; t32 = t31+1.0; t33 = X1.*t32; t15 = t1-t28+t30+t33; t21 = t10.*t11.*w1; t22 = t13.*t14.*w2.*w3; t45 = t5+t7; t53 = t16-t17; t54 = X1.*t53; t55 = t21+t22; t56 = Z1.*t55; t57 = t13.*t14.*t45; t58 = t57+1.0; t59 = Y1.*t58; t18 = t2+t54-t56+t59; t34 = t5+t6; t38 = t19+t20; t39 = X1.*t38; t40 = t21-t22; t41 = Y1.*t40; t42 = t13.*t14.*t34; t43 = t42+1.0; t44 = Z1.*t43; t23 = t3-t39+t41+t44; t25 = 1.0./t8.^(3.0./2.0); t26 = 1.0./t8.^2; t35 = t12.*t14.*w1.*w2; t36 = t5.*t10.*t25.*w3; t37 = t5.*t13.*t26.*w3.*2.0; t46 = t10.*t25.*w1.*w3; t47 = t5.*t10.*t25.*w2; t48 = t5.*t13.*t26.*w2.*2.0; t49 = t10.*t11; t50 = t5.*t12.*t14; t51 = t13.*t26.*w1.*w2.*w3.*2.0; t52 = t10.*t25.*w1.*w2.*w3; t60 = t15.^2; t61 = t18.^2; t62 = t23.^2; t63 = t60+t61+t62; t64 = t5.*t10.*t25; t65 = 1.0./sqrt(t63); t66 = Y1.*r2.*t6; t67 = Z1.*r3.*t7; t68 = r1.*t1.*t5; t69 = r1.*t1.*t6; t70 = r1.*t1.*t7; t71 = r2.*t2.*t5; t72 = r2.*t2.*t6; t73 = r2.*t2.*t7; t74 = r3.*t3.*t5; t75 = r3.*t3.*t6; t76 = r3.*t3.*t7; t77 = X1.*r1.*t5; t78 = X1.*r2.*w1.*w2; t79 = X1.*r3.*w1.*w3; t80 = Y1.*r1.*w1.*w2; t81 = Y1.*r3.*w2.*w3; t82 = Z1.*r1.*w1.*w3; t83 = Z1.*r2.*w2.*w3; t84 = X1.*r1.*t6.*t12; t85 = X1.*r1.*t7.*t12; t86 = Y1.*r2.*t5.*t12; t87 = Y1.*r2.*t7.*t12; t88 = Z1.*r3.*t5.*t12; t89 = Z1.*r3.*t6.*t12; t90 = X1.*r2.*t9.*t10.*w3; t91 = Y1.*r3.*t9.*t10.*w1; t92 = Z1.*r1.*t9.*t10.*w2; t102 = X1.*r3.*t9.*t10.*w2; t103 = Y1.*r1.*t9.*t10.*w3; t104 = Z1.*r2.*t9.*t10.*w1; t105 = X1.*r2.*t12.*w1.*w2; t106 = X1.*r3.*t12.*w1.*w3; t107 = Y1.*r1.*t12.*w1.*w2; t108 = Y1.*r3.*t12.*w2.*w3; t109 = Z1.*r1.*t12.*w1.*w3; t110 = Z1.*r2.*t12.*w2.*w3; t93 = t66+t67+t68+t69+t70+t71+t72+t73+t74+t75+t76+t77+t78+t79+t80+t81+t82+... t83+t84+t85+t86+t87+t88+t89+t90+t91+t92-t102-t103-t104-t105-t106-t107-t108-t109-t110; t94 = t10.*t25.*w1.*w2; t95 = t6.*t10.*t25.*w3; t96 = t6.*t13.*t26.*w3.*2.0; t97 = t12.*t14.*w2.*w3; t98 = t6.*t10.*t25.*w1; t99 = t6.*t13.*t26.*w1.*2.0; t100 = t6.*t10.*t25; t101 = 1.0./t63.^(3.0./2.0); t111 = t6.*t12.*t14; t112 = t10.*t25.*w2.*w3; t113 = t12.*t14.*w1.*w3; t114 = t7.*t10.*t25.*w2; t115 = t7.*t13.*t26.*w2.*2.0; t116 = t7.*t10.*t25.*w1; t117 = t7.*t13.*t26.*w1.*2.0; t118 = t7.*t12.*t14; t119 = t13.*t24.*t26.*w1.*2.0; t120 = t10.*t24.*t25.*w1; t121 = t119+t120; t122 = t13.*t26.*t34.*w1.*2.0; t123 = t10.*t25.*t34.*w1; t131 = t13.*t14.*w1.*2.0; t124 = t122+t123-t131; t139 = t13.*t14.*w3; t125 = -t35+t36+t37+t94-t139; t126 = X1.*t125; t127 = t49+t50+t51+t52-t64; t128 = Y1.*t127; t129 = t126+t128-Z1.*t124; t130 = t23.*t129.*2.0; t132 = t13.*t26.*t45.*w1.*2.0; t133 = t10.*t25.*t45.*w1; t138 = t13.*t14.*w2; t134 = -t46+t47+t48+t113-t138; t135 = X1.*t134; t136 = -t49-t50+t51+t52+t64; t137 = Z1.*t136; t140 = X1.*s1.*t5; t141 = Y1.*s2.*t6; t142 = Z1.*s3.*t7; t143 = s1.*t1.*t5; t144 = s1.*t1.*t6; t145 = s1.*t1.*t7; t146 = s2.*t2.*t5; t147 = s2.*t2.*t6; t148 = s2.*t2.*t7; t149 = s3.*t3.*t5; t150 = s3.*t3.*t6; t151 = s3.*t3.*t7; t152 = X1.*s2.*w1.*w2; t153 = X1.*s3.*w1.*w3; t154 = Y1.*s1.*w1.*w2; t155 = Y1.*s3.*w2.*w3; t156 = Z1.*s1.*w1.*w3; t157 = Z1.*s2.*w2.*w3; t158 = X1.*s1.*t6.*t12; t159 = X1.*s1.*t7.*t12; t160 = Y1.*s2.*t5.*t12; t161 = Y1.*s2.*t7.*t12; t162 = Z1.*s3.*t5.*t12; t163 = Z1.*s3.*t6.*t12; t164 = X1.*s2.*t9.*t10.*w3; t165 = Y1.*s3.*t9.*t10.*w1; t166 = Z1.*s1.*t9.*t10.*w2; t183 = X1.*s3.*t9.*t10.*w2; t184 = Y1.*s1.*t9.*t10.*w3; t185 = Z1.*s2.*t9.*t10.*w1; t186 = X1.*s2.*t12.*w1.*w2; t187 = X1.*s3.*t12.*w1.*w3; t188 = Y1.*s1.*t12.*w1.*w2; t189 = Y1.*s3.*t12.*w2.*w3; t190 = Z1.*s1.*t12.*w1.*w3; t191 = Z1.*s2.*t12.*w2.*w3; t167 = t140+t141+t142+t143+t144+t145+t146+t147+t148+t149+t150+t151+t152+... t153+t154+t155+t156+t157+t158+t159+t160+t161+t162+t163+t164+t165+t166-... t183-t184-t185-t186-t187-t188-t189-t190-t191; t168 = t13.*t26.*t45.*w2.*2.0; t169 = t10.*t25.*t45.*w2; t170 = t168+t169; t171 = t13.*t26.*t34.*w2.*2.0; t172 = t10.*t25.*t34.*w2; t176 = t13.*t14.*w2.*2.0; t173 = t171+t172-t176; t174 = -t49+t51+t52+t100-t111; t175 = X1.*t174; t177 = t13.*t24.*t26.*w2.*2.0; t178 = t10.*t24.*t25.*w2; t192 = t13.*t14.*w1; t179 = -t97+t98+t99+t112-t192; t180 = Y1.*t179; t181 = t49+t51+t52-t100+t111; t182 = Z1.*t181; t193 = t13.*t26.*t34.*w3.*2.0; t194 = t10.*t25.*t34.*w3; t195 = t193+t194; t196 = t13.*t26.*t45.*w3.*2.0; t197 = t10.*t25.*t45.*w3; t200 = t13.*t14.*w3.*2.0; t198 = t196+t197-t200; t199 = t7.*t10.*t25; t201 = t13.*t24.*t26.*w3.*2.0; t202 = t10.*t24.*t25.*w3; t203 = -t49+t51+t52-t118+t199; t204 = Y1.*t203; t205 = t1.*2.0; t206 = Z1.*t29.*2.0; t207 = X1.*t32.*2.0; t208 = t205+t206+t207-Y1.*t27.*2.0; t209 = t2.*2.0; t210 = X1.*t53.*2.0; t211 = Y1.*t58.*2.0; t212 = t209+t210+t211-Z1.*t55.*2.0; t213 = t3.*2.0; t214 = Y1.*t40.*2.0; t215 = Z1.*t43.*2.0; t216 = t213+t214+t215-X1.*t38.*2.0; jacs = reshape([t14.*t65.*(X1.*r1.*w1.*2.0+X1.*r2.*w2+X1.*r3.*w3+Y1.*r1.*w2+... Z1.*r1.*w3+r1.*t1.*w1.*2.0+r2.*t2.*w1.*2.0+r3.*t3.*w1.*2.0+Y1.*r3.*t5.*t12+... Y1.*r3.*t9.*t10-Z1.*r2.*t5.*t12-Z1.*r2.*t9.*t10-X1.*r2.*t12.*w2-X1.*r3.*t12.*w3-... Y1.*r1.*t12.*w2+Y1.*r2.*t12.*w1.*2.0-Z1.*r1.*t12.*w3+Z1.*r3.*t12.*w1.*2.0+... Y1.*r3.*t5.*t10.*t11-Z1.*r2.*t5.*t10.*t11+X1.*r2.*t12.*w1.*w3-... X1.*r3.*t12.*w1.*w2-Y1.*r1.*t12.*w1.*w3+Z1.*r1.*t12.*w1.*w2-... Y1.*r1.*t10.*t11.*w1.*w3+Z1.*r1.*t10.*t11.*w1.*w2-... X1.*r1.*t6.*t10.*t11.*w1-X1.*r1.*t7.*t10.*t11.*w1+X1.*r2.*t5.*t10.*t11.*w2+... X1.*r3.*t5.*t10.*t11.*w3+Y1.*r1.*t5.*t10.*t11.*w2-Y1.*r2.*t5.*t10.*t11.*w1-... Y1.*r2.*t7.*t10.*t11.*w1+Z1.*r1.*t5.*t10.*t11.*w3-Z1.*r3.*t5.*t10.*t11.*w1-... Z1.*r3.*t6.*t10.*t11.*w1+X1.*r2.*t10.*t11.*w1.*w3-X1.*r3.*t10.*t11.*w1.*w2+... Y1.*r3.*t10.*t11.*w1.*w2.*w3+Z1.*r2.*t10.*t11.*w1.*w2.*w3)-t26.*t65.*t93.*w1.*2.0-... t14.*t93.*t101.*(t130+t15.*(-X1.*t121+Y1.*(t46+t47+t48-t13.*t14.*w2-t12.*t14.*w1.*w3)+... Z1.*(t35+t36+t37-t13.*t14.*w3-t10.*t25.*w1.*w2)).*2.0+... t18.*(t135+t137-Y1.*(t132+t133-t13.*t14.*w1.*2.0)).*2.0).*(1.0./2.0),t14.*t65.*(X1.*s1.*w1.*2.0+X1.*s2.*w2+... X1.*s3.*w3+Y1.*s1.*w2+Z1.*s1.*w3+s1.*t1.*w1.*2.0+s2.*t2.*w1.*2.0+... s3.*t3.*w1.*2.0+Y1.*s3.*t5.*t12+Y1.*s3.*t9.*t10-Z1.*s2.*t5.*t12-Z1.*s2.*t9.*t10-X1.*s2.*t12.*w2-... X1.*s3.*t12.*w3-Y1.*s1.*t12.*w2+Y1.*s2.*t12.*w1.*2.0-Z1.*s1.*t12.*w3+... Z1.*s3.*t12.*w1.*2.0+Y1.*s3.*t5.*t10.*t11-Z1.*s2.*t5.*t10.*t11+... X1.*s2.*t12.*w1.*w3-X1.*s3.*t12.*w1.*w2-Y1.*s1.*t12.*w1.*w3+... Z1.*s1.*t12.*w1.*w2+X1.*s2.*t10.*t11.*w1.*w3-X1.*s3.*t10.*t11.*w1.*w2-... Y1.*s1.*t10.*t11.*w1.*w3+Z1.*s1.*t10.*t11.*w1.*w2-X1.*s1.*t6.*t10.*t11.*w1-... X1.*s1.*t7.*t10.*t11.*w1+X1.*s2.*t5.*t10.*t11.*w2+X1.*s3.*t5.*t10.*t11.*w3+... Y1.*s1.*t5.*t10.*t11.*w2-Y1.*s2.*t5.*t10.*t11.*w1-Y1.*s2.*t7.*t10.*t11.*w1+... Z1.*s1.*t5.*t10.*t11.*w3-Z1.*s3.*t5.*t10.*t11.*w1-Z1.*s3.*t6.*t10.*t11.*w1+... Y1.*s3.*t10.*t11.*w1.*w2.*w3+Z1.*s2.*t10.*t11.*w1.*w2.*w3)-... t14.*t101.*t167.*(t130+t15.*(Y1.*(t46+t47+t48-t113-t138)+... Z1.*(t35+t36+t37-t94-t139)-X1.*t121).*2.0+t18.*(t135+t137-... Y1.*(-t131+t132+t133)).*2.0).*(1.0./2.0)-t26.*t65.*t167.*w1.*2.0,t14.*t65.*(X1.*r2.*w1+... Y1.*r1.*w1+Y1.*r2.*w2.*2.0+Y1.*r3.*w3+Z1.*r2.*w3+r1.*t1.*w2.*2.0+... r2.*t2.*w2.*2.0+r3.*t3.*w2.*2.0-X1.*r3.*t6.*t12-X1.*r3.*t9.*t10+... Z1.*r1.*t6.*t12+Z1.*r1.*t9.*t10+X1.*r1.*t12.*w2.*2.0-X1.*r2.*t12.*w1-... Y1.*r1.*t12.*w1-Y1.*r3.*t12.*w3-Z1.*r2.*t12.*w3+Z1.*r3.*t12.*w2.*2.0-... X1.*r3.*t6.*t10.*t11+Z1.*r1.*t6.*t10.*t11+X1.*r2.*t12.*w2.*w3-Y1.*r1.*t12.*w2.*w3+... Y1.*r3.*t12.*w1.*w2-Z1.*r2.*t12.*w1.*w2-Y1.*r1.*t10.*t11.*w2.*w3+... Y1.*r3.*t10.*t11.*w1.*w2-Z1.*r2.*t10.*t11.*w1.*w2-X1.*r1.*t6.*t10.*t11.*w2+... X1.*r2.*t6.*t10.*t11.*w1-X1.*r1.*t7.*t10.*t11.*w2+Y1.*r1.*t6.*t10.*t11.*w1-... Y1.*r2.*t5.*t10.*t11.*w2-Y1.*r2.*t7.*t10.*t11.*w2+Y1.*r3.*t6.*t10.*t11.*w3-... Z1.*r3.*t5.*t10.*t11.*w2+Z1.*r2.*t6.*t10.*t11.*w3-Z1.*r3.*t6.*t10.*t11.*w2+... X1.*r2.*t10.*t11.*w2.*w3+X1.*r3.*t10.*t11.*w1.*w2.*w3+Z1.*r1.*t10.*t11.*w1.*w2.*w3)-... t26.*t65.*t93.*w2.*2.0-t14.*t93.*t101.*(t18.*(Z1.*(-t35+t94+t95+t96-t13.*t14.*w3)-... Y1.*t170+X1.*(t97+t98+t99-t13.*t14.*w1-t10.*t25.*w2.*w3)).*2.0+... t15.*(t180+t182-X1.*(t177+t178-t13.*t14.*w2.*2.0)).*2.0+t23.*(t175+... Y1.*(t35-t94+t95+t96-t13.*t14.*w3)-Z1.*t173).*2.0).*(1.0./2.0),t14.*t65.*(X1.*s2.*w1+... Y1.*s1.*w1+Y1.*s2.*w2.*2.0+Y1.*s3.*w3+Z1.*s2.*w3+s1.*t1.*w2.*2.0+s2.*t2.*w2.*2.0+... s3.*t3.*w2.*2.0-X1.*s3.*t6.*t12-X1.*s3.*t9.*t10+Z1.*s1.*t6.*t12+Z1.*s1.*t9.*t10+... X1.*s1.*t12.*w2.*2.0-X1.*s2.*t12.*w1-Y1.*s1.*t12.*w1-Y1.*s3.*t12.*w3-Z1.*s2.*t12.*w3+... Z1.*s3.*t12.*w2.*2.0-X1.*s3.*t6.*t10.*t11+Z1.*s1.*t6.*t10.*t11+X1.*s2.*t12.*w2.*w3-... Y1.*s1.*t12.*w2.*w3+Y1.*s3.*t12.*w1.*w2-Z1.*s2.*t12.*w1.*w2+X1.*s2.*t10.*t11.*w2.*w3-... Y1.*s1.*t10.*t11.*w2.*w3+Y1.*s3.*t10.*t11.*w1.*w2-Z1.*s2.*t10.*t11.*w1.*w2-... X1.*s1.*t6.*t10.*t11.*w2+X1.*s2.*t6.*t10.*t11.*w1-X1.*s1.*t7.*t10.*t11.*w2+... Y1.*s1.*t6.*t10.*t11.*w1-Y1.*s2.*t5.*t10.*t11.*w2-Y1.*s2.*t7.*t10.*t11.*w2+... Y1.*s3.*t6.*t10.*t11.*w3-Z1.*s3.*t5.*t10.*t11.*w2+Z1.*s2.*t6.*t10.*t11.*w3-... Z1.*s3.*t6.*t10.*t11.*w2+X1.*s3.*t10.*t11.*w1.*w2.*w3+Z1.*s1.*t10.*t11.*w1.*w2.*w3)-... t26.*t65.*t167.*w2.*2.0-t14.*t101.*t167.*(t18.*(X1.*(t97+t98+t99-t112-t192)+... Z1.*(-t35+t94+t95+t96-t139)-Y1.*t170).*2.0+t15.*(t180+t182-X1.*(-t176+t177+t178)).*2.0+... t23.*(t175+Y1.*(t35-t94+t95+t96-t139)-Z1.*t173).*2.0).*(1.0./2.0),t14.*t65.*(X1.*r3.*w1+... Y1.*r3.*w2+Z1.*r1.*w1+Z1.*r2.*w2+Z1.*r3.*w3.*2.0+r1.*t1.*w3.*2.0+r2.*t2.*w3.*2.0+... r3.*t3.*w3.*2.0+X1.*r2.*t7.*t12+X1.*r2.*t9.*t10-Y1.*r1.*t7.*t12-Y1.*r1.*t9.*t10+... X1.*r1.*t12.*w3.*2.0-X1.*r3.*t12.*w1+Y1.*r2.*t12.*w3.*2.0-Y1.*r3.*t12.*w2-... Z1.*r1.*t12.*w1-Z1.*r2.*t12.*w2+X1.*r2.*t7.*t10.*t11-Y1.*r1.*t7.*t10.*t11-... X1.*r3.*t12.*w2.*w3+Y1.*r3.*t12.*w1.*w3+Z1.*r1.*t12.*w2.*w3-Z1.*r2.*t12.*w1.*w3+... Y1.*r3.*t10.*t11.*w1.*w3+Z1.*r1.*t10.*t11.*w2.*w3-Z1.*r2.*t10.*t11.*w1.*w3-... X1.*r1.*t6.*t10.*t11.*w3-X1.*r1.*t7.*t10.*t11.*w3+X1.*r3.*t7.*t10.*t11.*w1-... Y1.*r2.*t5.*t10.*t11.*w3-Y1.*r2.*t7.*t10.*t11.*w3+Y1.*r3.*t7.*t10.*t11.*w2+... Z1.*r1.*t7.*t10.*t11.*w1+Z1.*r2.*t7.*t10.*t11.*w2-Z1.*r3.*t5.*t10.*t11.*w3-... Z1.*r3.*t6.*t10.*t11.*w3-X1.*r3.*t10.*t11.*w2.*w3+X1.*r2.*t10.*t11.*w1.*w2.*w3+... Y1.*r1.*t10.*t11.*w1.*w2.*w3)-t26.*t65.*t93.*w3.*2.0-t14.*t93.*t101.*(t18.*(Z1.*(t46-... t113+t114+t115-t13.*t14.*w2)-Y1.*t198+X1.*(t49+t51+t52+t118-t7.*t10.*t25)).*2.0+... t23.*(X1.*(-t97+t112+t116+t117-t13.*t14.*w1)+Y1.*(-t46+t113+t114+t115-t13.*t14.*w2)-... Z1.*t195).*2.0+t15.*(t204+Z1.*(t97-t112+t116+t117-t13.*t14.*w1)-... X1.*(t201+t202-t13.*t14.*w3.*2.0)).*2.0).*(1.0./2.0),t14.*t65.*(X1.*s3.*w1+... Y1.*s3.*w2+Z1.*s1.*w1+Z1.*s2.*w2+Z1.*s3.*w3.*2.0+s1.*t1.*w3.*2.0+s2.*t2.*w3.*2.0+... s3.*t3.*w3.*2.0+X1.*s2.*t7.*t12+X1.*s2.*t9.*t10-Y1.*s1.*t7.*t12-Y1.*s1.*t9.*t10+... X1.*s1.*t12.*w3.*2.0-X1.*s3.*t12.*w1+Y1.*s2.*t12.*w3.*2.0-... Y1.*s3.*t12.*w2-Z1.*s1.*t12.*w1-Z1.*s2.*t12.*w2+X1.*s2.*t7.*t10.*t11-... Y1.*s1.*t7.*t10.*t11-X1.*s3.*t12.*w2.*w3+Y1.*s3.*t12.*w1.*w3+Z1.*s1.*t12.*w2.*w3-... Z1.*s2.*t12.*w1.*w3-X1.*s3.*t10.*t11.*w2.*w3+Y1.*s3.*t10.*t11.*w1.*w3+... Z1.*s1.*t10.*t11.*w2.*w3-Z1.*s2.*t10.*t11.*w1.*w3-X1.*s1.*t6.*t10.*t11.*w3-... X1.*s1.*t7.*t10.*t11.*w3+X1.*s3.*t7.*t10.*t11.*w1-Y1.*s2.*t5.*t10.*t11.*w3-... Y1.*s2.*t7.*t10.*t11.*w3+Y1.*s3.*t7.*t10.*t11.*w2+Z1.*s1.*t7.*t10.*t11.*w1+... Z1.*s2.*t7.*t10.*t11.*w2-Z1.*s3.*t5.*t10.*t11.*w3-Z1.*s3.*t6.*t10.*t11.*w3+... X1.*s2.*t10.*t11.*w1.*w2.*w3+Y1.*s1.*t10.*t11.*w1.*w2.*w3)-t26.*t65.*t167.*w3.*2.0-... t14.*t101.*t167.*(t18.*(Z1.*(t46-t113+t114+t115-t138)-Y1.*t198+... X1.*(t49+t51+t52+t118-t199)).*2.0+t23.*(X1.*(-t97+t112+t116+t117-... t192)+Y1.*(-t46+t113+t114+t115-t138)-Z1.*t195).*2.0+t15.*(t204+Z1.*(t97-t112+... t116+t117-t192)-X1.*(-t200+t201+t202)).*2.0).*(1.0./2.0),r1.*t65-... t14.*t93.*t101.*t208.*(1.0./2.0),s1.*t65-t14.*t101.*t167.*t208.*(1.0./2.0),r2.*t65-... t14.*t93.*t101.*t212.*(1.0./2.0),s2.*t65-t14.*t101.*t167.*t212.*(1.0./2.0),r3.*t65-... t14.*t93.*t101.*t216.*(1.0./2.0),s3.*t65-t14.*t101.*t167.*t216.*(1.0./2.0)],[2,6]);
github
urbste/MLPnP_matlab_toolbox-master
residualsAndJacobian.m
.m
MLPnP_matlab_toolbox-master/MLPnP/residualsAndJacobian.m
1,387
utf_8
89d0256a7c3f30ed205d43dd9c2208c6
% Steffen Urban email: [email protected] % Copyright (C) 2016 Steffen Urban % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % 28.06.2016 Steffen Urban function [err,J] = residualsAndJacobian(x, r, s, points3D) nrPts = size(points3D,2); err = zeros(2*nrPts,1); J = zeros(2*nrPts,6); R = Rodrigues2(x(1:3)); t = x(4:6); res1 = R*points3D+repmat(t,1,nrPts); normres = normc(res1(1:3,:)); for i=1:size(r,2) err(2*i-1,1) = r(:,i)'*normres(:,i); err(2*i,1) = s(:,i)'*normres(:,i); J(2*i-1:2*i,1:6) = jacobians_Rodrigues(points3D(1,i),points3D(2,i),points3D(3,i),... r(1,i),r(2,i),r(3,i),s(1,i),s(2,i),s(3,i),x(4),x(5),x(6),x(1),x(2),x(3)); end end
github
urbste/MLPnP_matlab_toolbox-master
Rodrigues2.m
.m
MLPnP_matlab_toolbox-master/MLPnP/Rodrigues2.m
1,658
utf_8
392768dcf4fc591828ec95d9e0cb3814
% Steffen Urban email: [email protected] % Copyright (C) 2016 Steffen Urban % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. % 28.06.2016 Steffen Urban function R2 = Rodrigues2(R1) [r,c] = size(R1); %% Rodrigues Rotation Vector to Rotation Matrix if ((r == 3) && (c == 1)) || ((r == 1) && (c == 3)) wx = [ 0 -R1(3) R1(2); R1(3) 0 -R1(1); -R1(2) R1(1) 0 ]; omega_norm = sqrt(R1(1)^2 + R1(2)^2 + R1(3)^2); if (omega_norm < eps) R2 = eye(3); else R2 = eye(3) + ... sin(omega_norm)/omega_norm*wx + ... (1-cos(omega_norm))/omega_norm^2*wx^2; end %% Rotation Matrix to Rodrigues Rotation Vector elseif (r == 3) && (c == 3) w_norm = acos((trace(R1)-1)/2); if (w_norm < eps) R2 = [0 0 0]'; else R2 = 1/(2*sin(w_norm)) * ... [R1(3,2)-R1(2,3);R1(1,3)-R1(3,1);R1(2,1)-R1(1,2)]*w_norm; end end
github
urbste/MLPnP_matlab_toolbox-master
efficient_pnp_gauss.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/epnp/efficient_pnp_gauss.m
7,985
utf_8
361396729ae9c9291df547c60c062e74
function [R,T,Xc,best_solution,opt]=efficient_pnp_gauss(x3d_h,x2d_h,A) % EFFICIENT_PNP_GAUSS Main Function to solve the PnP problem % as described in: % % Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua. % Accurate Non-Iterative O(n) Solution to the PnP Problem. % In Proceedings of ICCV, 2007. % % Note: In this version of the software we perform a final % optimization using Gauss-Newton,which is not described in the % paper. % % x3d_h: homogeneous coordinates of the points in world reference % x2d_h: homogeneous position of the points in the image plane % A: intrincic camera parameters % R: Rotation of the camera system wrt world reference % T: Translation of the camera system wrt world reference % Xc: Position of the points in the camera reference % best solution: dimension of the kernel for the best solution % (before applying Gauss Newton). % opt: some parameters of the optimization process % % Copyright (C) <2007> <Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Francesc Moreno-Noguer, CVLab-EPFL, October 2007. % [email protected], http://cvlab.epfl.ch/~fmoreno/ Xw=x3d_h(:,1:3); U=x2d_h(:,1:2); THRESHOLD_REPROJECTION_ERROR=20;%error in degrees of the basis formed by the control points. %If we have a larger error, we will compute the solution using a larger %number of vectors in the kernel %define control points in a world coordinate system (centered on the 3d %points centroid) Cw=define_control_points(); %compute alphas (linear combination of the control points to represent the 3d %points) Alph=compute_alphas(Xw,Cw); %Compute M M=compute_M_ver2(U,Alph,A); %Compute kernel M Km=kernel_noise(M,4); %in matlab we have directly the funcion km=null(M); %1.-Solve assuming dim(ker(M))=1. X=[Km_end];------------------------------ dim_kerM=1; X1=Km(:,end); [Cc,Xc,sc]=compute_norm_sign_scaling_factor(X1,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(1)=reprojection_error_usingRT(Xw,U,R,T,A); sol(1).Xc=Xc; sol(1).Cc=Cc; sol(1).R=R; sol(1).T=T; sol(1).error=err(1); sol(1).betas=[1]; sol(1).sc=sc; sol(1).Kernel=X1; %2.-Solve assuming dim(ker(M))=2------------------------------------------ Km1=Km(:,end-1); Km2=Km(:,end); %control points distance constraint D=compute_constraint_distance_2param_6eq_3unk(Km1,Km2); dsq=define_distances_btw_control_points(); betas_=inv(D'*D)*D'*dsq; beta1=sqrt(abs(betas_(1))); beta2=sqrt(abs(betas_(3)))*sign(betas_(2))*sign(betas_(1)); X2=beta1*Km1+beta2*Km2; [Cc,Xc,sc]=compute_norm_sign_scaling_factor(X2,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(2)=reprojection_error_usingRT(Xw,U,R,T,A); sol(2).Xc=Xc; sol(2).Cc=Cc; sol(2).R=R; sol(2).T=T; sol(2).error=err(2); sol(2).betas=[beta1,beta2]; sol(2).sc=sc; sol(2).Kernel=[Km1,Km2]; %3.-Solve assuming dim(ker(M))=3------------------------------------------ if min(err)>THRESHOLD_REPROJECTION_ERROR %just compute if we do not have good solution in the previus cases Km1=Km(:,end-2); Km2=Km(:,end-1); Km3=Km(:,end); %control points distance constraint D=compute_constraint_distance_3param_6eq_6unk(Km1,Km2,Km3); dsq=define_distances_btw_control_points(); betas_=inv(D)*dsq; beta1=sqrt(abs(betas_(1))); beta2=sqrt(abs(betas_(4)))*sign(betas_(2))*sign(betas_(1)); beta3=sqrt(abs(betas_(6)))*sign(betas_(3))*sign(betas_(1)); X3=beta1*Km1+beta2*Km2+beta3*Km3; [Cc,Xc,sc]=compute_norm_sign_scaling_factor(X3,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(3)=reprojection_error_usingRT(Xw,U,R,T,A); sol(3).Xc=Xc; sol(3).Cc=Cc; sol(3).R=R; sol(3).T=T; sol(3).error=err(3); sol(3).betas=[beta1,beta2,beta3]; sol(3).sc=sc; sol(3).Kernel=[Km1,Km2,Km3]; end %4.-Solve assuming dim(ker(M))=4------------------------------------------ if min(err)>THRESHOLD_REPROJECTION_ERROR %just compute if we do not have good solution in the previus cases Km1=Km(:,end-3); Km2=Km(:,end-2); Km3=Km(:,end-1); Km4=Km(:,end); D=compute_constraint_distance_orthog_4param_9eq_10unk(Km1,Km2,Km3,Km4); dsq=define_distances_btw_control_points(); lastcolumn=[-dsq',0,0,0]'; D_=[D,lastcolumn]; Kd=null(D_); P=compute_permutation_constraint4(Kd); lambdas_=kernel_noise(P,1); lambda(1)=sqrt(abs(lambdas_(1))); lambda(2)=sqrt(abs(lambdas_(6)))*sign(lambdas_(2))*sign(lambdas_(1)); lambda(3)=sqrt(abs(lambdas_(10)))*sign(lambdas_(3))*sign(lambdas_(1)); lambda(4)=sqrt(abs(lambdas_(13)))*sign(lambdas_(4))*sign(lambdas_(1)); lambda(5)=sqrt(abs(lambdas_(15)))*sign(lambdas_(5))*sign(lambdas_(1)); betass_=lambda(1)*Kd(:,1)+lambda(2)*Kd(:,2)+lambda(3)*Kd(:,3)+lambda(4)*Kd(:,4)+lambda(5)*Kd(:,5); beta1=sqrt(abs(betass_(1))); beta2=sqrt(abs(betass_(5)))*sign(betass_(2)); beta3=sqrt(abs(betass_(8)))*sign(betass_(3)); beta4=sqrt(abs(betass_(10)))*sign(betass_(4)); X4=beta1*Km1+beta2*Km2+beta3*Km3+beta4*Km4; [Cc,Xc,sc]=compute_norm_sign_scaling_factor(X4,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(4)=reprojection_error_usingRT(Xw,U,R,T,A); sol(4).Xc=Xc; sol(4).Cc=Cc; sol(4).R=R; sol(4).T=T; sol(4).error=err(4); sol(4).betas=[beta1,beta2,beta3,beta4]; sol(4).sc=sc; sol(4).Kernel=[Km1,Km2,Km3,Km4]; end %5.-Gauss Newton Optimization------------------------------------------------------ [min_err,best_solution]=min(err); Xc=sol(best_solution).Xc; R=sol(best_solution).R; T=sol(best_solution).T; Betas=sol(best_solution).betas; sc=sol(best_solution).sc; Kernel=sol(best_solution).Kernel; if best_solution==1 Betas=[0,0,0,Betas]; elseif best_solution==2 Betas=[0,0,Betas]; elseif best_solution==3 Betas=[0,Betas]; end Km1=Km(:,end-3); Km2=Km(:,end-2); Km3=Km(:,end-1); Km4=Km(:,end); Kernel=[Km1,Km2,Km3,Km4]; %refine the solution iterating over the betas Beta0=Betas/sc; [Xc_opt,R_opt,T_opt,err_opt,iter]=optimize_betas_gauss_newton(Kernel,Cw,Beta0,Alph,Xw,U,A); %Just update R,T,Xc if Gauss Newton improves results (which is almost %always) if err_opt<min_err R=R_opt; T=T_opt; Xc=Xc_opt; end opt.Beta0=Beta0; opt.Kernel=Kernel; opt.iter=iter; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R, T]=getrotT(wpts,cpts) % This routine solves the exterior orientation problem for a point cloud % given in both camera and world coordinates. % wpts = 3D points in arbitrary reference frame % cpts = 3D points in camera reference frame n=size(wpts,1); M=zeros(3); ccent=mean(cpts); wcent=mean(wpts); for i=1:3 cpts(:,i)=cpts(:,i)-ccent(i)*ones(n,1); wpts(:,i)=wpts(:,i)-wcent(i)*ones(n,1); end for i=1:n M=M+cpts(i,:)'*wpts(i,:); end [U S V]=svd(M); R=U*V'; if det(R)<0 R=-R; end T=ccent'-R*wcent'; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [err,Urep]=reprojection_error_usingRT(Xw,U,R,T,A) %clear all; close all; load reprojection_error_usingRT; n=size(Xw,1); P=A*[R,T]; Xw_h=[Xw,ones(n,1)]; Urep_=(P*Xw_h')'; %project reference points into the image plane Urep=zeros(n,2); Urep(:,1)=Urep_(:,1)./Urep_(:,3); Urep(:,2)=Urep_(:,2)./Urep_(:,3); %reprojection error err_=sqrt((U(:,1)-Urep(:,1)).^2+(U(:,2)-Urep(:,2)).^2); err=sum(err_)/n;
github
urbste/MLPnP_matlab_toolbox-master
efficient_pnp.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/epnp/efficient_pnp.m
6,550
utf_8
b1b02989deb052da7480f60d06be7010
function [R,T,Xc,best_solution]=efficient_pnp(x3d_h,x2d_h,A) % EFFICIENT_PNP Main Function to solve the PnP problem % as described in: % % Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua. % Accurate Non-Iterative O(n) Solution to the PnP Problem. % In Proceedings of ICCV, 2007. % % x3d_h: homogeneous coordinates of the points in world reference % x2d_h: homogeneous position of the points in the image plane % A: intrincic camera parameters % R: Rotation of the camera system wrt world reference % T: Translation of the camera system wrt world reference % Xc: Position of the points in the camera reference % % Copyright (C) <2007> <Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Francesc Moreno-Noguer, CVLab-EPFL, September 2007. % [email protected], http://cvlab.epfl.ch/~fmoreno/ Xw=x3d_h(:,1:3); U=x2d_h(:,1:2); THRESHOLD_REPROJECTION_ERROR=20;%error in degrees of the basis formed by the control points. %If we have a larger error, we will compute the solution using a larger %number of vectors in the kernel %define control points in a world coordinate system (centered on the 3d %points centroid) Cw=define_control_points(); %compute alphas (linear combination of the control points to represent the 3d %points) Alph=compute_alphas(Xw,Cw); %Compute M M=compute_M_ver2(U,Alph,A); %Compute kernel M Km=kernel_noise(M,4); %in matlab we have directly the funcion km=null(M); %1.-Solve assuming dim(ker(M))=1. X=[Km_end];------------------------------ dim_kerM=1; X1=Km(:,end); [Cc,Xc]=compute_norm_sign_scaling_factor(X1,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(1)=reprojection_error_usingRT(Xw,U,R,T,A); sol(1).Xc=Xc; sol(1).Cc=Cc; sol(1).R=R; sol(1).T=T; sol(1).error=err(1); %2.-Solve assuming dim(ker(M))=2------------------------------------------ Km1=Km(:,end-1); Km2=Km(:,end); %control points distance constraint D=compute_constraint_distance_2param_6eq_3unk(Km1,Km2); dsq=define_distances_btw_control_points(); betas_=inv(D'*D)*D'*dsq; beta1=sqrt(abs(betas_(1))); beta2=sqrt(abs(betas_(3)))*sign(betas_(2))*sign(betas_(1)); X2=beta1*Km1+beta2*Km2; [Cc,Xc]=compute_norm_sign_scaling_factor(X2,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(2)=reprojection_error_usingRT(Xw,U,R,T,A); sol(2).Xc=Xc; sol(2).Cc=Cc; sol(2).R=R; sol(2).T=T; sol(2).error=err(2); %3.-Solve assuming dim(ker(M))=3------------------------------------------ if min(err)>THRESHOLD_REPROJECTION_ERROR %just compute if we do not have good solution in the previus cases Km1=Km(:,end-2); Km2=Km(:,end-1); Km3=Km(:,end); %control points distance constraint D=compute_constraint_distance_3param_6eq_6unk(Km1,Km2,Km3); dsq=define_distances_btw_control_points(); betas_=inv(D)*dsq; beta1=sqrt(abs(betas_(1))); beta2=sqrt(abs(betas_(4)))*sign(betas_(2))*sign(betas_(1)); beta3=sqrt(abs(betas_(6)))*sign(betas_(3))*sign(betas_(1)); X3=beta1*Km1+beta2*Km2+beta3*Km3; [Cc,Xc]=compute_norm_sign_scaling_factor(X3,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(3)=reprojection_error_usingRT(Xw,U,R,T,A); sol(3).Xc=Xc; sol(3).Cc=Cc; sol(3).R=R; sol(3).T=T; sol(3).error=err(3); end %4.-Solve assuming dim(ker(M))=4------------------------------------------ if min(err)>THRESHOLD_REPROJECTION_ERROR %just compute if we do not have good solution in the previus cases Km1=Km(:,end-3); Km2=Km(:,end-2); Km3=Km(:,end-1); Km4=Km(:,end); D=compute_constraint_distance_orthog_4param_9eq_10unk(Km1,Km2,Km3,Km4); dsq=define_distances_btw_control_points(); lastcolumn=[-dsq',0,0,0]'; D_=[D,lastcolumn]; Kd=null(D_); P=compute_permutation_constraint4(Kd); lambdas_=kernel_noise(P,1); lambda(1)=sqrt(abs(lambdas_(1))); lambda(2)=sqrt(abs(lambdas_(6)))*sign(lambdas_(2))*sign(lambdas_(1)); lambda(3)=sqrt(abs(lambdas_(10)))*sign(lambdas_(3))*sign(lambdas_(1)); lambda(4)=sqrt(abs(lambdas_(13)))*sign(lambdas_(4))*sign(lambdas_(1)); lambda(5)=sqrt(abs(lambdas_(15)))*sign(lambdas_(5))*sign(lambdas_(1)); betass_=lambda(1)*Kd(:,1)+lambda(2)*Kd(:,2)+lambda(3)*Kd(:,3)+lambda(4)*Kd(:,4)+lambda(5)*Kd(:,5); beta1=sqrt(abs(betass_(1))); beta2=sqrt(abs(betass_(5)))*sign(betass_(2)); beta3=sqrt(abs(betass_(8)))*sign(betass_(3)); beta4=sqrt(abs(betass_(10)))*sign(betass_(4)); X4=beta1*Km1+beta2*Km2+beta3*Km3+beta4*Km4; [Cc,Xc]=compute_norm_sign_scaling_factor(X4,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(4)=reprojection_error_usingRT(Xw,U,R,T,A); sol(4).Xc=Xc; sol(4).Cc=Cc; sol(4).R=R; sol(4).T=T; sol(4).error=err(4); end [min_err,best_solution]=min(err); Xc=sol(best_solution).Xc; R=sol(best_solution).R; T=sol(best_solution).T; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R, T]=getrotT(wpts,cpts) % This routine solves the exterior orientation problem for a point cloud % given in both camera and world coordinates. % wpts = 3D points in arbitrary reference frame % cpts = 3D points in camera reference frame n=size(wpts,1); M=zeros(3); ccent=mean(cpts); wcent=mean(wpts); for i=1:3 cpts(:,i)=cpts(:,i)-ccent(i)*ones(n,1); wpts(:,i)=wpts(:,i)-wcent(i)*ones(n,1); end for i=1:n M=M+cpts(i,:)'*wpts(i,:); end [U S V]=svd(M); R=U*V'; if det(R)<0 R=-R; end T=ccent'-R*wcent'; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [err,Urep]=reprojection_error_usingRT(Xw,U,R,T,A) %clear all; close all; load reprojection_error_usingRT; n=size(Xw,1); P=A*[R,T]; Xw_h=[Xw,ones(n,1)]; Urep_=(P*Xw_h')'; %project reference points into the image plane Urep=zeros(n,2); Urep(:,1)=Urep_(:,1)./Urep_(:,3); Urep(:,2)=Urep_(:,2)./Urep_(:,3); %reprojection error err_=sqrt((U(:,1)-Urep(:,1)).^2+(U(:,2)-Urep(:,2)).^2); err=sum(err_)/n;
github
urbste/MLPnP_matlab_toolbox-master
efficient_pnp_planar.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/epnp/efficient_pnp_planar.m
16,335
utf_8
be35d59e4da0eadf5e108ffbc469f801
function [R,t,Xc,best_solution]=efficient_pnp_planar(x3d_h,x2d_h,A) % EFFICIENT_PNP Main Function to solve the PnP problem % as described in: % % Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua. % Accurate Non-Iterative O(n) Solution to the PnP Problem. % In Proceedings of ICCV, 2007. % % x3d_h: homogeneous coordinates of the points in world reference % x2d_h: homogeneous position of the points in the image plane % A: intrincic camera parameters % R: Rotation of the camera system wrt world reference % T: Translation of the camera system wrt world reference % Xc: Position of the points in the camera reference % % Copyright (C) <2007> <Francesc Moreno-Noguer, Vincent Lepetit, Pascal Fua> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Francesc Moreno-Noguer, CVLab-EPFL, September 2007. % [email protected], http://cvlab.epfl.ch/~fmoreno/ %============================================================= % Modified by % Xu Chi, Huazhong University of Science and Technology, China %============================================================= Xw=x3d_h(:,1:3); U=x2d_h(:,1:2); R= []; t= []; THRESHOLD_REPROJECTION_ERROR=5/800;%error in degrees of the basis formed by the control points. %If we have a larger error, we will compute the solution using a larger %number of vectors in the kernel %define control points in a world coordinate system (centered on the 3d %points centroid) Cw=[1 0 0; 0 1 0; 0 0 0]; %compute alphas (linear combination of the control points to represent the 3d %points) n=size(Xw,1); %number of 3d points C=[Cw(:,1:2)';ones(1,3)]; X=[Xw(:,1:2)';ones(1,n)]; Alph_=inv(C)*X; Alph=Alph_'; %Compute M M=compute_M2(U,Alph,A); %Compute kernel M MtM=M'*M; [V,S]=eig(MtM); Km=V(:,4:-1:1); %in matlab we have directly the funcion km=null(M); %1.-Solve assuming dim(ker(M))=1. X=[Km_end];------------------------------ dim_kerM=1; X1=Km(:,end); [Cc,Xc]=compute_norm_sign_scaling_factor2(X1,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(1)=reprojection_error_usingRT(Xw,U,R,T,A); sol(1).Xc=Xc; sol(1).Cc=Cc; sol(1).R=R; sol(1).T=T; sol(1).error=err(1); %2.-Solve assuming dim(ker(M))=2------------------------------------------ Km1=Km(:,end-1); Km2=Km(:,end); %control points distance constraint D=compute_constraint_distance_2param(Km1,Km2); dsq=define_distances_btw_control_points2(); betas_=inv(D'*D)*D'*dsq; beta1=sqrt(abs(betas_(1))); beta2=sqrt(abs(betas_(3)))*sign(betas_(2))*sign(betas_(1)); X2=beta1*Km1+beta2*Km2; [Cc,Xc]=compute_norm_sign_scaling_factor2(X2,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(2)=reprojection_error_usingRT(Xw,U,R,T,A); sol(2).Xc=Xc; sol(2).Cc=Cc; sol(2).R=R; sol(2).T=T; sol(2).error=err(2); %3.-Solve assuming dim(ker(M))=3------------------------------------------ if min(err)>THRESHOLD_REPROJECTION_ERROR %just compute if we do not have good solution in the previus cases Km1=Km(:,end-2); Km2=Km(:,end-1); Km3=Km(:,end); %control points distance constraint D=compute_constraint_distance_3param(Km1,Km2,Km3); dsq=define_distances_btw_control_points2(); D_=[D,-dsq]; Kd=null(D_); for i= 1:4 Kd(:,i)= Kd(:,i)/Kd(7,i); end Kd= Kd(1:6,:); P=compute_permutation_constraint3(Kd); lambdas_=kernel_noise(P,1); lambda(1)=sqrt(abs(lambdas_(1))); lambda(2)=sqrt(abs(lambdas_(5)))*sign(lambdas_(2)); lambda(3)=sqrt(abs(lambdas_(8)))*sign(lambdas_(3)); lambda(4)=sqrt(abs(lambdas_(10)))*sign(lambdas_(4)); betas_=lambda(1)*Kd(:,1)+lambda(2)*Kd(:,2)+lambda(3)*Kd(:,3)+lambda(4)*Kd(:,4); beta1=sqrt(abs(betas_(1))); beta2=sqrt(abs(betas_(4)))*sign(betas_(2))*sign(betas_(1)); beta3=sqrt(abs(betas_(6)))*sign(betas_(3))*sign(betas_(1)); X3=beta1*Km1+beta2*Km2+beta3*Km3; [Cc,Xc]=compute_norm_sign_scaling_factor2(X3,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(3)=reprojection_error_usingRT(Xw,U,R,T,A); sol(3).Xc=Xc; sol(3).Cc=Cc; sol(3).R=R; sol(3).T=T; sol(3).error=err(3); end [min_err,best_solution]=min(err); Xc=sol(best_solution).Xc; R=sol(best_solution).R; t=sol(best_solution).T; return %4.-Solve assuming dim(ker(M))=4------------------------------------------ if min(err)>THRESHOLD_REPROJECTION_ERROR %just compute if we do not have good solution in the previus cases Km1=Km(:,end-3); Km2=Km(:,end-2); Km3=Km(:,end-1); Km4=Km(:,end); D=compute_constraint_distance_orthog_4param_9eq_10unk(Km1,Km2,Km3,Km4); dsq=define_distances_btw_control_points(); lastcolumn=[-dsq',0,0,0]'; D_=[D,lastcolumn]; Kd=null(D_); P=compute_permutation_constraint4(Kd); lambdas_=kernel_noise(P,1); lambda(1)=sqrt(abs(lambdas_(1))); lambda(2)=sqrt(abs(lambdas_(6)))*sign(lambdas_(2))*sign(lambdas_(1)); lambda(3)=sqrt(abs(lambdas_(10)))*sign(lambdas_(3))*sign(lambdas_(1)); lambda(4)=sqrt(abs(lambdas_(13)))*sign(lambdas_(4))*sign(lambdas_(1)); lambda(5)=sqrt(abs(lambdas_(15)))*sign(lambdas_(5))*sign(lambdas_(1)); betass_=lambda(1)*Kd(:,1)+lambda(2)*Kd(:,2)+lambda(3)*Kd(:,3)+lambda(4)*Kd(:,4)+lambda(5)*Kd(:,5); beta1=sqrt(abs(betass_(1))); beta2=sqrt(abs(betass_(5)))*sign(betass_(2)); beta3=sqrt(abs(betass_(8)))*sign(betass_(3)); beta4=sqrt(abs(betass_(10)))*sign(betass_(4)); X4=beta1*Km1+beta2*Km2+beta3*Km3+beta4*Km4; [Cc,Xc]=compute_norm_sign_scaling_factor(X4,Cw,Alph,Xw); [R,T]=getrotT(Xw,Xc); %solve exterior orientation err(4)=reprojection_error_usingRT(Xw,U,R,T,A); sol(4).Xc=Xc; sol(4).Cc=Cc; sol(4).R=R; sol(4).T=T; sol(4).error=err(4); end [min_err,best_solution]=min(err); Xc=sol(best_solution).Xc; R=sol(best_solution).R; t=sol(best_solution).T; return function [err,Urep]=reprojection_error_usingRT(Xw,U,R,T,A) %clear all; close all; load reprojection_error_usingRT; n=size(Xw,1); P=A*[R,T]; Xw_h=[Xw,ones(n,1)]; Urep_=(P*Xw_h')'; %project reference points into the image plane Urep=zeros(n,2); Urep(:,1)=Urep_(:,1)./Urep_(:,3); Urep(:,2)=Urep_(:,2)./Urep_(:,3); %reprojection error err_=sqrt((U(:,1)-Urep(:,1)).^2+(U(:,2)-Urep(:,2)).^2); err=sum(err_)/n; return function M=compute_M2(U,Alph,A) n=size(Alph,1); %number of 3d points fu=A(1,1); fv=A(2,2); u0=A(1,3); v0=A(2,3); nrows_M=2*n; ncols_M=9; M=zeros(nrows_M,ncols_M); for i=1:n a1=Alph(i,1); a2=Alph(i,2); a3=Alph(i,3); ui=U(i,1); vi=U(i,2); %generate submatrix M M_=[a1*fu, 0, a1*(u0-ui), a2*fu, 0, a2*(u0-ui), a3*fu, 0, a3*(u0-ui); 0, a1*fv, a1*(v0-vi), 0, a2*fv, a2*(v0-vi), 0, a3*fv, a3*(v0-vi)]; %put M_ in the whole matrix row_ini=i*2-1; row_end=i*2; M(row_ini:row_end,:)=M_; end return function [Cc,Xc,sc]=compute_norm_sign_scaling_factor2(X1,Cw,Alph,Xw) n=size(Xw,1); %number of data points %Km will be a scaled solution. In order to find the scale parameter we %impose distance constraints between the reference points %scaled position of the control points in camera coordinates Cc_=zeros(3,3); for i=1:3 Cc_(i,:)=X1(3*i-2:3*i); end %position of reference points in camera coordinates Xc_=Alph*Cc_; %compute distances in world coordinates w.r.t. the centroid centr_w=mean(Xw); centroid_w=repmat(centr_w,[n,1]); tmp1=Xw-centroid_w; dist_w=sqrt(sum(tmp1.^2,2)); %compute distances in camera coordinates w.r.t. the centroid centr_c=mean(Xc_); centroid_c=repmat(centr_c,[n,1]); tmp2=Xc_-centroid_c; dist_c=sqrt(sum(tmp2.^2,2)); %least squares solution for the scale factor sc=1/(inv(dist_c'*dist_c)*dist_c'*dist_w); %scale position of the control points Cc=Cc_/sc; %rescaled position of the reference points Xc=Alph*Cc; %change the sign if necessary. z negative is no possible in camera %coordinates neg_z=find(Xc(:,3)<0); if size(neg_z,1)>=1 sc=-sc; Xc=Xc*(-1); end return function P=compute_constraint_distance_2param(m1,m2) %redefine variables name, for compatibility with maple m1_1=m1(1); m1_2=m1(2); m1_3=m1(3); m1_4=m1(4); m1_5=m1(5); m1_6=m1(6); m1_7=m1(7); m1_8=m1(8); m1_9=m1(9); m2_1=m2(1); m2_2=m2(2); m2_3=m2(3); m2_4=m2(4); m2_5=m2(5); m2_6=m2(6); m2_7=m2(7); m2_8=m2(8); m2_9=m2(9); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t7 = (m1_6 ^ 2); t8 = (m1_4 ^ 2); t9 = (m1_1 ^ 2); t10 = (m1_5 ^ 2); t11 = (m1_2 ^ 2); t12 = (m1_3 ^ 2); t17 = m1_4 * m2_4; t18 = m1_1 * m2_1; t19 = m1_5 * m2_5; t22 = m1_2 * m2_2; t23 = m1_6 * m2_6; t25 = m1_3 * m2_3; t26 = (-m2_6 * m1_3 - m1_4 * m2_1 - m2_4 * m1_1 + t17 + t18 + t19 - m1_5 * m2_2 - m2_5 * m1_2 + t22 + t23 - m1_6 * m2_3 + t25); t29 = (m2_3 ^ 2); t34 = (m2_4 ^ 2); t35 = (m2_1 ^ 2); t36 = (m2_5 ^ 2); t37 = (m2_2 ^ 2); t38 = (m2_6 ^ 2); t44 = (m1_7 ^ 2); t45 = (m1_8 ^ 2); t46 = (m1_9 ^ 2); t55 = m1_8 * m2_8; t56 = m1_9 * m2_9; t58 = m1_7 * m2_7; t59 = (-m1_9 * m2_3 - m2_8 * m1_2 - m2_9 * m1_3 - m1_7 * m2_1 - m2_7 * m1_1 + t55 + t22 + t56 + t18 - m1_8 * m2_2 + t25 + t58); t64 = (m2_8 ^ 2); t65 = (m2_9 ^ 2); t68 = (m2_7 ^ 2); t113 = (-m1_9 * m2_6 - m2_9 * m1_6 + t55 + t23 + t17 + t56 + t58 - m1_7 * m2_4 - m2_7 * m1_4 - m1_8 * m2_5 - m2_8 * m1_5 + t19); P(1,1) = -2 * m1_4 * m1_1 - 2 * m1_5 * m1_2 - 2 * m1_6 * m1_3 + t7 + t8 + t9 + t10 + t11 + t12; P(1,2) = 2 * t26; P(1,3) = -2 * m2_6 * m2_3 + t29 - 2 * m2_4 * m2_1 - 2 * m2_5 * m2_2 + t34 + t35 + t36 + t37 + t38; P(2,1) = -2 * m1_7 * m1_1 + t12 - 2 * m1_9 * m1_3 + t44 + t45 + t46 - 2 * m1_8 * m1_2 + t9 + t11; P(2,2) = 2 * t59; P(2,3) = -2 * m2_8 * m2_2 - 2 * m2_9 * m2_3 + t64 + t65 - 2 * m2_7 * m2_1 + t29 + t68 + t37 + t35; P(3,1) = -2 * m1_9 * m1_6 + t8 + t10 + t7 - 2 * m1_7 * m1_4 + t44 + t45 + t46 - 2 * m1_8 * m1_5; P(3,2) = 2 * t113; P(3,3) = -2 * m2_9 * m2_6 + t68 + t64 - 2 * m2_7 * m2_4 - 2 * m2_8 * m2_5 + t34 + t36 + t38 + t65; return function P=compute_constraint_distance_3param(m1,m2,m3) %redefine variables name, for compatibility with maple m1_1=m1(1); m1_2=m1(2); m1_3=m1(3); m1_4=m1(4); m1_5=m1(5); m1_6=m1(6); m1_10=m1(7); m1_11=m1(8); m1_12=m1(9); m2_1=m2(1); m2_2=m2(2); m2_3=m2(3); m2_4=m2(4); m2_5=m2(5); m2_6=m2(6); m2_10=m2(7); m2_11=m2(8); m2_12=m2(9); m3_1=m3(1); m3_2=m3(2); m3_3=m3(3); m3_4=m3(4); m3_5=m3(5); m3_6=m3(6); m3_10=m3(7); m3_11=m3(8); m3_12=m3(9); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t1 = (m1_2 ^ 2); t4 = (m1_6 ^ 2); t5 = (m1_3 ^ 2); t6 = (m1_5 ^ 2); t11 = (m1_4 ^ 2); t12 = (m1_1 ^ 2); t20 = m1_4 * m2_4; t21 = m1_3 * m2_3; t22 = m1_5 * m2_5; t23 = m1_2 * m2_2; t24 = m1_6 * m2_6; t25 = m1_1 * m2_1; t26 = (-m2_4 * m1_1 - m2_5 * m1_2 - m2_6 * m1_3 - m1_6 * m2_3 - m1_4 * m2_1 - m1_5 * m2_2 + t20 + t21 + t22 + t23 + t24 + t25); t27 = m1_6 * m3_6; t29 = m1_5 * m3_5; t30 = m1_4 * m3_4; t33 = m1_3 * m3_3; t35 = m1_1 * m3_1; t38 = m1_2 * m3_2; t39 = (t27 - m1_6 * m3_3 + t29 + t30 - m1_4 * m3_1 - m3_6 * m1_3 + t33 - m3_5 * m1_2 + t35 - m3_4 * m1_1 - m1_5 * m3_2 + t38); t40 = (m2_4 ^ 2); t41 = (m2_2 ^ 2); t42 = (m2_5 ^ 2); t43 = (m2_1 ^ 2); t44 = (m2_6 ^ 2); t45 = (m2_3 ^ 2); t53 = m2_4 * m3_4; t56 = m2_5 * m3_5; t57 = m2_2 * m3_2; t60 = m2_1 * m3_1; t62 = m2_6 * m3_6; t63 = m2_3 * m3_3; t65 = (t53 - m2_4 * m3_1 - m3_4 * m2_1 + t56 + t57 - m2_5 * m3_2 - m2_6 * m3_3 + t60 - m3_6 * m2_3 + t62 + t63 - m3_5 * m2_2); t66 = (m3_5 ^ 2); t69 = (m3_4 ^ 2); t70 = (m3_3 ^ 2); t71 = (m3_2 ^ 2); t72 = (m3_6 ^ 2); t75 = (m3_1 ^ 2); t141 = (m1_10 ^ 2); t142 = (m1_11 ^ 2); t143 = (m1_12 ^ 2); t151 = m1_10 * m2_10; t152 = m1_12 * m2_12; t154 = m1_11 * m2_11; t158 = (-m2_10 * m1_1 - m2_12 * m1_3 + t151 + t23 + t25 + t152 + t21 - m1_10 * m2_1 + t154 - m1_11 * m2_2 - m2_11 * m1_2 - m1_12 * m2_3); t160 = m1_12 * m3_12; t164 = m1_10 * m3_10; t165 = m1_11 * m3_11; t168 = (-m3_10 * m1_1 + t160 - m3_11 * m1_2 + t38 + t33 - m1_12 * m3_3 - m3_12 * m1_3 + t164 + t35 + t165 - m1_11 * m3_2 - m1_10 * m3_1); t169 = (m2_12 ^ 2); t170 = (m2_10 ^ 2); t171 = (m2_11 ^ 2); t179 = m2_10 * m3_10; t181 = m2_12 * m3_12; t185 = m2_11 * m3_11; t188 = (t57 + t60 + t179 - m2_10 * m3_1 + t181 - m2_12 * m3_3 - m3_12 * m2_3 - m3_10 * m2_1 + t63 + t185 - m2_11 * m3_2 - m3_11 * m2_2); t191 = (m3_12 ^ 2); t192 = (m3_10 ^ 2); t193 = (m3_11 ^ 2); t254 = (-m2_11 * m1_5 + t154 + t151 - m1_12 * m2_6 + t20 - m1_10 * m2_4 - m2_12 * m1_6 - m2_10 * m1_4 - m1_11 * m2_5 + t152 + t24 + t22); t261 = (t30 - m3_12 * m1_6 - m1_10 * m3_4 - m1_11 * m3_5 + t160 + t27 + t164 + t165 - m3_11 * m1_5 - m3_10 * m1_4 - m1_12 * m3_6 + t29); t275 = (-m3_10 * m2_4 + t56 - m2_10 * m3_4 + t62 - m3_12 * m2_6 - m2_11 * m3_5 + t53 - m3_11 * m2_5 - m2_12 * m3_6 + t179 + t181 + t185); % 12 P(1,1) = t1 - 2 * m1_4 * m1_1 + t4 + t5 + t6 - 2 * m1_5 * m1_2 - 2 * m1_6 * m1_3 + t11 + t12; P(1,2) = 2 * t26; P(1,3) = 2 * t39; P(1,4) = t40 + t41 + t42 + t43 + t44 + t45 - 2 * m2_5 * m2_2 - 2 * m2_6 * m2_3 - 2 * m2_4 * m2_1; P(1,5) = 2 * t65; P(1,6) = t66 - 2 * m3_4 * m3_1 + t69 + t70 + t71 + t72 - 2 * m3_6 * m3_3 + t75 - 2 * m3_5 * m3_2; % 14 P(2,1) = -2 * m1_11 * m1_2 + t141 + t142 + t12 + t1 + t5 + t143 - 2 * m1_10 * m1_1 - 2 * m1_12 * m1_3; P(2,2) = 2 * t158; P(2,3) = 2 * t168; P(2,4) = t169 + t41 + t43 + t45 + t170 + t171 - 2 * m2_12 * m2_3 - 2 * m2_10 * m2_1 - 2 * m2_11 * m2_2; P(2,5) = 2 * t188; P(2,6) = t71 - 2 * m3_12 * m3_3 + t75 + t191 + t70 + t192 + t193 - 2 * m3_10 * m3_1 - 2 * m3_11 * m3_2; % 24 P(3,1) = t4 + t143 + t11 - 2 * m1_12 * m1_6 - 2 * m1_11 * m1_5 - 2 * m1_10 * m1_4 + t6 + t141 + t142; P(3,2) = 2 * t254; P(3,3) = 2 * t261; P(3,4) = t170 + t171 + t169 - 2 * m2_10 * m2_4 - 2 * m2_11 * m2_5 - 2 * m2_12 * m2_6 + t40 + t42 + t44; P(3,5) = 2 * t275; P(3,6) = t69 + t66 + t72 - 2 * m3_12 * m3_6 - 2 * m3_10 * m3_4 + t193 - 2 * m3_11 * m3_5 + t192 + t191; return function dsq=define_distances_btw_control_points2() %relative coordinates of the control points c1=[1,0,0]; c2=[0,1,0]; c3=[0,0,0]; d12=(c1(1)-c2(1))^2 + (c1(2)-c2(2))^2 + (c1(3)-c2(3))^2; d13=(c1(1)-c3(1))^2 + (c1(2)-c3(2))^2 + (c1(3)-c3(3))^2; d23=(c2(1)-c3(1))^2 + (c2(2)-c3(2))^2 + (c2(3)-c3(3))^2; dsq=[d12,d13,d23]'; return function K=compute_permutation_constraint3(V) %[B11,B12,...,B33]=lambda1*v1+lambda2*v2+lambda3*v3 N=size(V,2); %dimension of the kernel n=3; %dimension of Bij idx=[1 2 3; 2 4 5; 3 5 6]; %1.-Generation of the first set of equations Bii.Bjj=Bij.Bii (n(n-1)/2 eqs). nrowsK=n*(n-1)/2+n*(n-1)*n/2; ncolsK=N*(N+1)/2; K=zeros(nrowsK,ncolsK); t=1; for i=1:n for j=i+1:n offset=1; for a=1:N for b=a:N if a==b K(t,offset)=V(idx(i,i),a)*V(idx(j,j),a)-V(idx(i,j),a)*V(idx(i,j),a); else K(t,offset)=V(idx(i,i),a)*V(idx(j,j),b)-V(idx(i,j),a)*V(idx(i,j),b)+... V(idx(i,i),b)*V(idx(j,j),a)-V(idx(i,j),b)*V(idx(i,j),a); end offset=offset+1; end end t=t+1; %fprintf('t:%d\t offset:%d\n',t,offset); end end for k=1:n for j=k:n for i=1:n if (i~=j & i~=k) offset=1; for a=1:N for b=a:N if a==b K(t,offset)=V(idx(i,j),a)*V(idx(i,k),a)-V(idx(i,i),a)*V(idx(j,k),a); else K(t,offset)=V(idx(i,j),a)*V(idx(i,k),b)-V(idx(i,i),a)*V(idx(j,k),b)+... V(idx(i,j),b)*V(idx(i,k),a)-V(idx(i,i),b)*V(idx(j,k),a); end offset=offset+1; end end t=t+1; %fprintf('t:%d\t offset:%d\n',t,offset); end end end end return
github
urbste/MLPnP_matlab_toolbox-master
DLT.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/func/DLT.m
869
utf_8
e7e82eec467a5e8a90e71822b1b2b150
function [R,t]= DLT(XXw,xx) n= size(xx,2); D= zeros(n*2,12); for i= 1:n xi= XXw(1,i); yi= XXw(2,i); zi= XXw(3,i); ui= xx(1,i); vi= xx(2,i); D_= [xi yi zi 0 0 0 -ui*xi -ui*yi -ui*zi 1 0 -ui; 0 0 0 xi yi zi -vi*xi -vi*yi -vi*zi 0 1 -vi]; D(i*2-1:i*2,:)= D_; end DD= D.'*D; [V,D]= eig(DD); v= V(:,1); v= v/norm(v(7:9)); v= v*sign(v(12)); R= reshape(v(1:9),3,3).'; t= v(10:12); XXc= R*XXw+repmat(t,1,size(XXw,2)); [R,t]= calcampose(XXc,XXw); return function [R2,t2] = calcampose(XXc,XXw) n= length(XXc); X= XXw; Y= XXc; K= eye(n)-ones(n,n)/n; ux= mean(X,2); uy= mean(Y,2); sigmx2= mean(sum((X*K).^2)); SXY= Y*K*(X')/n; [U, D, V]= svd(SXY); S= eye(3); if det(SXY) < 0 S(3,3)= -1; end R2= U*S*(V'); c2= trace(D*S)/sigmx2; t2= uy-c2*R2*ux; X= R2(:,1); Y= R2(:,2); Z= R2(:,3); if norm(cross(X,Y)-Z) > 2e-2 R2(:,3)= -Z; end return
github
urbste/MLPnP_matlab_toolbox-master
cal_pose_err.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/func/cal_pose_err.m
1,343
utf_8
f555995b9635b9706e34c45d50f70da2
function [y y1]= cal_pose_err(T1, T2) R1= T1(1:3,1:3); R2= T2(1:3,1:3); X1= R1(:,1); X2= R2(:,1); Y1= R1(:,2); Y2= R2(:,2); Z1= R1(:,3); Z2= R2(:,3); exyz= [X1'*X2 Y1'*Y2 Z1'*Z2]; exyz(exyz>1)= 1; exyz(exyz<-1)= -1; y(1)= max(abs(acos(exyz)))*180/pi; q1 = Matrix2Quaternion(R1); q2 = Matrix2Quaternion(R2); y1(1) = norm(q1-q2)/norm(q2)*100; if isnan(y(1)) txt; end y(2)= norm(T1(1:3,4)-T2(1:3,4))/norm(T2(1:3,4))*100; y1(2) = y(2); y= abs(y); end function Q = Matrix2Quaternion(R) % Solve (R-I)v = 0; [v,d] = eig(R-eye(3)); % The following code assumes the eigenvalues returned are not necessarily % sorted by size. This may be overcautious on my part. d = diag(abs(d)); % Extract eigenvalues [s, ind] = sort(d); % Find index of smallest one if d(ind(1)) > 0.001 % Hopefully it is close to 0 warning('Rotation matrix is dubious'); end axis = v(:,ind(1)); % Extract appropriate eigenvector if abs(norm(axis) - 1) > .0001 % Debug warning('non unit rotation axis'); end % Now determine the rotation angle twocostheta = trace(R)-1; twosinthetav = [R(3,2)-R(2,3), R(1,3)-R(3,1), R(2,1)-R(1,2)]'; twosintheta = axis'*twosinthetav; theta = atan2(twosintheta, twocostheta); Q = [cos(theta/2); axis*sin(theta/2)]; end
github
urbste/MLPnP_matlab_toolbox-master
RPnP.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/func/RPnP.m
6,404
utf_8
261f910a5e9c5c9c5f727ff7c32a41d8
function [R t]= RPnP(XX,xx) R= []; t= []; n= length(xx); XXw= XX; xxv= [xx; ones(1,n)]; for i=1:n xxv(:,i)= xxv(:,i)/norm(xxv(:,i)); end % selecting an edge $P_{i1}P_{i2}$ by n random sampling i1= 1; i2= 2; lmin= xxv(1,i1)*xxv(1,i2)+xxv(2,i1)*xxv(2,i2)+xxv(3,i1)*xxv(3,i2); rij= ceil(rand(n,2)*n); for ii= 1:n i= rij(ii,1); j= rij(ii,2); if i == j continue; end l= xxv(1,i)*xxv(1,j)+xxv(2,i)*xxv(2,j)+xxv(3,i)*xxv(3,j); if l < lmin i1= i; i2= j; lmin= l; end end % calculating the rotation matrix of $O_aX_aY_aZ_a$. p1= XX(:,i1); p2= XX(:,i2); p0= (p1+p2)/2; x= p2-p0; x= x/norm(x); if abs([0 1 0]*x) < abs([0 0 1]*x) z= xcross(x,[0; 1; 0]); z= z/norm(z); y= xcross(z, x); y= y/norm(y); else y= xcross([0; 0; 1], x); y= y/norm(y); z= xcross(x,y); z= z/norm(z); end Ro= [x y z]; % transforming the reference points form orignial object space % to the new coordinate frame $O_aX_aY_aZ_a$. XX= Ro.'*(XX-repmat(p0,1,n)); % Dividing the n-point set into (n-2) 3-point subsets % and setting up the P3P equations v1= xxv(:,i1); v2= xxv(:,i2); cg1= v1.'*v2; sg1= sqrt(1-cg1^2); D1= norm(XX(:,i1)-XX(:,i2)); D4= zeros(n-2,5); if 0 % determining F', the deviation of the cost function. j= 0; for i= 1:n if i == i1 || i == i2 continue; end j= j+1; vi= xxv(:,i); cg2= v1.'*vi; cg3= v2.'*vi; sg2= sqrt(1-cg2^2); D2= norm(XX(:,i1)-XX(:,i)); D3= norm(XX(:,i)-XX(:,i2)); % get the coefficients of the P3P equation from each subset. D4(j,:)= getp3p(cg1,cg2,cg3,sg1,sg2,D1,D2,D3); end % get the 7th order polynomial, the deviation of the cost function. D7= zeros(1,8); for i= 1:n-2 D7= D7+ getpoly7(D4(i,:)); end else % ======================================================================= % following code is the same as the code above (between "if 0" and "else") % but the following code is a little more efficient than the former % in matlab when the number of points is large, % because the dot multiply operation is used. idx= true(1,n); idx([i1 i2])= false; vi= xxv(:,idx); cg2= vi.'*v1; cg3= vi.'*v2; sg2= sqrt(1-cg2.^2); D2= cg2; D3= cg2; didx= find(idx); for i= 1:n-2 D2(i)= norm(XX(:,i1)-XX(:,didx(i))); D3(i)= norm(XX(:,didx(i))-XX(:,i2)); end A1= (D2./D1).^2; A2= A1*sg1^2-sg2.^2; A3= cg2.*cg3-cg1; A4= cg1*cg3-cg2; A6= (D3.^2-D1^2-D2.^2)./(2*D1^2); A7= 1-cg1^2-cg2.^2+cg1*cg2.*cg3+A6.*sg1^2; D4= [A6.^2-A1.*cg3.^2, 2*(A3.*A6-A1.*A4.*cg3),... A3.^2+2*A6.*A7-A1.*A4.^2-A2.*cg3.^2,... 2*(A3.*A7-A2.*A4.*cg3), A7.^2-A2.*A4.^2]; F7= [4*D4(:,1).^2,... 7*D4(:,2).*D4(:,1),... 6*D4(:,3).*D4(:,1)+3*D4(:,2).^2,... 5*D4(:,4).*D4(:,1)+5*D4(:,3).*D4(:,2),... 4*D4(:,5).*D4(:,1)+4*D4(:,4).*D4(:,2)+2*D4(:,3).^2,... 3*D4(:,5).*D4(:,2)+3*D4(:,4).*D4(:,3),... 2*D4(:,5).*D4(:,3)+D4(:,4).^2,... D4(:,5).*D4(:,4)]; D7= sum(F7); end % retriving the local minima of the cost function. try % try catch added by Luis Ferraz t2s= roots(D7); maxreal= max(abs(real(t2s))); t2s(abs(imag(t2s))/maxreal > 0.001)= []; t2s= real(t2s); D6= (7:-1:1).*D7(1:7); F6= polyval(D6,t2s); t2s(F6 <= 0)= []; if isempty(t2s) %fprintf('no solution!\n'); return end catch %fprintf('no solution!\n'); return end % calculating the camera pose from each local minimum. m= length(t2s); for i= 1:m t2= t2s(i); % calculating the rotation matrix d2= cg1+t2; x= v2*d2- v1; x= x/norm(x); if abs([0 1 0]*x) < abs([0 0 1]*x) z= xcross(x,[0; 1; 0]); z= z/norm(z); y= xcross(z, x); y= y/norm(y); else y= xcross([0; 0; 1], x); y= y/norm(y); z= xcross(x,y); z= z/norm(z); end Rx= [x y z]; % calculating c, s, tx, ty, tz D= zeros(2*n,6); r= Rx.'; for j= 1:n ui= xx(1,j); vi= xx(2,j); xi= XX(1,j); yi= XX(2,j); zi= XX(3,j); D(2*j-1,:)= [-r(2)*yi+ui*(r(8)*yi+r(9)*zi)-r(3)*zi, ... -r(3)*yi+ui*(r(9)*yi-r(8)*zi)+r(2)*zi, ... -1, 0, ui, ui*r(7)*xi-r(1)*xi]; D(2*j, :)= [-r(5)*yi+vi*(r(8)*yi+r(9)*zi)-r(6)*zi, ... -r(6)*yi+vi*(r(9)*yi-r(8)*zi)+r(5)*zi, ... 0, -1, vi, vi*r(7)*xi-r(4)*xi]; end DTD= D.'*D; [V D]= eig(DTD); V1= V(:,1); V1= V1/V1(end); c= V1(1); s= V1(2); t= V1(3:5); % calculating the camera pose by 3d alignment xi= XX(1,:); yi= XX(2,:); zi= XX(3,:); XXcs= [r(1)*xi+(r(2)*c+r(3)*s)*yi+(-r(2)*s+r(3)*c)*zi+t(1); r(4)*xi+(r(5)*c+r(6)*s)*yi+(-r(5)*s+r(6)*c)*zi+t(2); r(7)*xi+(r(8)*c+r(9)*s)*yi+(-r(8)*s+r(9)*c)*zi+t(3)]; XXc= zeros(size(XXcs)); for j= 1:n XXc(:,j)= xxv(:,j)*norm(XXcs(:,j)); end [R t]= calcampose(XXc,XXw); % calculating the reprojection error XXc= R*XXw+t*ones(1,n); xxc= [XXc(1,:)./XXc(3,:); XXc(2,:)./XXc(3,:)]; %r= mean(sqrt(sum((xxc-xx).^2))); r = norm(xxc-xx,'fro')/n; res{i}.R= R; res{i}.t= t; res{i}.r= r; end % determing the camera pose with the smallest reprojection error. minr= inf; for i= 1:m if res{i}.r < minr minr= res{i}.r; R= res{i}.R; t= res{i}.t; end end return function B = getp3p(l1,l2,A5,C1,C2,D1,D2,D3) A1= (D2/D1)^2; A2= A1*C1^2-C2^2; A3= l2*A5-l1; A4= l1*A5-l2; A6= (D3^2-D1^2-D2^2)/(2*D1^2); A7= 1-l1^2-l2^2+l1*l2*A5+A6*C1^2; B= [A6^2-A1*A5^2, 2*(A3*A6-A1*A4*A5), A3^2+2*A6*A7-A1*A4^2-A2*A5^2,... 2*(A3*A7-A2*A4*A5), A7^2-A2*A4^2]; return function F7= getpoly7(F) F7= [4*F(1)^2; 7*F(2)*F(1); 6*F(3)*F(1)+3*F(2)^2; 5*F(4)*F(1)+5*F(3)*F(2); 4*F(5)*F(1)+4*F(4)*F(2)+2*F(3)^2; 3*F(5)*F(2)+3*F(4)*F(3); 2*F(5)*F(3)+F(4)^2; F(5)*F(4)].'; return function [R2,t2] = calcampose(XXc,XXw) n= length(XXc); X= XXw; Y= XXc; K= eye(n)-ones(n,n)/n; ux= mean(X,2); uy= mean(Y,2); sigmx2= mean(sum((X*K).^2)); SXY= Y*K*(X')/n; [U, D, V]= svd(SXY); S= eye(3); if det(SXY) < 0 S(3,3)= -1; end R2= U*S*(V'); c2= trace(D*S)/sigmx2; t2= uy-c2*R2*ux; X= R2(:,1); Y= R2(:,2); Z= R2(:,3); if norm(xcross(X,Y)-Z) > 2e-2 R2(:,3)= -Z; end return function c = xcross(a,b) c = [a(2)*b(3)-a(3)*b(2); a(3)*b(1)-a(1)*b(3); a(1)*b(2)-a(2)*b(1)]; return
github
urbste/MLPnP_matlab_toolbox-master
RPnP2.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/func/RPnP2.m
6,250
utf_8
aea150b9d6f873d63b1824dcddcc73a6
function [R t]= RPnP2(XX,xx) R= []; t= []; n= length(xx); XXw= XX; xxv= [xx; ones(1,n)]; for i=1:n xxv(:,i)= xxv(:,i)/norm(xxv(:,i)); end % selecting an edge $P_{i1}P_{i2}$ whose projection length % is the longest in image plane. lmin= inf; i1= 0; i2= 0; for i= 1:n-1 for j= i+1:n l= xxv(1,i)*xxv(1,j)+xxv(2,i)*xxv(2,j)+xxv(3,i)*xxv(3,j); if l < lmin i1= i; i2= j; lmin= l; end end end % calculating the rotation matrix of $O_aX_aY_aZ_a$. p1= XX(:,i1); p2= XX(:,i2); p0= (p1+p2)/2; x= p2-p0; x= x/norm(x); if abs([0 1 0]*x) < abs([0 0 1]*x) z= xcross(x,[0; 1; 0]); z= z/norm(z); y= xcross(z, x); y= y/norm(y); else y= xcross([0; 0; 1], x); y= y/norm(y); z= xcross(x,y); z= z/norm(z); end Ro= [x y z]; % transforming the reference points form orignial object space % to the new coordinate frame $O_aX_aY_aZ_a$. XX= Ro.'*(XX-repmat(p0,1,n)); % Dividing the n-point set into (n-2) 3-point subsets % and setting up the P3P equations v1= xxv(:,i1); v2= xxv(:,i2); cg1= v1.'*v2; sg1= sqrt(1-cg1^2); D1= norm(XX(:,i1)-XX(:,i2)); D4= zeros(n-2,5); if 0 % determining F', the deviation of the cost function. j= 0; for i= 1:n if i == i1 || i == i2 continue; end j= j+1; vi= xxv(:,i); cg2= v1.'*vi; cg3= v2.'*vi; sg2= sqrt(1-cg2^2); D2= norm(XX(:,i1)-XX(:,i)); D3= norm(XX(:,i)-XX(:,i2)); % get the coefficients of the P3P equation from each subset. D4(j,:)= getp3p(cg1,cg2,cg3,sg1,sg2,D1,D2,D3); end % get the 7th order polynomial, the deviation of the cost function. D7= zeros(1,8); for i= 1:n-2 D7= D7+ getpoly7(D4(i,:)); end else % ======================================================================= % following code is the same as the code above (between "if 0" and "else") % but the following code is a little more efficient than the former % in matlab when the number of points is large, % because the dot multiply operation is used. idx= true(1,n); idx([i1 i2])= false; vi= xxv(:,idx); cg2= vi.'*v1; cg3= vi.'*v2; sg2= sqrt(1-cg2.^2); D2= cg2; D3= cg2; didx= find(idx); for i= 1:n-2 D2(i)= norm(XX(:,i1)-XX(:,didx(i))); D3(i)= norm(XX(:,didx(i))-XX(:,i2)); end A1= (D2./D1).^2; A2= A1*sg1^2-sg2.^2; A3= cg2.*cg3-cg1; A4= cg1*cg3-cg2; A6= (D3.^2-D1^2-D2.^2)./(2*D1^2); A7= 1-cg1^2-cg2.^2+cg1*cg2.*cg3+A6.*sg1^2; D4= [A6.^2-A1.*cg3.^2, 2*(A3.*A6-A1.*A4.*cg3),... A3.^2+2*A6.*A7-A1.*A4.^2-A2.*cg3.^2,... 2*(A3.*A7-A2.*A4.*cg3), A7.^2-A2.*A4.^2]; F7= [4*D4(:,1).^2,... 7*D4(:,2).*D4(:,1),... 6*D4(:,3).*D4(:,1)+3*D4(:,2).^2,... 5*D4(:,4).*D4(:,1)+5*D4(:,3).*D4(:,2),... 4*D4(:,5).*D4(:,1)+4*D4(:,4).*D4(:,2)+2*D4(:,3).^2,... 3*D4(:,5).*D4(:,2)+3*D4(:,4).*D4(:,3),... 2*D4(:,5).*D4(:,3)+D4(:,4).^2,... D4(:,5).*D4(:,4)]; D7= sum(F7); end % retriving the local minima of the cost function. t2s= roots(D7); maxreal= max(abs(real(t2s))); t2s(abs(imag(t2s))/maxreal > 0.001)= []; t2s= real(t2s); D6= (7:-1:1).*D7(1:7); F6= polyval(D6,t2s); t2s(F6 <= 0)= []; if isempty(t2s) fprintf('no solution!\n'); return end % calculating the camera pose from each local minimum. m= length(t2s); for i= 1:m t2= t2s(i); % calculating the rotation matrix d2= cg1+t2; x= v2*d2- v1; x= x/norm(x); if abs([0 1 0]*x) < abs([0 0 1]*x) z= xcross(x,[0; 1; 0]); z= z/norm(z); y= xcross(z, x); y= y/norm(y); else y= xcross([0; 0; 1], x); y= y/norm(y); z= xcross(x,y); z= z/norm(z); end Rx= [x y z]; % calculating c, s, tx, ty, tz D= zeros(2*n,6); r= Rx.'; for j= 1:n ui= xx(1,j); vi= xx(2,j); xi= XX(1,j); yi= XX(2,j); zi= XX(3,j); D(2*j-1,:)= [-r(2)*yi+ui*(r(8)*yi+r(9)*zi)-r(3)*zi, ... -r(3)*yi+ui*(r(9)*yi-r(8)*zi)+r(2)*zi, ... -1, 0, ui, ui*r(7)*xi-r(1)*xi]; D(2*j, :)= [-r(5)*yi+vi*(r(8)*yi+r(9)*zi)-r(6)*zi, ... -r(6)*yi+vi*(r(9)*yi-r(8)*zi)+r(5)*zi, ... 0, -1, vi, vi*r(7)*xi-r(4)*xi]; end DTD= D.'*D; [V D]= eig(DTD); V1= V(:,1); V1= V1/V1(end); c= V1(1); s= V1(2); t= V1(3:5); % calculating the camera pose by 3d alignment xi= XX(1,:); yi= XX(2,:); zi= XX(3,:); XXcs= [r(1)*xi+(r(2)*c+r(3)*s)*yi+(-r(2)*s+r(3)*c)*zi+t(1); r(4)*xi+(r(5)*c+r(6)*s)*yi+(-r(5)*s+r(6)*c)*zi+t(2); r(7)*xi+(r(8)*c+r(9)*s)*yi+(-r(8)*s+r(9)*c)*zi+t(3)]; XXc= zeros(size(XXcs)); for j= 1:n XXc(:,j)= xxv(:,j)*norm(XXcs(:,j)); end [R t]= calcampose(XXc,XXw); % calculating the reprojection error XXc= R*XXw+t*ones(1,n); xxc= [XXc(1,:)./XXc(3,:); XXc(2,:)./XXc(3,:)]; r= mean(sqrt(sum((xxc-xx).^2))); res{i}.R= R; res{i}.t= t; res{i}.r= r; end % determing the camera pose with the smallest reprojection error. minr= inf; for i= 1:m if res{i}.r < minr minr= res{i}.r; R= res{i}.R; t= res{i}.t; end end return function B = getp3p(l1,l2,A5,C1,C2,D1,D2,D3) A1= (D2/D1)^2; A2= A1*C1^2-C2^2; A3= l2*A5-l1; A4= l1*A5-l2; A6= (D3^2-D1^2-D2^2)/(2*D1^2); A7= 1-l1^2-l2^2+l1*l2*A5+A6*C1^2; B= [A6^2-A1*A5^2, 2*(A3*A6-A1*A4*A5), A3^2+2*A6*A7-A1*A4^2-A2*A5^2,... 2*(A3*A7-A2*A4*A5), A7^2-A2*A4^2]; return function F7= getpoly7(F) F7= [4*F(1)^2; 7*F(2)*F(1); 6*F(3)*F(1)+3*F(2)^2; 5*F(4)*F(1)+5*F(3)*F(2); 4*F(5)*F(1)+4*F(4)*F(2)+2*F(3)^2; 3*F(5)*F(2)+3*F(4)*F(3); 2*F(5)*F(3)+F(4)^2; F(5)*F(4)].'; return function [R2,t2] = calcampose(XXc,XXw) n= length(XXc); X= XXw; Y= XXc; K= eye(n)-ones(n,n)/n; ux= mean(X,2); uy= mean(Y,2); sigmx2= mean(sum((X*K).^2)); SXY= Y*K*(X')/n; [U, D, V]= svd(SXY); S= eye(3); if det(SXY) < 0 S(3,3)= -1; end R2= U*S*(V'); c2= trace(D*S)/sigmx2; t2= uy-c2*R2*ux; X= R2(:,1); Y= R2(:,2); Z= R2(:,3); if norm(xcross(X,Y)-Z) > 2e-2 R2(:,3)= -Z; end return function c = xcross(a,b) c = [a(2)*b(3)-a(3)*b(2); a(3)*b(1)-a(1)*b(3); a(1)*b(2)-a(2)*b(1)]; return
github
urbste/MLPnP_matlab_toolbox-master
RPnP1.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/func/RPnP1.m
6,202
utf_8
188e6135a0b28b2e5758ad1ff4495607
function [R t]= RPnP1(XX,xx) R= []; t= []; n= length(xx); XXw= XX; xxv= [xx; ones(1,n)]; for i=1:n xxv(:,i)= xxv(:,i)/norm(xxv(:,i)); end % selecting an edge $P_{i1}P_{i2}$ randomly i1= 1; i2= 2; lmin= xxv(1,i1)*xxv(1,i2)+xxv(2,i1)*xxv(2,i2)+xxv(3,i1)*xxv(3,i2); i= ceil(rand*n); j= ceil(rand*n); if i ~= j l= xxv(1,i)*xxv(1,j)+xxv(2,i)*xxv(2,j)+xxv(3,i)*xxv(3,j); if l < lmin i1= i; i2= j; end end % calculating the rotation matrix of $O_aX_aY_aZ_a$. p1= XX(:,i1); p2= XX(:,i2); p0= (p1+p2)/2; x= p2-p0; x= x/norm(x); if abs([0 1 0]*x) < abs([0 0 1]*x) z= xcross(x,[0; 1; 0]); z= z/norm(z); y= xcross(z, x); y= y/norm(y); else y= xcross([0; 0; 1], x); y= y/norm(y); z= xcross(x,y); z= z/norm(z); end Ro= [x y z]; % transforming the reference points form orignial object space % to the new coordinate frame $O_aX_aY_aZ_a$. XX= Ro.'*(XX-repmat(p0,1,n)); % Dividing the n-point set into (n-2) 3-point subsets % and setting up the P3P equations v1= xxv(:,i1); v2= xxv(:,i2); cg1= v1.'*v2; sg1= sqrt(1-cg1^2); D1= norm(XX(:,i1)-XX(:,i2)); D4= zeros(n-2,5); if 0 % determining F', the deviation of the cost function. j= 0; for i= 1:n if i == i1 || i == i2 continue; end j= j+1; vi= xxv(:,i); cg2= v1.'*vi; cg3= v2.'*vi; sg2= sqrt(1-cg2^2); D2= norm(XX(:,i1)-XX(:,i)); D3= norm(XX(:,i)-XX(:,i2)); % get the coefficients of the P3P equation from each subset. D4(j,:)= getp3p(cg1,cg2,cg3,sg1,sg2,D1,D2,D3); end % get the 7th order polynomial, the deviation of the cost function. D7= zeros(1,8); for i= 1:n-2 D7= D7+ getpoly7(D4(i,:)); end else % ======================================================================= % following code is the same as the code above (between "if 0" and "else") % but the following code is a little more efficient than the former % in matlab when the number of points is large, % because the dot multiply operation is used. idx= true(1,n); idx([i1 i2])= false; vi= xxv(:,idx); cg2= vi.'*v1; cg3= vi.'*v2; sg2= sqrt(1-cg2.^2); D2= cg2; D3= cg2; didx= find(idx); for i= 1:n-2 D2(i)= norm(XX(:,i1)-XX(:,didx(i))); D3(i)= norm(XX(:,didx(i))-XX(:,i2)); end A1= (D2./D1).^2; A2= A1*sg1^2-sg2.^2; A3= cg2.*cg3-cg1; A4= cg1*cg3-cg2; A6= (D3.^2-D1^2-D2.^2)./(2*D1^2); A7= 1-cg1^2-cg2.^2+cg1*cg2.*cg3+A6.*sg1^2; D4= [A6.^2-A1.*cg3.^2, 2*(A3.*A6-A1.*A4.*cg3),... A3.^2+2*A6.*A7-A1.*A4.^2-A2.*cg3.^2,... 2*(A3.*A7-A2.*A4.*cg3), A7.^2-A2.*A4.^2]; F7= [4*D4(:,1).^2,... 7*D4(:,2).*D4(:,1),... 6*D4(:,3).*D4(:,1)+3*D4(:,2).^2,... 5*D4(:,4).*D4(:,1)+5*D4(:,3).*D4(:,2),... 4*D4(:,5).*D4(:,1)+4*D4(:,4).*D4(:,2)+2*D4(:,3).^2,... 3*D4(:,5).*D4(:,2)+3*D4(:,4).*D4(:,3),... 2*D4(:,5).*D4(:,3)+D4(:,4).^2,... D4(:,5).*D4(:,4)]; D7= sum(F7); end % retriving the local minima of the cost function. t2s= roots(D7); maxreal= max(abs(real(t2s))); t2s(abs(imag(t2s))/maxreal > 0.001)= []; t2s= real(t2s); D6= (7:-1:1).*D7(1:7); F6= polyval(D6,t2s); t2s(F6 <= 0)= []; if isempty(t2s) fprintf('no solution!\n'); return end % calculating the camera pose from each local minimum. m= length(t2s); for i= 1:m t2= t2s(i); % calculating the rotation matrix d2= cg1+t2; x= v2*d2- v1; x= x/norm(x); if abs([0 1 0]*x) < abs([0 0 1]*x) z= xcross(x,[0; 1; 0]); z= z/norm(z); y= xcross(z, x); y= y/norm(y); else y= xcross([0; 0; 1], x); y= y/norm(y); z= xcross(x,y); z= z/norm(z); end Rx= [x y z]; % calculating c, s, tx, ty, tz D= zeros(2*n,6); r= Rx.'; for j= 1:n ui= xx(1,j); vi= xx(2,j); xi= XX(1,j); yi= XX(2,j); zi= XX(3,j); D(2*j-1,:)= [-r(2)*yi+ui*(r(8)*yi+r(9)*zi)-r(3)*zi, ... -r(3)*yi+ui*(r(9)*yi-r(8)*zi)+r(2)*zi, ... -1, 0, ui, ui*r(7)*xi-r(1)*xi]; D(2*j, :)= [-r(5)*yi+vi*(r(8)*yi+r(9)*zi)-r(6)*zi, ... -r(6)*yi+vi*(r(9)*yi-r(8)*zi)+r(5)*zi, ... 0, -1, vi, vi*r(7)*xi-r(4)*xi]; end DTD= D.'*D; [V D]= eig(DTD); V1= V(:,1); V1= V1/V1(end); c= V1(1); s= V1(2); t= V1(3:5); % calculating the camera pose by 3d alignment xi= XX(1,:); yi= XX(2,:); zi= XX(3,:); XXcs= [r(1)*xi+(r(2)*c+r(3)*s)*yi+(-r(2)*s+r(3)*c)*zi+t(1); r(4)*xi+(r(5)*c+r(6)*s)*yi+(-r(5)*s+r(6)*c)*zi+t(2); r(7)*xi+(r(8)*c+r(9)*s)*yi+(-r(8)*s+r(9)*c)*zi+t(3)]; XXc= zeros(size(XXcs)); for j= 1:n XXc(:,j)= xxv(:,j)*norm(XXcs(:,j)); end [R t]= calcampose(XXc,XXw); % calculating the reprojection error XXc= R*XXw+t*ones(1,n); xxc= [XXc(1,:)./XXc(3,:); XXc(2,:)./XXc(3,:)]; r= mean(sqrt(sum((xxc-xx).^2))); res{i}.R= R; res{i}.t= t; res{i}.r= r; end % determing the camera pose with the smallest reprojection error. minr= inf; for i= 1:m if res{i}.r < minr minr= res{i}.r; R= res{i}.R; t= res{i}.t; end end return function B = getp3p(l1,l2,A5,C1,C2,D1,D2,D3) A1= (D2/D1)^2; A2= A1*C1^2-C2^2; A3= l2*A5-l1; A4= l1*A5-l2; A6= (D3^2-D1^2-D2^2)/(2*D1^2); A7= 1-l1^2-l2^2+l1*l2*A5+A6*C1^2; B= [A6^2-A1*A5^2, 2*(A3*A6-A1*A4*A5), A3^2+2*A6*A7-A1*A4^2-A2*A5^2,... 2*(A3*A7-A2*A4*A5), A7^2-A2*A4^2]; return function F7= getpoly7(F) F7= [4*F(1)^2; 7*F(2)*F(1); 6*F(3)*F(1)+3*F(2)^2; 5*F(4)*F(1)+5*F(3)*F(2); 4*F(5)*F(1)+4*F(4)*F(2)+2*F(3)^2; 3*F(5)*F(2)+3*F(4)*F(3); 2*F(5)*F(3)+F(4)^2; F(5)*F(4)].'; return function [R2,t2] = calcampose(XXc,XXw) n= length(XXc); X= XXw; Y= XXc; K= eye(n)-ones(n,n)/n; ux= mean(X,2); uy= mean(Y,2); sigmx2= mean(sum((X*K).^2)); SXY= Y*K*(X')/n; [U, D, V]= svd(SXY); S= eye(3); if det(SXY) < 0 S(3,3)= -1; end R2= U*S*(V'); c2= trace(D*S)/sigmx2; t2= uy-c2*R2*ux; X= R2(:,1); Y= R2(:,2); Z= R2(:,3); if norm(xcross(X,Y)-Z) > 2e-2 R2(:,3)= -Z; end return function c = xcross(a,b) c = [a(2)*b(3)-a(3)*b(2); a(3)*b(1)-a(1)*b(3); a(1)*b(2)-a(2)*b(1)]; return
github
urbste/MLPnP_matlab_toolbox-master
objpose.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/lhm/objpose.m
6,619
utf_8
b9c153a88d0dfe0fc1eb586122344ed3
function [R, t, it, obj_err, img_err] = objpose(P, Qp, options) % OBJPOSE - Object pose estimation % OBJPOSE(P, Qp) compute the pose (exterior orientation) % between the 3D point set P represented in object space % and its projection Qp represented in normalized image % plane. It implements the algorithm described in "Fast % and Globally Convergent Pose Estimation from Video % Images" by Chien-Ping Lu et. al. to appear in IEEE % Transaction on Pattern Analysis and Machine intelligence % % function [R, t, it, obj_err, img_err] = objpose(P, Qp, options) % % INPUTS: % P - 3D point set arranged in a 3xn matrix % Qp - 2D point set arranged in a 2xn matrix % options - a structure specifies certain parameters in the algorithm. % % Field name Parameter Default % % OPTIONS.initR initial guess of rotation none % OPTIONS.tol Convergence tolerance: 1e-5 % abs(new_value-old_value)/old_value<tol % OPTIONS.epsilon lower bound of the objective function 1e-8 % OPTIONS.method 'SVD' use SVD for solving rotation 'QTN' % 'QTN' use quaternion for solving % rotation % OUTPUTS: % R - estimated rotation matrix % t - estimated translation vector % it - number of the iterations taken % obj_err - object-space error associated with the estimate % img_err - image-space error associated with the estimate % TOL = 1E-5; EPSILON = 1E-8; METHOD = 'QTN'; if nargin >= 3 if isfield(options, 'tol') TOL = options.tol; end if isfield(options, 'epsilon') EPSILON = options.epsilon; end if isfield(options, 'method') METHOD = options.method; end end n = size(P,2); % move the origin to the center of P pbar = sum(P,2)/n; for i = 1:n P(:,i) = P(:,i)-pbar; end Q(1:3,n) = 0; for i = 1 : n Q(:,i) = [Qp(:,i);1]; end % compute projection matrices F(1:3,1:3,1:n) = 0; V(1:3) = 0; for i = 1:n V = Q(:,i)/Q(3,i); F(:,:,i) = (V*V.')/(V.'*V); end % compute the matrix factor required to compute t tFactor = inv(eye(3)-sum(F,3)/n)/n; it = 0; if isfield(options, 'initR') % initial guess of rotation is given Ri = options.initR; sum_(1:3,1) = 0; for i = 1:n sum_ = sum_ + (F(:,:,i)-eye(3))*Ri*P(:,i); end ti = tFactor*sum_; % calculate error Qi = xform(P, Ri, ti); old_err = 0; vec(1:3,1) = 0; for i = 1 : n vec = (eye(3)-F(:,:,i))*Qi(:,i); old_err = old_err + dot(vec,vec); end else % no initial guess; use weak-perspective approximation % compute initial pose estimate if 0 Qx= [Q(1,:)./norm(Q); Q(2,:)./norm(Q); ones(1,length(Q))]; Q= Qx; end [Ri, ti, Qi, old_err] = abskernel(P, Q, F, tFactor, METHOD); it = 1; end % compute next pose estimate [Ri, ti, Qi, new_err] = abskernel(P, Qi, F, tFactor, METHOD); it = it + 1; while (abs((old_err-new_err)/old_err) > TOL) & (new_err > EPSILON) old_err = new_err; % compute the optimal estimate of R [Ri, ti, Qi, new_err] = abskernel(P, Qi, F, tFactor, METHOD); it = it + 1; if it > 20 break end end R = Ri; t = ti; obj_err = sqrt(new_err/n); if (nargout >= 5) % calculate image-space error Qproj = xformproj(P, Ri, ti); img_err = 0; vec(1:3,1) = 0; for i = 1:n vec = Qproj(i)-Qp(i); img_err = img_err + dot(vec,vec); end img_err = sqrt(img_err/n); end %% correct possible reflection w.r.t the projection center %if t(3) < 0 %% This is a wrong assumption HERE XXX % R = -R; %% Need to be checked in each iteration !! % t = -t; %end % get back to original refernce frame t = t - Ri*pbar; % end of OBJPOSE function t = estimate_t( R,G,F,P,n ) sum_(1:3,1) = 0; for i = 1:n sum_ = sum_ + F(:,:,i)*R*P(:,i); end t = G*sum_; function [R, t, Qout, err2] = abskernel(P, Q, F, G, method) % ABSKERNEL - Absolute orientation kernel % ABSKERNEL is the function for solving the % intermediate absolute orientation problems % in the inner loop of the OI pose estimation % algorithm % % INPUTS: % P - the reference point set arranged as a 3xn matrix % Q - the point set obtained by transforming P with % some pose estimate (typically the last estimate) % F - the array of projection matrices arranged as % a 3x3xn array % G - a matrix precomputed for calculating t % method - 'SVD' -> use SVD solution for rotation % 'QTN' -> use quaterion solution for rotation % % % OUTPUTS: % R - estimated rotation matrix % t - estimated translation vector % Qout - the point set obtained by transforming P with % newest pose estimate % err2 - sum of squared object-space error associated % with the estimate n = size(P,2); for i = 1:n Q(:,i) = F(:,:,i)*Q(:,i); end % compute P' and Q' pbar = sum(P,2)/n; qbar = sum(Q,2)/n; for i = 1:n P(:,i) = P(:,i)-pbar; Q(:,i) = Q(:,i)-qbar; end if method == 'SVD' % use SVD solution % compute M matrix M(1:3,1:3) = 0; for i = 1:n M = M+P(:,i)*Q(:,i).'; end % calculate SVD of M [U,S,V] = svd(M); % compute rotation matrix R R = V*(U.'); % disp(['det(R)= ' num2str(det(R)) ]); if sign(det(R)) == 1, t = estimate_t( R,G,F,P,n ); if t(3) < 0 , % disp(['t_3 = ' num2str(t(3)) ]); %% we need to invert the t R=-[V(:,1:2) -V(:,3)]*U.'; t = estimate_t( R,G,F,P,n ); % S V U R t end else R=[V(:,1:2) -V(:,3)]*U.'; t = estimate_t( R,G,F,P,n ); if t(3) < 0 , % disp(['t_3 = ' num2str(t(3)) ]); %% we need to invert the t R =- V*(U.'); t = estimate_t( R,G,F,P,n ); end end if det(R) < 0 , % R % kl end if t(3) < 0, % t % kl end elseif method == 'QTN' % use quaternion solution % compute M matrix A(1:4,1:4) = 0; for i = 1:n A = A + qmatQ([1;Q(:,i)]).'*qmatW([1;P(:,i)]); end % Find the largest eigenvalue of A eigs_options.disp = 0; [V,D] = eigs(A, eye(size(A)), 1, 'LM', eigs_options); % compute rotation matrix R from the quaternion that % corresponds to the largest egienvalue of A %% -> this is wrong -> we need to take the largest -> which is no always the first one % kl R = quat2mat(V); sum_(1:3,1) = 0; for i = 1:n sum_ = sum_ + F(:,:,i)*R*P(:,i); end t = G*sum_; end Qout = xform(P, R, t); % calculate error err2 = 0; vec(1:3,1) = 0; for i = 1 : n vec = (eye(3)-F(:,:,i))*Qout(:,i); err2 = err2 + dot(vec,vec); end % end of ABSKERNEL
github
urbste/MLPnP_matlab_toolbox-master
get2ndPose_Exact.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/sp/get2ndPose_Exact.m
1,662
utf_8
279c3611d83fb0b5ae3064d2b6479259
function sol=get2ndPose_Exact(v,P,R,t,DB) %function bet=get2ndPose_Exact(v,P,R,t) % %returns the second pose if a first pose was calulated. % % Author: Gerald Schweighofer [email protected] % Disclaimer: This code comes with no guarantee at all and its author % is not liable for any damage that its utilization may cause. cent=normRv(mean(normRv(v)')'); Rim=GetRotationbyVector([0;0;1],cent); %cent %Rim v_ = Rim*v; cent=normRv(mean(normRv(v_)')'); R_=Rim*R; t_=Rim*t; %R_ %t_ sol=getRfor2ndPose_V_Exact(v_,P,R_,t_,DB); %% de Normalise the Pose for i=1:length(sol), sol(i).R = Rim'*sol(i).R; sol(i).t = Rim'*sol(i).t; end function sol=getRfor2ndPose_V_Exact(v,P,R,t,DB) % gets the exact R with variations in t % %hgenv(R*P+repmat(t,1,size(P,2))) %hgenv(v) RzN=decomposeR(R); R_= R*RzN; %% change model by Rz %hgenv(R*P+repmat(t,1,size(P,2))) %hgenv(v) P_=RzN'*P; %hgenv(R_*P_+repmat(t,1,size(P_,2))) %hgenv(v) %% project into Image with only Ry ang_zyx = rpyAng_X(R_); Ry =rpyMat([0;ang_zyx(2);0]); Rz =rpyMat([0;0;ang_zyx(3)]); %hgenv(Rz*Ry*P_+repmat(t,1,size(P_,2))) %hgenv(v) %v %P_ %t %Rz [bl,Tnew,at]=getRotationY_wrtT(v ,P_,t,DB,Rz); bl = bl ./180*pi; %% we got 2 solutions. YEAH V=[]; for i=1:size(v,2), V(i).V= (v(:,i)*v(:,i)')./(v(:,i)'*v(:,i)); end sol=[]; for j=1:length(bl), sol(j).bl = bl(j); sol(j).at = at(j); Ry = rpyMat([0;bl(j);0]); sol(j).R = Rz*Ry*RzN'; sol(j).t = Tnew(:,j); %test the Error E=0; for i=1:size(v,2), E=E+sum(((eye(3)-V(i).V)*(sol(j).R*P(:,i)+sol(j).t)).^2); end sol(j).E=E; end
github
urbste/MLPnP_matlab_toolbox-master
rpyMat.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/sp/rpyMat.m
685
utf_8
b3324a80385c9ddc0b997a5631ca134d
% Author: Rodrigo Carceroni % Disclaimer: This code comes with no guarantee at all and its author % is not liable for any damage that its utilization may cause. function R = rpyMat (angs) % Return the 3x3 rotation matrix described by a set of Roll, Pitch and Yaw % angles. cosA = cos (angs(3)); sinA = sin (angs(3)); cosB = cos (angs(2)); sinB = sin (angs(2)); cosC = cos (angs(1)); sinC = sin (angs(1)); cosAsinB = cosA .* sinB; sinAsinB = sinA .* sinB; R = [ cosA.*cosB cosAsinB.*sinC-sinA.*cosC cosAsinB.*cosC+sinA.*sinC ; sinA.*cosB sinAsinB.*sinC+cosA.*cosC sinAsinB.*cosC-cosA.*sinC ; -sinB cosB.*sinC cosB.*cosC ];
github
urbste/MLPnP_matlab_toolbox-master
rpp.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/sp/rpp.m
2,232
utf_8
fc5efdb13e8c0ba4978d8a537f6f2113
function [pose,po2]=rpp(model,iprts,opt) %Pose=rpp(model,points) % % Robust Pose from Planar Tragets % Estimates a Pose for a given Planar Target / image Points combination % based on this 1st Solution a second solution is found. % From both Solutions the "better one" (based on the error) is choosen % as the correct one ! % % (For image-sequenzes a more sophisticated approach should be used) % % Author: Gerald Schweighofer [email protected] % Disclaimer: This code comes with no guarantee at all and its author % is not liable for any damage that its utilization may cause. %% test if nargin == 0, model = [ 0.0685 0.6383 0.4558 0.7411 -0.7219 0.7081 0.7061 0.2887 -0.9521 -0.2553 ; 0.4636 0.0159 -0.1010 0.2817 0.6638 0.1582 0.3925 -0.7954 0.6965 -0.7795; 0 0 0 0 0 0 0 0 0 0]; iprts =[ -0.0168 0.0377 0.0277 0.0373 -0.0824 0.0386 0.0317 0.0360 -0.1015 -0.0080; 0.0866 0.1179 0.1233 0.1035 0.0667 0.1102 0.0969 0.1660 0.0622 0.1608; 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000]; end %model 3xn Model Points: planar 3rd row = 0 %ipts 3xn Image Points: 2d (homogen) 3rd row = 1 if nargin <= 2, %% no opt -> use random values. opt.initR=rpyMat(2*pi*(rand(3,1))); end opt.method='SVD'; %% get a first guess of the pose. [Rlu_, tlu_, it1_, obj_err1_, img_err1_] = objpose(model, iprts(1:2,:) , opt); %% get 2nd Pose sol=get2ndPose_Exact(iprts,model,Rlu_,tlu_,0); %% refine with lu for i=1:length(sol), opt.initR = sol(i).R; [Rlu_, tlu_, it1_, obj_err1_, img_err1_] = objpose(model, iprts(1:2,:) , opt); % Rlu_ sol(i).PoseLu.R = Rlu_; sol(i).PoseLu.t = tlu_; sol(i).obj_err = obj_err1_; end % disp(['There are ' num2str(length(sol)) ' Solutions with Error: ' num2str(cat(2,sol.obj_err)) ]); e = [cat(1, sol.obj_err ) [1:length(sol)]' ]; e = sortrows(e,1); pose = sol(e(1,2)).PoseLu; pose.err = sol(e(1,2)).obj_err; if nargout == 2, if size(e,1) > 1, po2 = sol(e(2,2)).PoseLu; po2.err = sol(e(2,2)).obj_err; else po2 = pose; end end
github
urbste/MLPnP_matlab_toolbox-master
rpyAng.m
.m
MLPnP_matlab_toolbox-master/rpnp/code3/sp/rpyAng.m
1,184
utf_8
1ae147340c1474c625e3a56cb5ef871c
% Author: Rodrigo Carceroni % Disclaimer: This code comes with no guarantee at all and its author % is not liable for any damage that its utilization may cause. function angs = rpyAng (R) % Returns a set of Roll, Pitch and Yaw angles that describe a certain 3x3 % transformation matrix. The magnitude of the Pitch angle is constrained % to be not bigger than pi/2. sinB = -R(3,1); cosB = sqrt (R(1,1) .* R(1,1) + R(2,1) .* R(2,1)); if abs (cosB) > 1e-15 sinA = R(2,1) ./ cosB; cosA = R(1,1) ./ cosB; sinC = R(3,2) ./ cosB; cosC = R(3,3) ./ cosB; angs = [atan2(sinC,cosC); atan2(sinB,cosB); atan2(sinA,cosA)]; else sinC = (R(1,2) - R(2,3)) ./ 2; cosC = (R(2,2) + R(1,3)) ./ 2; angs = [atan2(sinC,cosC); pi./2; 0]; if sinB < 0 angs = -angs; end; end; if norm(R-rpyMat(angs)) > 1e-10, disp('rpyMat: Error not correct Solution '); pause end %if norm(R-rpyMat([angs(1);0;0])*rpyMat([0;angs(2);0])*rpyMat([0;0;angs(3)]),'fro') > 1e-10, % disp('rpyMat: Error not correct Solution '); % pause %end %if norm(R-rpyMat([0;0;angs(3)])*rpyMat([0;angs(2);0])*rpyMat([angs(1);0;0]),'fro') > 1e-10, % disp('rpyMat: Error not correct Solution '); % pause %end
github
urbste/MLPnP_matlab_toolbox-master
solver_pfold.m
.m
MLPnP_matlab_toolbox-master/OPnP/solver_pfold.m
8,452
utf_8
7d7065489a779da0b7f8153a045b4a11
function [sols,stats] = solver_pfold(C0,settings) if isfield(settings,'debug') == 0; settings.debug = 0; % compute statistics conditioning etc. much slower end if isfield(settings,'nrun') == 0 settings.nrun = 0; % # of run to find best sub-determinants in p-fold integer solver end if isfield(settings,'old_zplineq') == 0 settings.old_zplineq = 0; % use old zp linear equation solver, ~slower end if isfield(settings,'cutoff_threshold') == 0; settings.cutoff_threshold = 1e12; end if isfield(settings,'full_QR1') == 0; settings.full_QR1 = 0; % 0 : sparse QR on the first part of QR - faster and higher accuracy end if isfield(settings,'real') == 0; settings.real = 0; % only output real solutions end if isfield(settings,'inverter_threshold') == 0 settings.inverter_threshold = 1; % set this to be smaller seem to gain accuracy, but might give large error for cases with large scale differences end debug = settings.debug; C0 = C0(:,settings.reorder); C0 = bsxfun(@rdivide,C0,sqrt(sum(C0.^2,2))); I = settings.I; J = settings.J; mon = settings.mon; % keyboard neq = size(C0,1); nmon = size(mon,2); T = settings.T; T0 = settings.Tid; C1 = C0'; vv = (C1(T)); C=(sparse(settings.II,settings.JJ,vv)); % T = settings.T; % C = zeros(max(I{end}),nmon); % T0 = settings.Tid; % C1 = C0'; % C(T0) = (C1(T)); % C = sparse(C); P = settings.P; % permissible R = settings.R; % reducible E = settings.E; % excessive p = neq; %# of unknonws : assume # of unknown = # of eqs n = nmon; %# of monomials in the template r = settings.dim; %dim of p-fold solutions ind = settings.ind; % monomial indices action_variable * permissibles stats.neq = size(C,1); stats.nmon = size(C,2); % % construct modulo matrix % % reorder ne = length(E); nr = length(R); np = length(P); if debug modstats.n_to_reduce = nr; modstats.n_excessive = ne; end V = [E R P]; C = C(:, [E, R, P]); % eliminate excessive monomials (done by lu in the qr paper. % this is more general) % the row_echelon method was used before, but the qr version is almost % always much faster. if(~isempty(E)) [qq rr ee] = qr(C(:, 1 : length(E))); % CC = sparse(C(:, length(E) + 1 : end)); C2 = [rr qq'*C(:, length(E) + 1 : end)]; kk = abs(rr(1))./abs(diag(rr)) < settings.cutoff_threshold; k = find(diff(kk) == -1); if(isempty(k)) k = length(kk); end else C2 = C; k = 0; end % partition C into R- and P-parts CR = C2(k + 1 : end, ne + 1 : ne + nr); CP = C2(k + 1 : end, end - np + 1 : end); mm = size(CR, 1); nn = size(CR, 2) + size(CP, 2); if(nn - mm > r) error('not enough equations for that solution dimension'); end % eliminate R-monomials (this step is included in the lu factorization % in the paper. qr is slightly slower but more stable). [q2 UR2_0] = qr(full(CR)); CP = q2'*CP; % [LL,UU,PP] = lu(C(:,1:(ne+nr))); % select basis (qr + column pivoting) CP2 = CP(1 : nr, :); CP3 = CP(nr + 1 : end, :); [q3 r3 e] = qr(CP3, 0); CP4 = CP2(:, e(1 : end - r)); CB1 = CP2(:, e(end - r + 1 : end)); UP3 = r3(1 : np - r, 1 : np - r); CB2 = r3(1 : np - r, end - r + 1 : end); if(isempty(CP4)), CP4 = []; end; if(isempty(UP3)), UP3 = []; end; ee = [1 : ne + nr e + ne + nr]; if debug stats.basis = P(e(end-r+1:end)); end V = V(ee); % mon = mon(ee); % % elimination step % Celim = [UR2_0(1 : nr + np - r, :) [CP4; UP3]]; T = - Celim \ [CB1; CB2]; if debug modstats.rankdiff = size(Celim, 2) - rank(Celim); modstats.condition = cond(Celim); end % modulo matrix modM = zeros(r, n); modM(:, end - r + 1 : end) = eye(r); modM(:, ne + 1 : end - r) = T'; e = V; % % save some statistics % if debug stats.n_monomials = nmon; stats.n_eqs = size(C, 1); stats.rank = rank(full(C)); stats.rankdiff = size(C, 2) - stats.rank; stats.inner_rankdiff = modstats.rankdiff; stats.condition = modstats.condition; stats.n_permissible = length(P); % stats.n_to_reduce = modstats.n_to_reduce; % stats.n_excessive = modstats.n_excessive; % stats.reducible_range = [stats.n_excessive + 1, stats.n_monomials]; % stats.reducibles = stats.reducible_range(1) : stats.reducible_range(2); stats.basis = mon(end - r + 1 : end); end % % construct action matrix % % m = construct_actionmatrix(mon, modM, settings.dim, P, x); ind2 = zeros(np,1); ind2(P) = ind; % [nouse,ind2] = ismember(ind2(e(n-r+1:n)),e); ind2 = find_id(e,ind2(e(n-r+1:n))); % ind2 = find_id(e,[ind2(e(n-r+1:n));settings.ids_a1;settings.ids_a3;settings.ids_abc]'); % % ids_vv = ind2(end-12+1:end); % ind2 = ind2(1:end-12); M = zeros(n, r); M(ind2, :) = eye(r); m = modM * M; [vv, dk] = eig(m'); d=diag(dk); %% Extract possible solutions %setup matrix okmon = find(sum(modM,1)~=0); % mon = mon(:,e); % MM = mon(:,okmon)'; %setup vv vv = modM(:,okmon)'*vv; % PRid = e(end-nr-np+1:end); % PRid = PRid(okmon-ne); % ids_abc = find_id(e,settings.ids_abc)'- ne; if strcmp(settings.p_inverter,'all') == 0 && strcmp(settings.p_inverter,'best') == 0 sid = settings.p_inverter; sid_r = 1:p; sid_r(sid)=[]; % [nouse,ids_a13] = ismember([settings.ids_a1(sid),settings.ids_a3(sid)],PRid); ids_a13 = find_id(e,[settings.ids_a1(sid),settings.ids_a3(sid)]) - ne; ids = [ids_a13,ids_abc([sid,sid_r])']; vv1 = sqrt(vv(ids(2),:)./vv(ids(1),:)); constant = vv(ids(1),:)./vv1; if settings.real realid = imag(vv1) == 0; vv1 = vv1(:,realid); constant = constant(realid); else realid = 1:settings.dim; end vv1_ = -vv1; mmid = settings.p_inverter; else % ids_ac2_list = find_id(e,settings.ids_ac2) - ne; ids_a13_list = find_id(e,[settings.ids_a1;settings.ids_a3]) - ne; % ids_a2c_list = find_id(e,[settings.ids_a2c]) - ne; ids_a1 = ids_a13_list(1:4); sols = []; for ii = 1:p ids_a13 = ids_a13_list([ii,p+ii]); sid = ii; sid_rl{ii} = 1:p; sid_rl{ii}(sid)=[]; % ids = [ids_a13]; idsl{ii} = ids; % a3/a1 vv1l{ii} = sqrt(vv(ids(2),:)./vv(ids(1),:)); realid = imag(vv1l{ii}) == 0; vv1rl{ii} = vv1l{ii}(:,realid); constant{ii} = vv(ids(1),:)./vv1l{ii}; fail_flag = isempty(vv1rl{ii}); if ~fail_flag && min(abs(real((vv1l{ii})))) > 1e-7 mm(ii) = min(norm(vv1l{ii})); mx(ii) = max(abs(vv1rl{ii})); else mm(ii) = inf; mx(ii) = 1; end if strcmp(settings.p_inverter,'all') == 1; % % ids_a2c = ids_a2c_list(3*(ii-1)+(1:3)); vv2l{ii} =(vv(ids_a1(sid_rl{ii}),realid)./(ones(3,1)*(constant{ii}(:,realid)))); solsl = [ [vv1rl{ii} -vv1rl{ii}]; [vv2l{ii} -vv2l{ii}] ] ; solsl([sid,sid_rl{ii}],:) = solsl; sols = [sols solsl]; end end if strcmp(settings.p_inverter,'best') == 1 [mme,mmid] = min(mm); [mxe,mxid] = max(mx); % mm if mme < settings.inverter_threshold; [mme,mmid] = max(mm); else % [nouse,mmid] = max(mx); mmid = 1; end % [min(mm) mmid mm] vv1 = vv1l{mmid}; cc = constant{mmid}; if settings.real realid = imag(vv1) == 0; vv1 = vv1(realid); cc = cc(realid); else realid = 1:length(vv1); end vv1_ = -vv1; sid = mmid; sid_r = sid_rl{mmid}; ids = idsl{mmid}; constant = constant{mmid}(realid); end end if ~strcmp(settings.p_inverter,'all'); if 1 vv2 =(vv(ids_a1(sid_rl{mmid}),realid)./(ones(3,1)*(constant))); end vv2_ = -vv2; sols = [ [vv1 vv1_]; [vv2 vv2_]]; sols([sid,sid_r],:) = sols; end if settings.real realid = (sum(imag(sols)<1e-4)==4); sols = sols(:,realid); end end % function end function ids_reorder = find_id (list,ids) % slightly faster than ismember ccc = zeros(1,length(list)); ccc(ids) = 1:length(ids); ccc = ccc(list); [nouse,ids_reorder,ff] = find(ccc); ids_reorder(ff) = ids_reorder; end
github
urbste/MLPnP_matlab_toolbox-master
Resultant_Solver_DLS.m
.m
MLPnP_matlab_toolbox-master/OPnP/Resultant_Solver_DLS.m
36,582
utf_8
31825a36e21ef1797fb94d2c9968c250
function [y z t] = Resultant_Solver_DLS(f1coeff,f2coeff,f3coeff) u = round(randn(4,1) * 100); M2 = cayley_LS_M(f1coeff, f2coeff, f3coeff,u); % construct the multiplication matrix via schur compliment of the Macaulay % matrix Mtilde = M2(1:27,1:27) - M2(1:27,28:120)/M2(28:120,28:120)*M2(28:120,1:27); [V,~] = eig(Mtilde); % extract the optimal solutions from the eigen decomposition of the % Multiplication matrix sol = V([10 4 2],:)./(ones(3, 1)*V(1,:)); if (find(isnan(sol(:))) > 0) x = []; y = []; z = []; else I = find(not(imag( sol(1,:) ))); y = sol(1,I); z = sol(2,I); t = sol(3,I); end end function M = cayley_LS_M(a,b,c,u) %,u1,u2,u3) % Construct the Macaulay resultant matrix M = [u(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(1) 0; u(4) u(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(1) a(10) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(10) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(10) 0; 0 u(4) u(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(10) a(14) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(1) 0 0 b(10) 0 0 0 0 0 0 0 0 0 0 b(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(14) 0 0 0 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11) a(3) 0 0 0 a(5) a(17) 0 0 0 0 a(14) a(8) a(10) a(13) a(9) a(19) 0 0 0 a(4) 0 0 0 a(2) 0 a(12) 0 b(11) b(9) b(3) 0 b(17) b(4) b(5) b(13) 0 0 b(2) 0 0 0 0 0 b(19) b(10) 0 0 0 0 0 b(14) b(8) 0 0 b(12) 0 0 0 0 c(12) 0 c(2) c(4) 0 c(14) 0 0 c(10) c(8) 0 0 0 c(19) 0 0 0 0 0 c(9) 0 0 0 0 c(13) 0 c(11) c(3) 0 c(5) c(17) 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u(2) 0 0 0 0 0 u(3) 0 0 u(1) 0 0 0 0 a(9) a(13) 0 0 0 0 0 a(18) 0 a(11) a(3) 0 0 0 0 0 0 0 0 0 a(2) 0 0 a(1) a(15) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(1) b(9) b(13) b(2) 0 b(11) b(3) 0 0 b(15) 0 b(18) 0 0 c(15) c(18) 0 0 0 c(11) c(1) c(9) 0 c(3) 0 0 0 0 0 0 0 0 0 0 c(13) 0 0 0 0 0 0 0 0 0 0 0 c(2); 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u(2) 0 0 0 0 0 u(3) 0 u(4) u(1) 0 0 0 a(4) a(19) 0 a(15) a(18) 0 0 0 0 a(5) a(17) a(11) 0 0 a(2) a(9) a(13) 0 a(3) 0 0 0 0 a(10) a(6) 0 0 0 0 0 b(18) b(3) b(15) 0 b(13) 0 0 0 0 b(9) 0 0 b(2) b(11) b(10) b(4) b(19) 0 0 b(5) b(17) 0 0 b(6) 0 0 0 0 c(6) 0 0 c(3) 0 c(5) c(10) c(4) c(11) c(17) c(9) 0 0 c(2) 0 0 0 0 0 0 c(19) 0 0 0 0 c(13) 0 0 0 c(15) c(18) 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u(2) 0 0 0 0 0 u(3) 0 u(4) u(1) a(15) a(18) a(8) 0 0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 a(15) 0 a(18) 0 a(13) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(13) b(20) 0 0 b(3) b(2) 0 b(18) b(15) 0 0 0 c(15) c(18) 0 0 0 0 0 c(2) c(13) c(20) 0 0 0 c(3) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(13) a(20) 0 0 a(4) a(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(14) 0 a(8) 0 0 0 0 b(13) 0 b(20) b(4) 0 0 b(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(8) b(14) 0 0 0 c(14) c(8) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(13) c(20) c(4) c(19) 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(20) 0 0 0 a(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(8) 0 0 0 0 0 0 b(20) 0 0 b(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(8) 0 0 0 c(8) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(20) 0 c(19) 0 0 0 0]'; end
github
urbste/MLPnP_matlab_toolbox-master
PnP_Reproj_NLS_Matlab.m
.m
MLPnP_matlab_toolbox-master/OPnP/PnP_Reproj_NLS_Matlab.m
1,767
utf_8
10261b578cc0cc01f64c72439bf7f95f
function [Rr tr] = PnP_Reproj_NLS_Matlab(U,u,R0,t0) %to refine the column-triplet by using nonlinear least square %it's much better than the fminunc used by CVPR12. %there are three fractional formulations, anyone is equivalently good. %there are two constrained formulations, yet neither is good. %the reason is that: eliminating the unkown scale. ---> similar to %reprojection error and homogeneous error %transform matrix to unit quaternion q = matrix2quaternion(R0); %nonlinear least square parameter setting options = optimset('Algorithm','trust-region-reflective','Jacobian','on','DerivativeCheck','off','Display','off'); %call matlab lsqnonlin [var,resnorm] = lsqnonlin(@(var)valuegradient(var,U,u),[q(:);t0(:)],[],[],options); %denormalize data qr = var(1:4); tr = var(5:end); normqr = norm(qr); tr = tr/(normqr)^2; qr = qr/normqr; %trasform back into matrix form Rr = quaternion2matrix(qr); end %formulation 1 function [fval grad] = valuegradient(var,U,u) npt = size(U,2); fval = zeros(2*npt,1); grad = zeros(2*npt,7); a = var(1); b = var(2); c = var(3); d = var(4); R = [a^2+b^2-c^2-d^2 2*b*c-2*a*d 2*b*d+2*a*c 2*b*c+2*a*d a^2-b^2+c^2-d^2 2*c*d-2*a*b 2*b*d-2*a*c 2*c*d+2*a*b a^2-b^2-c^2+d^2]; t1 = var(5); t2 = var(6); t3 = var(7); for i = 1:npt vec = R*U(:,i) + [t1;t2;t3]; fval(2*(i-1)+1) = u(1,i) - vec(1)/vec(3); fval(2*i) = u(2,i) - vec(2)/vec(3); temp1 = [2*[a -d c;b c d; -c b a; -d -a b]*U(:,i); 1; 0; 0].'; temp2 = [2*[d a -b;c -b -a;b c d; a -d c]*U(:,i); 0; 1; 0].'; temp3 = [2*[-c b a;d a -b;-a d -c; b c d]*U(:,i); 0; 0; 1].'; grad(2*(i-1)+1,:) = (-temp1*vec(3) + temp3*vec(1))/(vec(3)^2); grad(2*i,:) = (-temp2*vec(3) + temp3*vec(2))/(vec(3)^2); end end
github
urbste/MLPnP_matlab_toolbox-master
Generate_Random_Data_Full.m
.m
MLPnP_matlab_toolbox-master/OPnP/Generate_Random_Data_Full.m
21,006
utf_8
073e56c803c19a87ea47860f35a982fe
function [var e1 e2 e3 e4 c1 c2 c3 Q q] = Generate_Random_Data_Full(rotation_type,point_config) %Output: %var = [a b c d]; ground_truth %e1,e2,e3,e4: the coefficients of polynomials of our formulation %c1,c2,c3: the coefficients of polynomials of DLS %Q,q: the objective function used in polishing %generate ground_truth rotations if strcmp(rotation_type,'Fully_Random') temp = randn(1,4); elseif strcmp(rotation_type,'Near_Cayley_Degenerate') temp = randn(1,4); temp(1) = 1e-4; %a small value,near degenerate to Cayley elseif strcmp(rotation_type,'Cayley_Degenerate') temp = randn(1,4); temp(1) = 0; % degenerate to Cayley end %Ground-truth quaternions temp = temp/norm(temp); a = temp(1); b = temp(2); c = temp(3); d = temp(4); var = [a b c d]; %Ground-truth rotation matrix R = [a^2+b^2-c^2-d^2 2*b*c-2*a*d 2*b*d+2*a*c 2*b*c+2*a*d a^2-b^2+c^2-d^2 2*c*d-2*a*b 2*b*d-2*a*c 2*c*d+2*a*b a^2-b^2-c^2+d^2]; %number of points npt = 50; % camera's parameters width= 640; height= 480; f= 800; if strcmp(point_config,'Ordinary_3D') % generate 3d coordinates in camera space Xc= [xrand(1,npt,[-2 2]); xrand(1,npt,[-2 2]); xrand(1,npt,[4 8])]; t= mean(Xc,2); U = inv(R)*(Xc-repmat(t,1,npt)); % projection xx= [Xc(1,:)./Xc(3,:); Xc(2,:)./Xc(3,:)]*f; xxn= xx+randn(2,npt)*0; %noise-free u = xxn/f; elseif strcmp(point_config,'Quasi_Singular') % generate 3d coordinates in camera space Xc= [xrand(1,npt,[1 2]); xrand(1,npt,[1 2]); xrand(1,npt,[4 8])]; t= mean(Xc,2); U= inv(R)*(Xc-repmat(t,1,npt)); % projection xx= [Xc(1,:)./Xc(3,:); Xc(2,:)./Xc(3,:)]*f; xxn= xx+randn(2,npt)*0; %noise-free u = xxn/f; else % generate 3d coordinates in camera space XXw= [xrand(2,npt,[-2 2]); zeros(1,npt)]; t= [rand-0.5;rand-0.5;rand*8+4]; Xc= R*XXw+repmat(t,1,npt); U = XXw; % projection xx= [Xc(1,:)./Xc(3,:); Xc(2,:)./Xc(3,:)]*f; xxn= xx+randn(2,npt)*0; u = xxn/f; end %using the fractional formulation n = npt; %homogeneous coordinate if size(u,1) > 2 u = u(1:2,:); end %3D points after translation to centroid Ucent = mean(U,2); Um = U - repmat(Ucent,1,n); xm = Um(1,:)'; ym = Um(2,:)'; zm = Um(3,:)'; x = U(1,:)'; y = U(2,:)'; z = U(3,:)'; u1 = u(1,:)'; v1 = u(2,:)'; %construct matrix N: 2n*11 N = zeros(2*n,11); N(1:2:end,:) = [ u1, u1.*zm - x, 2*u1.*ym, - 2*z - 2*u1.*xm, 2*y, - x - u1.*zm, -2*y, 2*u1.*xm - 2*z, x - u1.*zm, 2*u1.*ym, x + u1.*zm]; N(2:2:end,:) = [ v1, v1.*zm - y, 2*z + 2*v1.*ym, -2*v1.*xm, -2*x, y - v1.*zm, -2*x, 2*v1.*xm, - y - v1.*zm, 2*v1.*ym - 2*z, y + v1.*zm]; MTN = [sum(N(1:2:end,:)); sum(N(2:2:end,:))]; %construct matrix Q: 11*11 Q = N'*N - 1/n*(MTN')*MTN; q = Q(1,2:end); Q = Q(2:end,2:end); Q11 = Q(1,1); Q12 = Q(1,2); Q13 = Q(1,3); Q14 = Q(1,4); Q15 = Q(1,5); Q16 = Q(1,6); Q17 = Q(1,7); Q18 = Q(1,8); Q19 = Q(1,9); Q110 = Q(1,10); Q22 = Q(2,2); Q23 = Q(2,3); Q24 = Q(2,4); Q25 = Q(2,5); Q26 = Q(2,6); Q27 = Q(2,7); Q28 = Q(2,8); Q29 = Q(2,9); Q210 = Q(2,10); Q33 = Q(3,3); Q34 = Q(3,4); Q35 = Q(3,5); Q36 = Q(3,6); Q37 = Q(3,7); Q38 = Q(3,8); Q39 = Q(3,9); Q310 = Q(3,10); Q44 = Q(4,4); Q45 = Q(4,5); Q46 = Q(4,6); Q47 = Q(4,7); Q48 = Q(4,8); Q49 = Q(4,9); Q410 = Q(4,10); Q55 = Q(5,5); Q56 = Q(5,6); Q57 = Q(5,7); Q58 = Q(5,8); Q59 = Q(5,9); Q510 = Q(5,10); Q66 = Q(6,6); Q67 = Q(6,7); Q68 = Q(6,8); Q69 = Q(6,9); Q610 = Q(6,10); Q77 = Q(7,7); Q78 = Q(7,8); Q79 = Q(7,9); Q710 = Q(7,10); Q88 = Q(8,8); Q89 = Q(8,9); Q810 = Q(8,10); Q99 = Q(9,9); Q910 = Q(9,10); Q1010 = Q(10,10); q1 = q(1); q2 = q(2); q3 = q(3); q4 = q(4); q5 = q(5); q6 = q(6); q7 = q(7); q8 = q(8); q9 = q(9); q10 = q(10); %variable sequence %[ a^3, a^2*b, a^2*c, a^2*d, a*b^2, a*b*c, a*b*d, a*c^2, a*c*d, a*d^2, a, b^3, b^2*c, b^2*d, b*c^2, b*c*d, b*d^2, b, c^3, c^2*d, c*d^2, c, d^3, d] e1 = [ 4*Q11, 6*Q12, 6*Q13, 6*Q14, 4*Q15 + 2*Q22, 4*Q16 + 4*Q23, 4*Q17 + 4*Q24, 4*Q18 + 2*Q33, 4*Q19 + 4*Q34, 4*Q110 + 2*Q44, 4*q1, 2*Q25, 2*Q26 + 2*Q35, 2*Q27 + 2*Q45, 2*Q28 + 2*Q36, 2*Q29 + 2*Q37 + 2*Q46, 2*Q210 + 2*Q47, 2*q2, 2*Q38, 2*Q39 + 2*Q48, 2*Q310 + 2*Q49, 2*q3, 2*Q410, 2*q4]; e2 = [ 2*Q12, 4*Q15 + 2*Q22, 2*Q16 + 2*Q23, 2*Q17 + 2*Q24, 6*Q25, 4*Q26 + 4*Q35, 4*Q27 + 4*Q45, 2*Q28 + 2*Q36, 2*Q29 + 2*Q37 + 2*Q46, 2*Q210 + 2*Q47, 2*q2, 4*Q55, 6*Q56, 6*Q57, 4*Q58 + 2*Q66, 4*Q59 + 4*Q67, 4*Q510 + 2*Q77, 4*q5, 2*Q68, 2*Q69 + 2*Q78, 2*Q610 + 2*Q79, 2*q6, 2*Q710, 2*q7]; e3 = [ 2*Q13, 2*Q16 + 2*Q23, 4*Q18 + 2*Q33, 2*Q19 + 2*Q34, 2*Q26 + 2*Q35, 4*Q28 + 4*Q36, 2*Q29 + 2*Q37 + 2*Q46, 6*Q38, 4*Q39 + 4*Q48, 2*Q310 + 2*Q49, 2*q3, 2*Q56, 4*Q58 + 2*Q66, 2*Q59 + 2*Q67, 6*Q68, 4*Q69 + 4*Q78, 2*Q610 + 2*Q79, 2*q6, 4*Q88, 6*Q89, 4*Q810 + 2*Q99, 4*q8, 2*Q910, 2*q9]; e4 = [ 2*Q14, 2*Q17 + 2*Q24, 2*Q19 + 2*Q34, 4*Q110 + 2*Q44, 2*Q27 + 2*Q45, 2*Q29 + 2*Q37 + 2*Q46, 4*Q210 + 4*Q47, 2*Q39 + 2*Q48, 4*Q310 + 4*Q49, 6*Q410, 2*q4, 2*Q57, 2*Q59 + 2*Q67, 4*Q510 + 2*Q77, 2*Q69 + 2*Q78, 4*Q610 + 4*Q79, 6*Q710, 2*q7, 2*Q89, 4*Q810 + 2*Q99, 6*Q910, 2*q9, 4*Q1010, 4*q10]; %call the solver %[x y z t] = GB_Solver_3Order_4Variable_Division(e1, e2, e3, e4); %using the unit-norm formulation % M = zeros(2*n,3); % M(1:2:end,1) = -1; % M(2:2:end,2) = -1; % M(:,3) = u(:); % % N = zeros(2*n,10); % for i=1:n % N(2*(i-1)+1,:) = U(:,i)'*[1 0 2*u(1,i) 0 1 0 -2*u(1,i) -1 0 -1 % 0 -2*u(1,i) 0 -2 0 2 0 0 -2*u(1,i) 0 % -u(1,i) 0 2 0 u(1,i) 0 2 u(1,i) 0 -u(1,i)]; % % N(2*(i-1)+2,:) = U(:,i)'*[0 0 2*u(2,i) 2 0 2 -2*u(2,i) 0 0 0 % 1 -2*u(2,i) 0 0 -1 0 0 1 -2*u(2,i) -1 % -u(2,i) -2 0 0 u(2,i) 0 0 u(2,i) 2 -u(2,i)]; % end % pinvM = pinv(M); % Q = -N'*(M*pinvM-eye(2*n))*N; % % Q11 = Q(1,1); Q12 = Q(1,2); Q13 = Q(1,3); Q14 = Q(1,4); Q15 = Q(1,5); Q16 = Q(1,6); Q17 = Q(1,7); Q18 = Q(1,8); Q19 = Q(1,9); Q110 = Q(1,10); % Q22 = Q(2,2); Q23 = Q(2,3); Q24 = Q(2,4); Q25 = Q(2,5); Q26 = Q(2,6); Q27 = Q(2,7); Q28 = Q(2,8); Q29 = Q(2,9); Q210 = Q(2,10); % Q33 = Q(3,3); Q34 = Q(3,4); Q35 = Q(3,5); Q36 = Q(3,6); Q37 = Q(3,7); Q38 = Q(3,8); Q39 = Q(3,9); Q310 = Q(3,10); % Q44 = Q(4,4); Q45 = Q(4,5); Q46 = Q(4,6); Q47 = Q(4,7); Q48 = Q(4,8); Q49 = Q(4,9); Q410 = Q(4,10); % Q55 = Q(5,5); Q56 = Q(5,6); Q57 = Q(5,7); Q58 = Q(5,8); Q59 = Q(5,9); Q510 = Q(5,10); % Q66 = Q(6,6); Q67 = Q(6,7); Q68 = Q(6,8); Q69 = Q(6,9); Q610 = Q(6,10); % Q77 = Q(7,7); Q78 = Q(7,8); Q79 = Q(7,9); Q710 = Q(7,10); % Q88 = Q(8,8); Q89 = Q(8,9); Q810 = Q(8,10); % Q99 = Q(9,9); Q910 = Q(9,10); % Q1010 = Q(10,10); % % c1 = [ 4*Q11, 6*Q12, 6*Q13, 6*Q14, 4*Q15 + 2*Q22, 4*Q16 + 4*Q23, 4*Q17 + 4*Q24, 4*Q18 + 2*Q33, 4*Q19 + 4*Q34, 4*Q110 + 2*Q44, 2*Q25, 2*Q26 + 2*Q35, 2*Q27 + 2*Q45, 2*Q28 + 2*Q36, 2*Q29 + 2*Q37 + 2*Q46, 2*Q210 + 2*Q47, 2*Q38, 2*Q39 + 2*Q48, 2*Q310 + 2*Q49, 2*Q410]; % c2 = [ 2*Q12, 4*Q15 + 2*Q22, 2*Q16 + 2*Q23, 2*Q17 + 2*Q24, 6*Q25, 4*Q26 + 4*Q35, 4*Q27 + 4*Q45, 2*Q28 + 2*Q36, 2*Q29 + 2*Q37 + 2*Q46, 2*Q210 + 2*Q47, 4*Q55, 6*Q56, 6*Q57, 4*Q58 + 2*Q66, 4*Q59 + 4*Q67, 4*Q510 + 2*Q77, 2*Q68, 2*Q69 + 2*Q78, 2*Q610 + 2*Q79, 2*Q710]; % c3 = [ 2*Q13, 2*Q16 + 2*Q23, 4*Q18 + 2*Q33, 2*Q19 + 2*Q34, 2*Q26 + 2*Q35, 4*Q28 + 4*Q36, 2*Q29 + 2*Q37 + 2*Q46, 6*Q38, 4*Q39 + 4*Q48, 2*Q310 + 2*Q49, 2*Q56, 4*Q58 + 2*Q66, 2*Q59 + 2*Q67, 6*Q68, 4*Q69 + 4*Q78, 2*Q610 + 2*Q79, 4*Q88, 6*Q89, 4*Q810 + 2*Q99, 2*Q910]; % c4 = [ 2*Q14, 2*Q17 + 2*Q24, 2*Q19 + 2*Q34, 4*Q110 + 2*Q44, 2*Q27 + 2*Q45, 2*Q29 + 2*Q37 + 2*Q46, 4*Q210 + 4*Q47, 2*Q39 + 2*Q48, 4*Q310 + 4*Q49, 6*Q410, 2*Q57, 2*Q59 + 2*Q67, 4*Q510 + 2*Q77, 2*Q69 + 2*Q78, 4*Q610 + 4*Q79, 6*Q710, 2*Q89, 4*Q810 + 2*Q99, 6*Q910, 4*Q1010]; %call the solver %[x y z t] = GB_Solver_3Order_4Variable_UnitNorm_Division(c1, c2, c3, c4); %using the Cayley form in DLS p = U; z = u; z_old = z; % make z into unit vectors from normalized pixel coords z = [z; ones(1,size(z,2))]; z = z./ repmat(sqrt(sum(z.*z,1)),3,1); % some preliminaries flag = 0; N = size(z,2); % build coeff matrix % An intermediate matrix, the inverse of what is called "H" in the paper % (see eq. 25) H = zeros(3); for i = 1:N H = H + eye(3) - z(:,i)*z(:,i)'; end A = zeros(3,9); for i = 1:N A = A + (z(:,i)*z(:,i)' - eye(3)) * LeftMultVec(p(:,i)); end A = H\A; D = zeros(9); for i = 1:N D = D + (LeftMultVec(p(:,i)) + A)' * (eye(3) - z(:,i)*z(:,i)') * (LeftMultVec(p(:,i)) + A); end c1 = [2*D(1,6) - 2*D(1,8) + 2*D(5,6) - 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) - 2*D(8,1) - 2*D(8,5) - 2*D(8,9) + 2*D(9,6) - 2*D(9,8); % constant term (6*D(1,2) + 6*D(1,4) + 6*D(2,1) - 6*D(2,5) - 6*D(2,9) + 6*D(4,1) - 6*D(4,5) - 6*D(4,9) - 6*D(5,2) - 6*D(5,4) - 6*D(9,2) - 6*D(9,4)); % s1^2 * s2 (4*D(1,7) - 4*D(1,3) + 8*D(2,6) - 8*D(2,8) - 4*D(3,1) + 4*D(3,5) + 4*D(3,9) + 8*D(4,6) - 8*D(4,8) + 4*D(5,3) - 4*D(5,7) + 8*D(6,2) + 8*D(6,4) + 4*D(7,1) - 4*D(7,5) - 4*D(7,9) - 8*D(8,2) - 8*D(8,4) + 4*D(9,3) - 4*D(9,7)); % s1 * s2 (4*D(1,2) - 4*D(1,4) + 4*D(2,1) - 4*D(2,5) - 4*D(2,9) + 8*D(3,6) - 8*D(3,8) - 4*D(4,1) + 4*D(4,5) + 4*D(4,9) - 4*D(5,2) + 4*D(5,4) + 8*D(6,3) + 8*D(6,7) + 8*D(7,6) - 8*D(7,8) - 8*D(8,3) - 8*D(8,7) - 4*D(9,2) + 4*D(9,4)); % s1 * s3 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s2 * s3 (4*D(2,6) - 2*D(1,7) - 2*D(1,3) + 4*D(2,8) - 2*D(3,1) + 2*D(3,5) - 2*D(3,9) + 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) + 4*D(6,4) - 2*D(7,1) + 2*D(7,5) - 2*D(7,9) + 4*D(8,2) + 4*D(8,4) - 2*D(9,3) - 2*D(9,7)); % s2^2 * s3 (2*D(2,5) - 2*D(1,4) - 2*D(2,1) - 2*D(1,2) - 2*D(2,9) - 2*D(4,1) + 2*D(4,5) - 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 2*D(9,2) - 2*D(9,4)); % s2^3 (4*D(1,9) - 4*D(1,1) + 8*D(3,3) + 8*D(3,7) + 4*D(5,5) + 8*D(7,3) + 8*D(7,7) + 4*D(9,1) - 4*D(9,9)); % s1 * s3^2 (4*D(1,1) - 4*D(5,5) - 4*D(5,9) + 8*D(6,6) - 8*D(6,8) - 8*D(8,6) + 8*D(8,8) - 4*D(9,5) - 4*D(9,9)); % s1 (2*D(1,3) + 2*D(1,7) + 4*D(2,6) - 4*D(2,8) + 2*D(3,1) + 2*D(3,5) + 2*D(3,9) - 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) - 4*D(6,4) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 4*D(8,2) + 4*D(8,4) + 2*D(9,3) + 2*D(9,7)); % s3 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 4*D(3,6) + 4*D(3,8) + 2*D(4,1) + 2*D(4,5) + 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) + 4*D(8,3) - 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s2 (2*D(2,9) - 2*D(1,4) - 2*D(2,1) - 2*D(2,5) - 2*D(1,2) + 4*D(3,6) + 4*D(3,8) - 2*D(4,1) - 2*D(4,5) + 2*D(4,9) - 2*D(5,2) - 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) + 4*D(8,3) + 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s2 * s3^2 (6*D(1,6) - 6*D(1,8) - 6*D(5,6) + 6*D(5,8) + 6*D(6,1) - 6*D(6,5) - 6*D(6,9) - 6*D(8,1) + 6*D(8,5) + 6*D(8,9) - 6*D(9,6) + 6*D(9,8)); % s1^2 (2*D(1,8) - 2*D(1,6) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) - 4*D(3,4) - 4*D(4,3) - 4*D(4,7) - 2*D(5,6) + 2*D(5,8) - 2*D(6,1) - 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) - 2*D(8,9) + 2*D(9,6) - 2*D(9,8)); % s3^2 (2*D(1,8) - 2*D(1,6) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) - 4*D(3,4) - 4*D(4,3) + 4*D(4,7) + 2*D(5,6) - 2*D(5,8) - 2*D(6,1) + 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) + 2*D(8,9) - 2*D(9,6) + 2*D(9,8)); % s2^2 (2*D(3,9) - 2*D(1,7) - 2*D(3,1) - 2*D(3,5) - 2*D(1,3) - 2*D(5,3) - 2*D(5,7) - 2*D(7,1) - 2*D(7,5) + 2*D(7,9) + 2*D(9,3) + 2*D(9,7)); % s3^3 (4*D(1,6) + 4*D(1,8) + 8*D(2,3) + 8*D(2,7) + 8*D(3,2) + 8*D(3,4) + 8*D(4,3) + 8*D(4,7) - 4*D(5,6) - 4*D(5,8) + 4*D(6,1) - 4*D(6,5) - 4*D(6,9) + 8*D(7,2) + 8*D(7,4) + 4*D(8,1) - 4*D(8,5) - 4*D(8,9) - 4*D(9,6) - 4*D(9,8)); % s1 * s2 * s3 (4*D(1,5) - 4*D(1,1) + 8*D(2,2) + 8*D(2,4) + 8*D(4,2) + 8*D(4,4) + 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s1 * s2^2 (6*D(1,3) + 6*D(1,7) + 6*D(3,1) - 6*D(3,5) - 6*D(3,9) - 6*D(5,3) - 6*D(5,7) + 6*D(7,1) - 6*D(7,5) - 6*D(7,9) - 6*D(9,3) - 6*D(9,7)); % s1^2 * s3 (4*D(1,1) - 4*D(1,5) - 4*D(1,9) - 4*D(5,1) + 4*D(5,5) + 4*D(5,9) - 4*D(9,1) + 4*D(9,5) + 4*D(9,9))].'; % s1^3 c2 = [- 2*D(1,3) + 2*D(1,7) - 2*D(3,1) - 2*D(3,5) - 2*D(3,9) - 2*D(5,3) + 2*D(5,7) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 2*D(9,3) + 2*D(9,7); % constant term (4*D(1,5) - 4*D(1,1) + 8*D(2,2) + 8*D(2,4) + 8*D(4,2) + 8*D(4,4) + 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s1^2 * s2 (4*D(1,8) - 4*D(1,6) - 8*D(2,3) + 8*D(2,7) - 8*D(3,2) - 8*D(3,4) - 8*D(4,3) + 8*D(4,7) + 4*D(5,6) - 4*D(5,8) - 4*D(6,1) + 4*D(6,5) - 4*D(6,9) + 8*D(7,2) + 8*D(7,4) + 4*D(8,1) - 4*D(8,5) + 4*D(8,9) - 4*D(9,6) + 4*D(9,8)); % s1 * s2 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s1 * s3 (4*D(1,4) - 4*D(1,2) - 4*D(2,1) + 4*D(2,5) - 4*D(2,9) - 8*D(3,6) - 8*D(3,8) + 4*D(4,1) - 4*D(4,5) + 4*D(4,9) + 4*D(5,2) - 4*D(5,4) - 8*D(6,3) + 8*D(6,7) + 8*D(7,6) + 8*D(7,8) - 8*D(8,3) + 8*D(8,7) - 4*D(9,2) + 4*D(9,4)); % s2 * s3 (6*D(5,6) - 6*D(1,8) - 6*D(1,6) + 6*D(5,8) - 6*D(6,1) + 6*D(6,5) - 6*D(6,9) - 6*D(8,1) + 6*D(8,5) - 6*D(8,9) - 6*D(9,6) - 6*D(9,8)); % s2^2 * s3 (4*D(1,1) - 4*D(1,5) + 4*D(1,9) - 4*D(5,1) + 4*D(5,5) - 4*D(5,9) + 4*D(9,1) - 4*D(9,5) + 4*D(9,9)); % s2^3 (2*D(2,9) - 2*D(1,4) - 2*D(2,1) - 2*D(2,5) - 2*D(1,2) + 4*D(3,6) + 4*D(3,8) - 2*D(4,1) - 2*D(4,5) + 2*D(4,9) - 2*D(5,2) - 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) + 4*D(8,3) + 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s1 * s3^2 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 4*D(3,6) + 4*D(3,8) + 2*D(4,1) + 2*D(4,5) + 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) + 4*D(8,3) - 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s1 (2*D(1,6) + 2*D(1,8) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) + 4*D(3,4) + 4*D(4,3) - 4*D(4,7) + 2*D(5,6) + 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s3 (8*D(3,3) - 4*D(1,9) - 4*D(1,1) - 8*D(3,7) + 4*D(5,5) - 8*D(7,3) + 8*D(7,7) - 4*D(9,1) - 4*D(9,9)); % s2 (4*D(1,1) - 4*D(5,5) + 4*D(5,9) + 8*D(6,6) + 8*D(6,8) + 8*D(8,6) + 8*D(8,8) + 4*D(9,5) - 4*D(9,9)); % s2 * s3^2 (2*D(1,7) - 2*D(1,3) + 4*D(2,6) - 4*D(2,8) - 2*D(3,1) + 2*D(3,5) + 2*D(3,9) + 4*D(4,6) - 4*D(4,8) + 2*D(5,3) - 2*D(5,7) + 4*D(6,2) + 4*D(6,4) + 2*D(7,1) - 2*D(7,5) - 2*D(7,9) - 4*D(8,2) - 4*D(8,4) + 2*D(9,3) - 2*D(9,7)); % s1^2 (2*D(1,3) - 2*D(1,7) + 4*D(2,6) + 4*D(2,8) + 2*D(3,1) + 2*D(3,5) - 2*D(3,9) - 4*D(4,6) - 4*D(4,8) + 2*D(5,3) - 2*D(5,7) + 4*D(6,2) - 4*D(6,4) - 2*D(7,1) - 2*D(7,5) + 2*D(7,9) + 4*D(8,2) - 4*D(8,4) - 2*D(9,3) + 2*D(9,7)); % s3^2 (6*D(1,3) - 6*D(1,7) + 6*D(3,1) - 6*D(3,5) + 6*D(3,9) - 6*D(5,3) + 6*D(5,7) - 6*D(7,1) + 6*D(7,5) - 6*D(7,9) + 6*D(9,3) - 6*D(9,7)); % s2^2 (2*D(6,9) - 2*D(1,8) - 2*D(5,6) - 2*D(5,8) - 2*D(6,1) - 2*D(6,5) - 2*D(1,6) - 2*D(8,1) - 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s3^3 (8*D(2,6) - 4*D(1,7) - 4*D(1,3) + 8*D(2,8) - 4*D(3,1) + 4*D(3,5) - 4*D(3,9) + 8*D(4,6) + 8*D(4,8) + 4*D(5,3) + 4*D(5,7) + 8*D(6,2) + 8*D(6,4) - 4*D(7,1) + 4*D(7,5) - 4*D(7,9) + 8*D(8,2) + 8*D(8,4) - 4*D(9,3) - 4*D(9,7)); % s1 * s2 * s3 (6*D(2,5) - 6*D(1,4) - 6*D(2,1) - 6*D(1,2) - 6*D(2,9) - 6*D(4,1) + 6*D(4,5) - 6*D(4,9) + 6*D(5,2) + 6*D(5,4) - 6*D(9,2) - 6*D(9,4)); % s1 * s2^2 (2*D(1,6) + 2*D(1,8) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) + 4*D(3,4) + 4*D(4,3) + 4*D(4,7) - 2*D(5,6) - 2*D(5,8) + 2*D(6,1) - 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s1^2 * s3 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) - 2*D(2,5) - 2*D(2,9) + 2*D(4,1) - 2*D(4,5) - 2*D(4,9) - 2*D(5,2) - 2*D(5,4) - 2*D(9,2) - 2*D(9,4))].'; % s1^3 c3 = [2*D(1,2) - 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 2*D(4,1) - 2*D(4,5) - 2*D(4,9) + 2*D(5,2) - 2*D(5,4) + 2*D(9,2) - 2*D(9,4); % constant term (2*D(1,6) + 2*D(1,8) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) + 4*D(3,4) + 4*D(4,3) + 4*D(4,7) - 2*D(5,6) - 2*D(5,8) + 2*D(6,1) - 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s1^2 * s2 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s1 * s2 (4*D(1,8) - 4*D(1,6) + 8*D(2,3) + 8*D(2,7) + 8*D(3,2) - 8*D(3,4) - 8*D(4,3) - 8*D(4,7) - 4*D(5,6) + 4*D(5,8) - 4*D(6,1) - 4*D(6,5) + 4*D(6,9) + 8*D(7,2) - 8*D(7,4) + 4*D(8,1) + 4*D(8,5) - 4*D(8,9) + 4*D(9,6) - 4*D(9,8)); % s1 * s3 (4*D(1,3) - 4*D(1,7) + 8*D(2,6) + 8*D(2,8) + 4*D(3,1) + 4*D(3,5) - 4*D(3,9) - 8*D(4,6) - 8*D(4,8) + 4*D(5,3) - 4*D(5,7) + 8*D(6,2) - 8*D(6,4) - 4*D(7,1) - 4*D(7,5) + 4*D(7,9) + 8*D(8,2) - 8*D(8,4) - 4*D(9,3) + 4*D(9,7)); % s2 * s3 (4*D(1,1) - 4*D(5,5) + 4*D(5,9) + 8*D(6,6) + 8*D(6,8) + 8*D(8,6) + 8*D(8,8) + 4*D(9,5) - 4*D(9,9)); % s2^2 * s3 (2*D(5,6) - 2*D(1,8) - 2*D(1,6) + 2*D(5,8) - 2*D(6,1) + 2*D(6,5) - 2*D(6,9) - 2*D(8,1) + 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s2^3 (6*D(3,9) - 6*D(1,7) - 6*D(3,1) - 6*D(3,5) - 6*D(1,3) - 6*D(5,3) - 6*D(5,7) - 6*D(7,1) - 6*D(7,5) + 6*D(7,9) + 6*D(9,3) + 6*D(9,7)); % s1 * s3^2 (2*D(1,3) + 2*D(1,7) + 4*D(2,6) - 4*D(2,8) + 2*D(3,1) + 2*D(3,5) + 2*D(3,9) - 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) - 4*D(6,4) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 4*D(8,2) + 4*D(8,4) + 2*D(9,3) + 2*D(9,7)); % s1 (8*D(2,2) - 4*D(1,5) - 4*D(1,1) - 8*D(2,4) - 8*D(4,2) + 8*D(4,4) - 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s3 (2*D(1,6) + 2*D(1,8) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) + 4*D(3,4) + 4*D(4,3) - 4*D(4,7) + 2*D(5,6) + 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s2 (6*D(6,9) - 6*D(1,8) - 6*D(5,6) - 6*D(5,8) - 6*D(6,1) - 6*D(6,5) - 6*D(1,6) - 6*D(8,1) - 6*D(8,5) + 6*D(8,9) + 6*D(9,6) + 6*D(9,8)); % s2 * s3^2 (2*D(1,2) - 2*D(1,4) + 2*D(2,1) - 2*D(2,5) - 2*D(2,9) + 4*D(3,6) - 4*D(3,8) - 2*D(4,1) + 2*D(4,5) + 2*D(4,9) - 2*D(5,2) + 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) - 4*D(8,3) - 4*D(8,7) - 2*D(9,2) + 2*D(9,4)); % s1^2 (6*D(1,4) - 6*D(1,2) - 6*D(2,1) - 6*D(2,5) + 6*D(2,9) + 6*D(4,1) + 6*D(4,5) - 6*D(4,9) - 6*D(5,2) + 6*D(5,4) + 6*D(9,2) - 6*D(9,4)); % s3^2 (2*D(1,4) - 2*D(1,2) - 2*D(2,1) + 2*D(2,5) - 2*D(2,9) - 4*D(3,6) - 4*D(3,8) + 2*D(4,1) - 2*D(4,5) + 2*D(4,9) + 2*D(5,2) - 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) - 4*D(8,3) + 4*D(8,7) - 2*D(9,2) + 2*D(9,4)); % s2^2 (4*D(1,1) + 4*D(1,5) - 4*D(1,9) + 4*D(5,1) + 4*D(5,5) - 4*D(5,9) - 4*D(9,1) - 4*D(9,5) + 4*D(9,9)); % s3^3 (4*D(2,9) - 4*D(1,4) - 4*D(2,1) - 4*D(2,5) - 4*D(1,2) + 8*D(3,6) + 8*D(3,8) - 4*D(4,1) - 4*D(4,5) + 4*D(4,9) - 4*D(5,2) - 4*D(5,4) + 8*D(6,3) + 8*D(6,7) + 8*D(7,6) + 8*D(7,8) + 8*D(8,3) + 8*D(8,7) + 4*D(9,2) + 4*D(9,4)); % s1 * s2 * s3 (4*D(2,6) - 2*D(1,7) - 2*D(1,3) + 4*D(2,8) - 2*D(3,1) + 2*D(3,5) - 2*D(3,9) + 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) + 4*D(6,4) - 2*D(7,1) + 2*D(7,5) - 2*D(7,9) + 4*D(8,2) + 4*D(8,4) - 2*D(9,3) - 2*D(9,7)); % s1 * s2^2 (4*D(1,9) - 4*D(1,1) + 8*D(3,3) + 8*D(3,7) + 4*D(5,5) + 8*D(7,3) + 8*D(7,7) + 4*D(9,1) - 4*D(9,9)); % s1^2 * s3 (2*D(1,3) + 2*D(1,7) + 2*D(3,1) - 2*D(3,5) - 2*D(3,9) - 2*D(5,3) - 2*D(5,7) + 2*D(7,1) - 2*D(7,5) - 2*D(7,9) - 2*D(9,3) - 2*D(9,7))].'; % s1^3 end function M = LeftMultVec(v) % R * p = LeftMultVec(p) * vec(R) M = [v' zeros(1,6); zeros(1,3) v' zeros(1,3); zeros(1,6) v']; end
github
urbste/MLPnP_matlab_toolbox-master
matrix2quaternion.m
.m
MLPnP_matlab_toolbox-master/OPnP/matrix2quaternion.m
2,010
utf_8
ad7a1983aceaa9953be167eddabb22ae
% MATRIX2QUATERNION - Homogeneous matrix to quaternion % % Converts 4x4 homogeneous rotation matrix to quaternion % % Usage: Q = matrix2quaternion(T) % % Argument: T - 4x4 Homogeneous transformation matrix % Returns: Q - a quaternion in the form [w, xi, yj, zk] % % See Also QUATERNION2MATRIX % Copyright (c) 2008 Peter Kovesi % School of Computer Science & Software Engineering % The University of Western Australia % pk at csse uwa edu au % http://www.csse.uwa.edu.au/ % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal % in the Software without restriction, subject to the following conditions: % % The above copyright notice and this permission notice shall be included in % all copies or substantial portions of the Software. % % The Software is provided "as is", without warranty of any kind. function Q = matrix2quaternion(T) % This code follows the implementation suggested by Hartley and Zisserman R = T(1:3, 1:3); % Extract rotation part of T % Find rotation axis as the eigenvector having unit eigenvalue % Solve (R-I)v = 0; [v,d] = eig(R-eye(3)); % The following code assumes the eigenvalues returned are not necessarily % sorted by size. This may be overcautious on my part. d = diag(abs(d)); % Extract eigenvalues [s, ind] = sort(d); % Find index of smallest one if d(ind(1)) > 0.001 % Hopefully it is close to 0 warning('Rotation matrix is dubious'); end axis = v(:,ind(1)); % Extract appropriate eigenvector if abs(norm(axis) - 1) > .0001 % Debug warning('non unit rotation axis'); end % Now determine the rotation angle twocostheta = trace(R)-1; twosinthetav = [R(3,2)-R(2,3), R(1,3)-R(3,1), R(2,1)-R(1,2)]'; twosintheta = axis'*twosinthetav; theta = atan2(twosintheta, twocostheta); Q = [cos(theta/2); axis*sin(theta/2)];
github
urbste/MLPnP_matlab_toolbox-master
GB_Solver_3Order_4Variable_Symmetry.m
.m
MLPnP_matlab_toolbox-master/OPnP/GB_Solver_3Order_4Variable_Symmetry.m
884
utf_8
81ed9a17a4479db7de5169dccf46c62f
% Generated using GBSolver generator Copyright Martin Bujnak, % Zuzana Kukelova, Tomas Pajdla CTU Prague 2008. % % Please refer to the following paper, when using this code : % Kukelova Z., Bujnak M., Pajdla T., Automatic Generator of Minimal Problem Solvers, % ECCV 2008, Marseille, France, October 12-18, 2008 function [x y z t] = GB_Solver_3Order_4Variable_Symmetry(a1, b1, c1, d1) %loading template template_name = 'template_pnp'; load(template_name); %solver parameter settings.debug = 0; % debug mode : very slow settings.full_QR1 = 0; % turn on sparse QR settings.p_inverter = 'all'; % use 'all' to use the 'best' inverter settings.real = 1; % 1: only output real solutions %call solver [sols,stats] = solver_pfold([a1;b1;c1;d1],settings); %selecting solutions x = sols(1,:); y = sols(2,:); z = sols(3,:); t = sols(4,:); end
github
urbste/MLPnP_matlab_toolbox-master
GB_Solver_3Order_4Variable_b_Division.m
.m
MLPnP_matlab_toolbox-master/OPnP/GB_Solver_3Order_4Variable_b_Division.m
118,829
utf_8
b99f7fa1930baa2a68e6e2c2904ac5bd
% Generated using GBSolver generator Copyright Martin Bujnak, % Zuzana Kukelova, Tomas Pajdla CTU Prague 2008. % % Please refer to the following paper, when using this code : % Kukelova Z., Bujnak M., Pajdla T., Automatic Generator of Minimal Problem Solvers, % ECCV 2008, Marseille, France, October 12-18, 2008 function [a b c d] = GB_Solver_3Order_4Variable_b_Division(e11, e21, e31, e41) % precalculate polynomial equations coefficients c(1) = e11(12); c(2) = e11(5); c(3) = e11(2); c(4) = e11(1); c(5) = e11(13); c(6) = e11(6); c(7) = e11(3); c(8) = e11(15); c(9) = e11(8); c(10) = e11(19); c(11) = e11(14); c(12) = e11(7); c(13) = e11(4); c(14) = e11(16); c(15) = e11(9); c(16) = e11(20); c(17) = e11(17); c(18) = e11(10); c(19) = e11(21); c(20) = e11(23); c(21) = e11(18); c(22) = e11(11); c(23) = e11(22); c(24) = e11(24); c(25) = 0; c(26) = e21(12); c(27) = e21(5); c(28) = e21(2); c(29) = e21(1); c(30) = e21(13); c(31) = e21(6); c(32) = e21(3); c(33) = e21(15); c(34) = e21(8); c(35) = e21(19); c(36) = e21(14); c(37) = e21(7); c(38) = e21(4); c(39) = e21(16); c(40) = e21(9); c(41) = e21(20); c(42) = e21(17); c(43) = e21(10); c(44) = e21(21); c(45) = e21(23); c(46) = e21(18); c(47) = e21(11); c(48) = e21(22); c(49) = e21(24); c(50) = 0; c(51) = e31(12); c(52) = e31(5); c(53) = e31(2); c(54) = e31(1); c(55) = e31(13); c(56) = e31(6); c(57) = e31(3); c(58) = e31(15); c(59) = e31(8); c(60) = e31(19); c(61) = e31(14); c(62) = e31(7); c(63) = e31(4); c(64) = e31(16); c(65) = e31(9); c(66) = e31(20); c(67) = e31(17); c(68) = e31(10); c(69) = e31(21); c(70) = e31(23); c(71) = e31(18); c(72) = e31(11); c(73) = e31(22); c(74) = e31(24); c(75) = 0; c(76) = e41(12); c(77) = e41(5); c(78) = e41(2); c(79) = e41(1); c(80) = e41(13); c(81) = e41(6); c(82) = e41(3); c(83) = e41(15); c(84) = e41(8); c(85) = e41(19); c(86) = e41(14); c(87) = e41(7); c(88) = e41(4); c(89) = e41(16); c(90) = e41(9); c(91) = e41(20); c(92) = e41(17); c(93) = e41(10); c(94) = e41(21); c(95) = e41(23); c(96) = e41(18); c(97) = e41(11); c(98) = e41(22); c(99) = e41(24); c(100) = 0; M = zeros(575, 656); ci = [448, 1022, 1596, 3895, 4469, 5043, 7342, 7916, 8490, 10789, 11363, 13662, 19411, 19985, 20559, 22858, 23432, 24006, 26305, 26879, 27453, 29752, 30326, 32625, 38374, 38948, 39522, 41821, 42395, 42969, 45268, 45842, 46416, 48715, 49289, 51588, 57337, 57911, 58485, 60784, 61358, 61932, 64231, 64805, 67104, 72853, 73427, 74001, 76300, 76874, 79173, 84922, 85496, 87795, 93544, 104938, 105512, 106086, 108385, 108959, 109533, 111832, 112406, 112980, 115279, 115853, 118152, 123901, 124475, 125049, 127348, 127922, 128496, 130795, 131369, 131943, 134242, 134816, 137115, 142864, 143438, 144012, 146311, 146885, 147459, 149758, 150332, 152631, 158380, 158954, 159528, 161827, 162401, 164700, 170449, 171023, 173322, 179071, 190489, 191063, 191637, 193936, 194510, 195084, 197383, 197957, 198531, 200830, 201404, 203703, 209452, 210026, 210600, 212899, 213473, 214047, 216346, 216920, 219219, 224968, 225542, 226116, 228415, 228989, 231288, 237037, 237611, 239910, 245659, 257104, 257678, 258252, 260551, 261125, 261699, 263998, 264572, 266871, 272620, 273194, 273768, 276067, 276641, 278940, 284689, 285263, 287562, 293311, 304780, 305354, 305928, 308227, 308801, 311100, 316849, 317423, 319722, 325471, 336958, 337532, 339831, 345580, 357076]; M(ci) = c(1); ci = [1023, 1597, 2171, 4470, 5044, 5618, 7917, 8491, 9065, 11364, 11938, 14237, 19986, 20560, 21134, 23433, 24007, 24581, 26880, 27454, 28028, 30327, 30901, 33200, 38949, 39523, 40097, 42396, 42970, 43544, 45843, 46417, 46991, 49290, 49864, 52163, 57912, 58486, 59060, 61359, 61933, 62507, 64806, 65380, 67679, 73428, 74002, 74576, 76875, 77449, 79748, 85497, 86071, 88370, 94119, 105513, 106087, 106661, 108960, 109534, 110108, 112407, 112981, 113555, 115854, 116428, 118727, 124476, 125050, 125624, 127923, 128497, 129071, 131370, 131944, 132518, 134817, 135391, 137690, 143439, 144013, 144587, 146886, 147460, 148034, 150333, 150907, 153206, 158955, 159529, 160103, 162402, 162976, 165275, 171024, 171598, 173897, 179646, 191064, 191638, 192212, 194511, 195085, 195659, 197958, 198532, 199106, 201405, 201979, 204278, 210027, 210601, 211175, 213474, 214048, 214622, 216921, 217495, 219794, 225543, 226117, 226691, 228990, 229564, 231863, 237612, 238186, 240485, 246234, 257679, 258253, 258827, 261126, 261700, 262274, 264573, 265147, 267446, 273195, 273769, 274343, 276642, 277216, 279515, 285264, 285838, 288137, 293886, 305355, 305929, 306503, 308802, 309376, 311675, 317424, 317998, 320297, 326046, 337533, 338107, 340406, 346155, 357651]; M(ci) = c(2); ci = [1598, 2172, 2746, 5045, 5619, 6193, 8492, 9066, 9640, 11939, 12513, 14812, 20561, 21135, 21709, 24008, 24582, 25156, 27455, 28029, 28603, 30902, 31476, 33775, 39524, 40098, 40672, 42971, 43545, 44119, 46418, 46992, 47566, 49865, 50439, 52738, 58487, 59061, 59635, 61934, 62508, 63082, 65381, 65955, 68254, 74003, 74577, 75151, 77450, 78024, 80323, 86072, 86646, 88945, 94694, 106088, 106662, 107236, 109535, 110109, 110683, 112982, 113556, 114130, 116429, 117003, 119302, 125051, 125625, 126199, 128498, 129072, 129646, 131945, 132519, 133093, 135392, 135966, 138265, 144014, 144588, 145162, 147461, 148035, 148609, 150908, 151482, 153781, 159530, 160104, 160678, 162977, 163551, 165850, 171599, 172173, 174472, 180221, 191639, 192213, 192787, 195086, 195660, 196234, 198533, 199107, 199681, 201980, 202554, 204853, 210602, 211176, 211750, 214049, 214623, 215197, 217496, 218070, 220369, 226118, 226692, 227266, 229565, 230139, 232438, 238187, 238761, 241060, 246809, 258254, 258828, 259402, 261701, 262275, 262849, 265148, 265722, 268021, 273770, 274344, 274918, 277217, 277791, 280090, 285839, 286413, 288712, 294461, 305930, 306504, 307078, 309377, 309951, 312250, 317999, 318573, 320872, 326621, 338108, 338682, 340981, 346730, 358226]; M(ci) = c(3); ci = [2173, 2747, 3321, 5620, 6194, 6768, 9067, 9641, 10215, 12514, 13088, 15387, 21136, 21710, 22284, 24583, 25157, 25731, 28030, 28604, 29178, 31477, 32051, 34350, 40099, 40673, 41247, 43546, 44120, 44694, 46993, 47567, 48141, 50440, 51014, 53313, 59062, 59636, 60210, 62509, 63083, 63657, 65956, 66530, 68829, 74578, 75152, 75726, 78025, 78599, 80898, 86647, 87221, 89520, 95269, 106663, 107237, 107811, 110110, 110684, 111258, 113557, 114131, 114705, 117004, 117578, 119877, 125626, 126200, 126774, 129073, 129647, 130221, 132520, 133094, 133668, 135967, 136541, 138840, 144589, 145163, 145737, 148036, 148610, 149184, 151483, 152057, 154356, 160105, 160679, 161253, 163552, 164126, 166425, 172174, 172748, 175047, 180796, 192214, 192788, 193362, 195661, 196235, 196809, 199108, 199682, 200256, 202555, 203129, 205428, 211177, 211751, 212325, 214624, 215198, 215772, 218071, 218645, 220944, 226693, 227267, 227841, 230140, 230714, 233013, 238762, 239336, 241635, 247384, 258829, 259403, 259977, 262276, 262850, 263424, 265723, 266297, 268596, 274345, 274919, 275493, 277792, 278366, 280665, 286414, 286988, 289287, 295036, 306505, 307079, 307653, 309952, 310526, 312825, 318574, 319148, 321447, 327196, 338683, 339257, 341556, 347305, 358801]; M(ci) = c(4); ci = [4473, 5047, 5621, 7920, 8494, 9068, 10792, 11366, 11940, 13664, 14238, 15962, 23436, 24010, 24584, 26883, 27457, 28031, 29755, 30329, 30903, 32627, 33201, 34925, 42399, 42973, 43547, 45846, 46420, 46994, 48718, 49292, 49866, 51590, 52164, 53888, 61362, 61936, 62510, 64234, 64808, 65382, 67106, 67680, 69404, 76303, 76877, 77451, 79175, 79749, 81473, 87797, 88371, 90095, 95844, 108963, 109537, 110111, 112410, 112984, 113558, 115282, 115856, 116430, 118154, 118728, 120452, 127926, 128500, 129074, 131373, 131947, 132521, 134245, 134819, 135393, 137117, 137691, 139415, 146889, 147463, 148037, 149761, 150335, 150909, 152633, 153207, 154931, 161830, 162404, 162978, 164702, 165276, 167000, 173324, 173898, 175622, 181371, 194514, 195088, 195662, 197961, 198535, 199109, 200833, 201407, 201981, 203705, 204279, 206003, 213477, 214051, 214625, 216349, 216923, 217497, 219221, 219795, 221519, 228418, 228992, 229566, 231290, 231864, 233588, 239912, 240486, 242210, 247959, 261129, 261703, 262277, 264001, 264575, 265149, 266873, 267447, 269171, 276070, 276644, 277218, 278942, 279516, 281240, 287564, 288138, 289862, 295611, 308230, 308804, 309378, 311102, 311676, 313400, 319724, 320298, 322022, 327771, 339833, 340407, 342131, 347880, 359376]; M(ci) = c(5); ci = [5048, 5622, 6196, 8495, 9069, 9643, 11367, 11941, 12515, 14239, 14813, 16537, 24011, 24585, 25159, 27458, 28032, 28606, 30330, 30904, 31478, 33202, 33776, 35500, 42974, 43548, 44122, 46421, 46995, 47569, 49293, 49867, 50441, 52165, 52739, 54463, 61937, 62511, 63085, 64809, 65383, 65957, 67681, 68255, 69979, 76878, 77452, 78026, 79750, 80324, 82048, 88372, 88946, 90670, 96419, 109538, 110112, 110686, 112985, 113559, 114133, 115857, 116431, 117005, 118729, 119303, 121027, 128501, 129075, 129649, 131948, 132522, 133096, 134820, 135394, 135968, 137692, 138266, 139990, 147464, 148038, 148612, 150336, 150910, 151484, 153208, 153782, 155506, 162405, 162979, 163553, 165277, 165851, 167575, 173899, 174473, 176197, 181946, 195089, 195663, 196237, 198536, 199110, 199684, 201408, 201982, 202556, 204280, 204854, 206578, 214052, 214626, 215200, 216924, 217498, 218072, 219796, 220370, 222094, 228993, 229567, 230141, 231865, 232439, 234163, 240487, 241061, 242785, 248534, 261704, 262278, 262852, 264576, 265150, 265724, 267448, 268022, 269746, 276645, 277219, 277793, 279517, 280091, 281815, 288139, 288713, 290437, 296186, 308805, 309379, 309953, 311677, 312251, 313975, 320299, 320873, 322597, 328346, 340408, 340982, 342706, 348455, 359951]; M(ci) = c(6); ci = [5623, 6197, 6771, 9070, 9644, 10218, 11942, 12516, 13090, 14814, 15388, 17112, 24586, 25160, 25734, 28033, 28607, 29181, 30905, 31479, 32053, 33777, 34351, 36075, 43549, 44123, 44697, 46996, 47570, 48144, 49868, 50442, 51016, 52740, 53314, 55038, 62512, 63086, 63660, 65384, 65958, 66532, 68256, 68830, 70554, 77453, 78027, 78601, 80325, 80899, 82623, 88947, 89521, 91245, 96994, 110113, 110687, 111261, 113560, 114134, 114708, 116432, 117006, 117580, 119304, 119878, 121602, 129076, 129650, 130224, 132523, 133097, 133671, 135395, 135969, 136543, 138267, 138841, 140565, 148039, 148613, 149187, 150911, 151485, 152059, 153783, 154357, 156081, 162980, 163554, 164128, 165852, 166426, 168150, 174474, 175048, 176772, 182521, 195664, 196238, 196812, 199111, 199685, 200259, 201983, 202557, 203131, 204855, 205429, 207153, 214627, 215201, 215775, 217499, 218073, 218647, 220371, 220945, 222669, 229568, 230142, 230716, 232440, 233014, 234738, 241062, 241636, 243360, 249109, 262279, 262853, 263427, 265151, 265725, 266299, 268023, 268597, 270321, 277220, 277794, 278368, 280092, 280666, 282390, 288714, 289288, 291012, 296761, 309380, 309954, 310528, 312252, 312826, 314550, 320874, 321448, 323172, 328921, 340983, 341557, 343281, 349030, 360526]; M(ci) = c(7); ci = [8498, 9072, 9646, 11370, 11944, 12518, 13667, 14241, 14815, 15964, 16538, 17687, 27461, 28035, 28609, 30333, 30907, 31481, 32630, 33204, 33778, 34927, 35501, 36650, 46424, 46998, 47572, 49296, 49870, 50444, 51593, 52167, 52741, 53890, 54464, 55613, 64812, 65386, 65960, 67109, 67683, 68257, 69406, 69980, 71129, 79178, 79752, 80326, 81475, 82049, 83198, 90097, 90671, 91820, 97569, 112988, 113562, 114136, 115860, 116434, 117008, 118157, 118731, 119305, 120454, 121028, 122177, 131951, 132525, 133099, 134823, 135397, 135971, 137120, 137694, 138268, 139417, 139991, 141140, 150339, 150913, 151487, 152636, 153210, 153784, 154933, 155507, 156656, 164705, 165279, 165853, 167002, 167576, 168725, 175624, 176198, 177347, 183096, 198539, 199113, 199687, 201411, 201985, 202559, 203708, 204282, 204856, 206005, 206579, 207728, 216927, 217501, 218075, 219224, 219798, 220372, 221521, 222095, 223244, 231293, 231867, 232441, 233590, 234164, 235313, 242212, 242786, 243935, 249684, 264579, 265153, 265727, 266876, 267450, 268024, 269173, 269747, 270896, 278945, 279519, 280093, 281242, 281816, 282965, 289864, 290438, 291587, 297336, 311105, 311679, 312253, 313402, 313976, 315125, 322024, 322598, 323747, 329496, 342133, 342707, 343856, 349605, 361101]; M(ci) = c(8); ci = [9073, 9647, 10221, 11945, 12519, 13093, 14242, 14816, 15390, 16539, 17113, 18262, 28036, 28610, 29184, 30908, 31482, 32056, 33205, 33779, 34353, 35502, 36076, 37225, 46999, 47573, 48147, 49871, 50445, 51019, 52168, 52742, 53316, 54465, 55039, 56188, 65387, 65961, 66535, 67684, 68258, 68832, 69981, 70555, 71704, 79753, 80327, 80901, 82050, 82624, 83773, 90672, 91246, 92395, 98144, 113563, 114137, 114711, 116435, 117009, 117583, 118732, 119306, 119880, 121029, 121603, 122752, 132526, 133100, 133674, 135398, 135972, 136546, 137695, 138269, 138843, 139992, 140566, 141715, 150914, 151488, 152062, 153211, 153785, 154359, 155508, 156082, 157231, 165280, 165854, 166428, 167577, 168151, 169300, 176199, 176773, 177922, 183671, 199114, 199688, 200262, 201986, 202560, 203134, 204283, 204857, 205431, 206580, 207154, 208303, 217502, 218076, 218650, 219799, 220373, 220947, 222096, 222670, 223819, 231868, 232442, 233016, 234165, 234739, 235888, 242787, 243361, 244510, 250259, 265154, 265728, 266302, 267451, 268025, 268599, 269748, 270322, 271471, 279520, 280094, 280668, 281817, 282391, 283540, 290439, 291013, 292162, 297911, 311680, 312254, 312828, 313977, 314551, 315700, 322599, 323173, 324322, 330071, 342708, 343282, 344431, 350180, 361676]; M(ci) = c(9); ci = [11948, 12522, 13096, 14245, 14819, 15393, 15967, 16541, 17115, 17689, 18263, 18837, 30911, 31485, 32059, 33208, 33782, 34356, 34930, 35504, 36078, 36652, 37226, 37800, 49874, 50448, 51022, 52171, 52745, 53319, 53893, 54467, 55041, 55615, 56189, 56763, 67687, 68261, 68835, 69409, 69983, 70557, 71131, 71705, 72279, 81478, 82052, 82626, 83200, 83774, 84348, 91822, 92396, 92970, 98719, 116438, 117012, 117586, 118735, 119309, 119883, 120457, 121031, 121605, 122179, 122753, 123327, 135401, 135975, 136549, 137698, 138272, 138846, 139420, 139994, 140568, 141142, 141716, 142290, 153214, 153788, 154362, 154936, 155510, 156084, 156658, 157232, 157806, 167005, 167579, 168153, 168727, 169301, 169875, 177349, 177923, 178497, 184246, 201989, 202563, 203137, 204286, 204860, 205434, 206008, 206582, 207156, 207730, 208304, 208878, 219802, 220376, 220950, 221524, 222098, 222672, 223246, 223820, 224394, 233593, 234167, 234741, 235315, 235889, 236463, 243937, 244511, 245085, 250834, 267454, 268028, 268602, 269176, 269750, 270324, 270898, 271472, 272046, 281245, 281819, 282393, 282967, 283541, 284115, 291589, 292163, 292737, 298486, 313405, 313979, 314553, 315127, 315701, 316275, 323749, 324323, 324897, 330646, 343858, 344432, 345006, 350755, 362251]; M(ci) = c(10); ci = [23448, 24022, 24596, 26895, 27469, 28043, 29767, 30341, 30915, 32639, 33213, 34937, 42411, 42985, 43559, 45858, 46432, 47006, 48730, 49304, 49878, 51602, 52176, 53900, 57924, 58498, 59072, 61371, 61945, 62519, 64243, 64817, 65391, 67115, 67689, 69413, 73437, 74011, 74585, 76309, 76883, 77457, 79181, 79755, 81479, 84928, 85502, 86076, 87800, 88374, 90098, 93547, 94121, 95845, 99294, 127938, 128512, 129086, 131385, 131959, 132533, 134257, 134831, 135405, 137129, 137703, 139427, 143451, 144025, 144599, 146898, 147472, 148046, 149770, 150344, 150918, 152642, 153216, 154940, 158964, 159538, 160112, 161836, 162410, 162984, 164708, 165282, 167006, 170455, 171029, 171603, 173327, 173901, 175625, 179074, 179648, 181372, 184821, 210039, 210613, 211187, 213486, 214060, 214634, 216358, 216932, 217506, 219230, 219804, 221528, 225552, 226126, 226700, 228424, 228998, 229572, 231296, 231870, 233594, 237043, 237617, 238191, 239915, 240489, 242213, 245662, 246236, 247960, 251409, 273204, 273778, 274352, 276076, 276650, 277224, 278948, 279522, 281246, 284695, 285269, 285843, 287567, 288141, 289865, 293314, 293888, 295612, 299061, 316855, 317429, 318003, 319727, 320301, 322025, 325474, 326048, 327772, 331221, 345583, 346157, 347881, 351330, 362826]; M(ci) = c(11); ci = [24023, 24597, 25171, 27470, 28044, 28618, 30342, 30916, 31490, 33214, 33788, 35512, 42986, 43560, 44134, 46433, 47007, 47581, 49305, 49879, 50453, 52177, 52751, 54475, 58499, 59073, 59647, 61946, 62520, 63094, 64818, 65392, 65966, 67690, 68264, 69988, 74012, 74586, 75160, 76884, 77458, 78032, 79756, 80330, 82054, 85503, 86077, 86651, 88375, 88949, 90673, 94122, 94696, 96420, 99869, 128513, 129087, 129661, 131960, 132534, 133108, 134832, 135406, 135980, 137704, 138278, 140002, 144026, 144600, 145174, 147473, 148047, 148621, 150345, 150919, 151493, 153217, 153791, 155515, 159539, 160113, 160687, 162411, 162985, 163559, 165283, 165857, 167581, 171030, 171604, 172178, 173902, 174476, 176200, 179649, 180223, 181947, 185396, 210614, 211188, 211762, 214061, 214635, 215209, 216933, 217507, 218081, 219805, 220379, 222103, 226127, 226701, 227275, 228999, 229573, 230147, 231871, 232445, 234169, 237618, 238192, 238766, 240490, 241064, 242788, 246237, 246811, 248535, 251984, 273779, 274353, 274927, 276651, 277225, 277799, 279523, 280097, 281821, 285270, 285844, 286418, 288142, 288716, 290440, 293889, 294463, 296187, 299636, 317430, 318004, 318578, 320302, 320876, 322600, 326049, 326623, 328347, 331796, 346158, 346732, 348456, 351905, 363401]; M(ci) = c(12); ci = [24598, 25172, 25746, 28045, 28619, 29193, 30917, 31491, 32065, 33789, 34363, 36087, 43561, 44135, 44709, 47008, 47582, 48156, 49880, 50454, 51028, 52752, 53326, 55050, 59074, 59648, 60222, 62521, 63095, 63669, 65393, 65967, 66541, 68265, 68839, 70563, 74587, 75161, 75735, 77459, 78033, 78607, 80331, 80905, 82629, 86078, 86652, 87226, 88950, 89524, 91248, 94697, 95271, 96995, 100444, 129088, 129662, 130236, 132535, 133109, 133683, 135407, 135981, 136555, 138279, 138853, 140577, 144601, 145175, 145749, 148048, 148622, 149196, 150920, 151494, 152068, 153792, 154366, 156090, 160114, 160688, 161262, 162986, 163560, 164134, 165858, 166432, 168156, 171605, 172179, 172753, 174477, 175051, 176775, 180224, 180798, 182522, 185971, 211189, 211763, 212337, 214636, 215210, 215784, 217508, 218082, 218656, 220380, 220954, 222678, 226702, 227276, 227850, 229574, 230148, 230722, 232446, 233020, 234744, 238193, 238767, 239341, 241065, 241639, 243363, 246812, 247386, 249110, 252559, 274354, 274928, 275502, 277226, 277800, 278374, 280098, 280672, 282396, 285845, 286419, 286993, 288717, 289291, 291015, 294464, 295038, 296762, 300211, 318005, 318579, 319153, 320877, 321451, 323175, 326624, 327198, 328922, 332371, 346733, 347307, 349031, 352480, 363976]; M(ci) = c(13); ci = [27473, 28047, 28621, 30345, 30919, 31493, 32642, 33216, 33790, 34939, 35513, 36662, 46436, 47010, 47584, 49308, 49882, 50456, 51605, 52179, 52753, 53902, 54476, 55625, 61949, 62523, 63097, 64821, 65395, 65969, 67118, 67692, 68266, 69415, 69989, 71138, 76887, 77461, 78035, 79184, 79758, 80332, 81481, 82055, 83204, 87803, 88377, 88951, 90100, 90674, 91823, 95847, 96421, 97570, 101019, 131963, 132537, 133111, 134835, 135409, 135983, 137132, 137706, 138280, 139429, 140003, 141152, 147476, 148050, 148624, 150348, 150922, 151496, 152645, 153219, 153793, 154942, 155516, 156665, 162414, 162988, 163562, 164711, 165285, 165859, 167008, 167582, 168731, 173330, 173904, 174478, 175627, 176201, 177350, 181374, 181948, 183097, 186546, 214064, 214638, 215212, 216936, 217510, 218084, 219233, 219807, 220381, 221530, 222104, 223253, 229002, 229576, 230150, 231299, 231873, 232447, 233596, 234170, 235319, 239918, 240492, 241066, 242215, 242789, 243938, 247962, 248536, 249685, 253134, 276654, 277228, 277802, 278951, 279525, 280099, 281248, 281822, 282971, 287570, 288144, 288718, 289867, 290441, 291590, 295614, 296188, 297337, 300786, 319730, 320304, 320878, 322027, 322601, 323750, 327774, 328348, 329497, 332946, 347883, 348457, 349606, 353055, 364551]; M(ci) = c(14); ci = [28048, 28622, 29196, 30920, 31494, 32068, 33217, 33791, 34365, 35514, 36088, 37237, 47011, 47585, 48159, 49883, 50457, 51031, 52180, 52754, 53328, 54477, 55051, 56200, 62524, 63098, 63672, 65396, 65970, 66544, 67693, 68267, 68841, 69990, 70564, 71713, 77462, 78036, 78610, 79759, 80333, 80907, 82056, 82630, 83779, 88378, 88952, 89526, 90675, 91249, 92398, 96422, 96996, 98145, 101594, 132538, 133112, 133686, 135410, 135984, 136558, 137707, 138281, 138855, 140004, 140578, 141727, 148051, 148625, 149199, 150923, 151497, 152071, 153220, 153794, 154368, 155517, 156091, 157240, 162989, 163563, 164137, 165286, 165860, 166434, 167583, 168157, 169306, 173905, 174479, 175053, 176202, 176776, 177925, 181949, 182523, 183672, 187121, 214639, 215213, 215787, 217511, 218085, 218659, 219808, 220382, 220956, 222105, 222679, 223828, 229577, 230151, 230725, 231874, 232448, 233022, 234171, 234745, 235894, 240493, 241067, 241641, 242790, 243364, 244513, 248537, 249111, 250260, 253709, 277229, 277803, 278377, 279526, 280100, 280674, 281823, 282397, 283546, 288145, 288719, 289293, 290442, 291016, 292165, 296189, 296763, 297912, 301361, 320305, 320879, 321453, 322602, 323176, 324325, 328349, 328923, 330072, 333521, 348458, 349032, 350181, 353630, 365126]; M(ci) = c(15); ci = [30923, 31497, 32071, 33220, 33794, 34368, 34942, 35516, 36090, 36664, 37238, 37812, 49886, 50460, 51034, 52183, 52757, 53331, 53905, 54479, 55053, 55627, 56201, 56775, 65399, 65973, 66547, 67696, 68270, 68844, 69418, 69992, 70566, 71140, 71714, 72288, 79762, 80336, 80910, 81484, 82058, 82632, 83206, 83780, 84354, 90103, 90677, 91251, 91825, 92399, 92973, 97572, 98146, 98720, 102169, 135413, 135987, 136561, 137710, 138284, 138858, 139432, 140006, 140580, 141154, 141728, 142302, 150926, 151500, 152074, 153223, 153797, 154371, 154945, 155519, 156093, 156667, 157241, 157815, 165289, 165863, 166437, 167011, 167585, 168159, 168733, 169307, 169881, 175630, 176204, 176778, 177352, 177926, 178500, 183099, 183673, 184247, 187696, 217514, 218088, 218662, 219811, 220385, 220959, 221533, 222107, 222681, 223255, 223829, 224403, 231877, 232451, 233025, 233599, 234173, 234747, 235321, 235895, 236469, 242218, 242792, 243366, 243940, 244514, 245088, 249687, 250261, 250835, 254284, 279529, 280103, 280677, 281251, 281825, 282399, 282973, 283547, 284121, 289870, 290444, 291018, 291592, 292166, 292740, 297339, 297913, 298487, 301936, 322030, 322604, 323178, 323752, 324326, 324900, 329499, 330073, 330647, 334096, 349608, 350182, 350756, 354205, 365701]; M(ci) = c(16); ci = [46448, 47022, 47596, 49320, 49894, 50468, 51617, 52191, 52765, 53914, 54488, 55637, 61961, 62535, 63109, 64833, 65407, 65981, 67130, 67704, 68278, 69427, 70001, 71150, 74024, 74598, 75172, 76896, 77470, 78044, 79193, 79767, 80341, 81490, 82064, 83213, 85512, 86086, 86660, 87809, 88383, 88957, 90106, 90680, 91829, 93553, 94127, 94701, 95850, 96424, 97573, 99297, 99871, 101020, 102744, 147488, 148062, 148636, 150360, 150934, 151508, 152657, 153231, 153805, 154954, 155528, 156677, 159551, 160125, 160699, 162423, 162997, 163571, 164720, 165294, 165868, 167017, 167591, 168740, 171039, 171613, 172187, 173336, 173910, 174484, 175633, 176207, 177356, 179080, 179654, 180228, 181377, 181951, 183100, 184824, 185398, 186547, 188271, 226139, 226713, 227287, 229011, 229585, 230159, 231308, 231882, 232456, 233605, 234179, 235328, 237627, 238201, 238775, 239924, 240498, 241072, 242221, 242795, 243944, 245668, 246242, 246816, 247965, 248539, 249688, 251412, 251986, 253135, 254859, 285279, 285853, 286427, 287576, 288150, 288724, 289873, 290447, 291596, 293320, 293894, 294468, 295617, 296191, 297340, 299064, 299638, 300787, 302511, 325480, 326054, 326628, 327777, 328351, 329500, 331224, 331798, 332947, 334671, 351333, 351907, 353056, 354780, 366276]; M(ci) = c(17); ci = [47023, 47597, 48171, 49895, 50469, 51043, 52192, 52766, 53340, 54489, 55063, 56212, 62536, 63110, 63684, 65408, 65982, 66556, 67705, 68279, 68853, 70002, 70576, 71725, 74599, 75173, 75747, 77471, 78045, 78619, 79768, 80342, 80916, 82065, 82639, 83788, 86087, 86661, 87235, 88384, 88958, 89532, 90681, 91255, 92404, 94128, 94702, 95276, 96425, 96999, 98148, 99872, 100446, 101595, 103319, 148063, 148637, 149211, 150935, 151509, 152083, 153232, 153806, 154380, 155529, 156103, 157252, 160126, 160700, 161274, 162998, 163572, 164146, 165295, 165869, 166443, 167592, 168166, 169315, 171614, 172188, 172762, 173911, 174485, 175059, 176208, 176782, 177931, 179655, 180229, 180803, 181952, 182526, 183675, 185399, 185973, 187122, 188846, 226714, 227288, 227862, 229586, 230160, 230734, 231883, 232457, 233031, 234180, 234754, 235903, 238202, 238776, 239350, 240499, 241073, 241647, 242796, 243370, 244519, 246243, 246817, 247391, 248540, 249114, 250263, 251987, 252561, 253710, 255434, 285854, 286428, 287002, 288151, 288725, 289299, 290448, 291022, 292171, 293895, 294469, 295043, 296192, 296766, 297915, 299639, 300213, 301362, 303086, 326055, 326629, 327203, 328352, 328926, 330075, 331799, 332373, 333522, 335246, 351908, 352482, 353631, 355355, 366851]; M(ci) = c(18); ci = [49898, 50472, 51046, 52195, 52769, 53343, 53917, 54491, 55065, 55639, 56213, 56787, 65411, 65985, 66559, 67708, 68282, 68856, 69430, 70004, 70578, 71152, 71726, 72300, 77474, 78048, 78622, 79771, 80345, 80919, 81493, 82067, 82641, 83215, 83789, 84363, 88387, 88961, 89535, 90109, 90683, 91257, 91831, 92405, 92979, 95853, 96427, 97001, 97575, 98149, 98723, 101022, 101596, 102170, 103894, 150938, 151512, 152086, 153235, 153809, 154383, 154957, 155531, 156105, 156679, 157253, 157827, 163001, 163575, 164149, 165298, 165872, 166446, 167020, 167594, 168168, 168742, 169316, 169890, 173914, 174488, 175062, 175636, 176210, 176784, 177358, 177932, 178506, 181380, 181954, 182528, 183102, 183676, 184250, 186549, 187123, 187697, 189421, 229589, 230163, 230737, 231886, 232460, 233034, 233608, 234182, 234756, 235330, 235904, 236478, 240502, 241076, 241650, 242224, 242798, 243372, 243946, 244520, 245094, 247968, 248542, 249116, 249690, 250264, 250838, 253137, 253711, 254285, 256009, 288154, 288728, 289302, 289876, 290450, 291024, 291598, 292172, 292746, 295620, 296194, 296768, 297342, 297916, 298490, 300789, 301363, 301937, 303661, 327780, 328354, 328928, 329502, 330076, 330650, 332949, 333523, 334097, 335821, 353058, 353632, 354206, 355930, 367426]; M(ci) = c(19); ci = [65423, 65997, 66571, 67720, 68294, 68868, 69442, 70016, 70590, 71164, 71738, 72312, 77486, 78060, 78634, 79783, 80357, 80931, 81505, 82079, 82653, 83227, 83801, 84375, 86099, 86673, 87247, 88396, 88970, 89544, 90118, 90692, 91266, 91840, 92414, 92988, 94137, 94711, 95285, 95859, 96433, 97007, 97581, 98155, 98729, 99303, 99877, 100451, 101025, 101599, 102173, 102747, 103321, 103895, 104469, 163013, 163587, 164161, 165310, 165884, 166458, 167032, 167606, 168180, 168754, 169328, 169902, 171626, 172200, 172774, 173923, 174497, 175071, 175645, 176219, 176793, 177367, 177941, 178515, 179664, 180238, 180812, 181386, 181960, 182534, 183108, 183682, 184256, 184830, 185404, 185978, 186552, 187126, 187700, 188274, 188848, 189422, 189996, 238214, 238788, 239362, 240511, 241085, 241659, 242233, 242807, 243381, 243955, 244529, 245103, 246252, 246826, 247400, 247974, 248548, 249122, 249696, 250270, 250844, 251418, 251992, 252566, 253140, 253714, 254288, 254862, 255436, 256010, 256584, 293904, 294478, 295052, 295626, 296200, 296774, 297348, 297922, 298496, 299070, 299644, 300218, 300792, 301366, 301940, 302514, 303088, 303662, 304236, 331230, 331804, 332378, 332952, 333526, 334100, 334674, 335248, 335822, 336396, 354783, 355357, 355931, 356505, 368001]; M(ci) = c(20); ci = [198823, 199397, 199971, 201695, 202269, 202843, 203992, 204566, 205140, 206289, 206863, 208012, 214336, 214910, 215484, 217208, 217782, 218356, 219505, 220079, 220653, 221802, 222376, 223525, 226399, 226973, 227547, 229271, 229845, 230419, 231568, 232142, 232716, 233865, 234439, 235588, 237887, 238461, 239035, 240184, 240758, 241332, 242481, 243055, 244204, 245928, 246502, 247076, 248225, 248799, 249948, 251672, 252246, 253395, 255119, 261913, 262487, 263061, 264785, 265359, 265933, 267082, 267656, 268230, 269379, 269953, 271102, 273976, 274550, 275124, 276848, 277422, 277996, 279145, 279719, 280293, 281442, 282016, 283165, 285464, 286038, 286612, 287761, 288335, 288909, 290058, 290632, 291781, 293505, 294079, 294653, 295802, 296376, 297525, 299249, 299823, 300972, 302696, 306064, 306638, 307212, 308936, 309510, 310084, 311233, 311807, 312381, 313530, 314104, 315253, 317552, 318126, 318700, 319849, 320423, 320997, 322146, 322720, 323869, 325593, 326167, 326741, 327890, 328464, 329613, 331337, 331911, 333060, 334784, 337604, 338178, 338752, 339901, 340475, 341049, 342198, 342772, 343921, 345645, 346219, 346793, 347942, 348516, 349665, 351389, 351963, 353112, 354836, 357105, 357679, 358253, 359402, 359976, 361125, 362849, 363423, 364572, 366296, 368583, 369157, 370306, 372030, 374326]; M(ci) = c(21); ci = [199398, 199972, 200546, 202270, 202844, 203418, 204567, 205141, 205715, 206864, 207438, 208587, 214911, 215485, 216059, 217783, 218357, 218931, 220080, 220654, 221228, 222377, 222951, 224100, 226974, 227548, 228122, 229846, 230420, 230994, 232143, 232717, 233291, 234440, 235014, 236163, 238462, 239036, 239610, 240759, 241333, 241907, 243056, 243630, 244779, 246503, 247077, 247651, 248800, 249374, 250523, 252247, 252821, 253970, 255694, 262488, 263062, 263636, 265360, 265934, 266508, 267657, 268231, 268805, 269954, 270528, 271677, 274551, 275125, 275699, 277423, 277997, 278571, 279720, 280294, 280868, 282017, 282591, 283740, 286039, 286613, 287187, 288336, 288910, 289484, 290633, 291207, 292356, 294080, 294654, 295228, 296377, 296951, 298100, 299824, 300398, 301547, 303271, 306639, 307213, 307787, 309511, 310085, 310659, 311808, 312382, 312956, 314105, 314679, 315828, 318127, 318701, 319275, 320424, 320998, 321572, 322721, 323295, 324444, 326168, 326742, 327316, 328465, 329039, 330188, 331912, 332486, 333635, 335359, 338179, 338753, 339327, 340476, 341050, 341624, 342773, 343347, 344496, 346220, 346794, 347368, 348517, 349091, 350240, 351964, 352538, 353687, 355411, 357680, 358254, 358828, 359977, 360551, 361700, 363424, 363998, 365147, 366871, 369158, 369732, 370881, 372605, 374901]; M(ci) = c(22); ci = [202273, 202847, 203421, 204570, 205144, 205718, 206292, 206866, 207440, 208014, 208588, 209162, 217786, 218360, 218934, 220083, 220657, 221231, 221805, 222379, 222953, 223527, 224101, 224675, 229849, 230423, 230997, 232146, 232720, 233294, 233868, 234442, 235016, 235590, 236164, 236738, 240762, 241336, 241910, 242484, 243058, 243632, 244206, 244780, 245354, 248228, 248802, 249376, 249950, 250524, 251098, 253397, 253971, 254545, 256269, 265363, 265937, 266511, 267660, 268234, 268808, 269382, 269956, 270530, 271104, 271678, 272252, 277426, 278000, 278574, 279723, 280297, 280871, 281445, 282019, 282593, 283167, 283741, 284315, 288339, 288913, 289487, 290061, 290635, 291209, 291783, 292357, 292931, 295805, 296379, 296953, 297527, 298101, 298675, 300974, 301548, 302122, 303846, 309514, 310088, 310662, 311811, 312385, 312959, 313533, 314107, 314681, 315255, 315829, 316403, 320427, 321001, 321575, 322149, 322723, 323297, 323871, 324445, 325019, 327893, 328467, 329041, 329615, 330189, 330763, 333062, 333636, 334210, 335934, 340479, 341053, 341627, 342201, 342775, 343349, 343923, 344497, 345071, 347945, 348519, 349093, 349667, 350241, 350815, 353114, 353688, 354262, 355986, 359405, 359979, 360553, 361127, 361701, 362275, 364574, 365148, 365722, 367446, 370308, 370882, 371456, 373180, 375476]; M(ci) = c(23); ci = [217798, 218372, 218946, 220095, 220669, 221243, 221817, 222391, 222965, 223539, 224113, 224687, 229861, 230435, 231009, 232158, 232732, 233306, 233880, 234454, 235028, 235602, 236176, 236750, 238474, 239048, 239622, 240771, 241345, 241919, 242493, 243067, 243641, 244215, 244789, 245363, 246512, 247086, 247660, 248234, 248808, 249382, 249956, 250530, 251104, 251678, 252252, 252826, 253400, 253974, 254548, 255122, 255696, 256270, 256844, 277438, 278012, 278586, 279735, 280309, 280883, 281457, 282031, 282605, 283179, 283753, 284327, 286051, 286625, 287199, 288348, 288922, 289496, 290070, 290644, 291218, 291792, 292366, 292940, 294089, 294663, 295237, 295811, 296385, 296959, 297533, 298107, 298681, 299255, 299829, 300403, 300977, 301551, 302125, 302699, 303273, 303847, 304421, 318139, 318713, 319287, 320436, 321010, 321584, 322158, 322732, 323306, 323880, 324454, 325028, 326177, 326751, 327325, 327899, 328473, 329047, 329621, 330195, 330769, 331343, 331917, 332491, 333065, 333639, 334213, 334787, 335361, 335935, 336509, 346229, 346803, 347377, 347951, 348525, 349099, 349673, 350247, 350821, 351395, 351969, 352543, 353117, 353691, 354265, 354839, 355413, 355987, 356561, 362855, 363429, 364003, 364577, 365151, 365725, 366299, 366873, 367447, 368021, 372033, 372607, 373181, 373755, 376051]; M(ci) = c(24); ci = [265523, 266097, 266671, 267820, 268394, 268968, 269542, 270116, 270690, 271264, 271838, 272412, 277586, 278160, 278734, 279883, 280457, 281031, 281605, 282179, 282753, 283327, 283901, 284475, 286199, 286773, 287347, 288496, 289070, 289644, 290218, 290792, 291366, 291940, 292514, 293088, 294237, 294811, 295385, 295959, 296533, 297107, 297681, 298255, 298829, 299403, 299977, 300551, 301125, 301699, 302273, 302847, 303421, 303995, 304569, 309638, 310212, 310786, 311935, 312509, 313083, 313657, 314231, 314805, 315379, 315953, 316527, 318251, 318825, 319399, 320548, 321122, 321696, 322270, 322844, 323418, 323992, 324566, 325140, 326289, 326863, 327437, 328011, 328585, 329159, 329733, 330307, 330881, 331455, 332029, 332603, 333177, 333751, 334325, 334899, 335473, 336047, 336621, 338264, 338838, 339412, 340561, 341135, 341709, 342283, 342857, 343431, 344005, 344579, 345153, 346302, 346876, 347450, 348024, 348598, 349172, 349746, 350320, 350894, 351468, 352042, 352616, 353190, 353764, 354338, 354912, 355486, 356060, 356634, 357729, 358303, 358877, 359451, 360025, 360599, 361173, 361747, 362321, 362895, 363469, 364043, 364617, 365191, 365765, 366339, 366913, 367487, 368061, 368605, 369179, 369753, 370327, 370901, 371475, 372049, 372623, 373197, 373771, 374333, 374907, 375481, 376055, 376626]; M(ci) = c(25); ci = [503, 1077, 1651, 3950, 4524, 5098, 7397, 7971, 8545, 10844, 11418, 13717, 19466, 20040, 20614, 22913, 23487, 24061, 26360, 26934, 27508, 29807, 30381, 32680, 38429, 39003, 39577, 41876, 42450, 43024, 45323, 45897, 46471, 48770, 49344, 51643, 57392, 57966, 58540, 60839, 61413, 61987, 64286, 64860, 67159, 72908, 73482, 74056, 76355, 76929, 79228, 84977, 85551, 87850, 93599, 104981, 105555, 106129, 108428, 109002, 109576, 111875, 112449, 113023, 115322, 115896, 118195, 123944, 124518, 125092, 127391, 127965, 128539, 130838, 131412, 131986, 134285, 134859, 137158, 142907, 143481, 144055, 146354, 146928, 147502, 149801, 150375, 152674, 158423, 158997, 159571, 161870, 162444, 164743, 170492, 171066, 173365, 179114, 190520, 191094, 191668, 193967, 194541, 195115, 197414, 197988, 198562, 200861, 201435, 203734, 209483, 210057, 210631, 212930, 213504, 214078, 216377, 216951, 219250, 224999, 225573, 226147, 228446, 229020, 231319, 237068, 237642, 239941, 245690, 257123, 257697, 258271, 260570, 261144, 261718, 264017, 264591, 266890, 272639, 273213, 273787, 276086, 276660, 278959, 284708, 285282, 287581, 293330, 304790, 305364, 305938, 308237, 308811, 311110, 316859, 317433, 319732, 325481, 336962, 337536, 339835, 345584, 357077]; M(ci) = c(26); ci = [1078, 1652, 2226, 4525, 5099, 5673, 7972, 8546, 9120, 11419, 11993, 14292, 20041, 20615, 21189, 23488, 24062, 24636, 26935, 27509, 28083, 30382, 30956, 33255, 39004, 39578, 40152, 42451, 43025, 43599, 45898, 46472, 47046, 49345, 49919, 52218, 57967, 58541, 59115, 61414, 61988, 62562, 64861, 65435, 67734, 73483, 74057, 74631, 76930, 77504, 79803, 85552, 86126, 88425, 94174, 105556, 106130, 106704, 109003, 109577, 110151, 112450, 113024, 113598, 115897, 116471, 118770, 124519, 125093, 125667, 127966, 128540, 129114, 131413, 131987, 132561, 134860, 135434, 137733, 143482, 144056, 144630, 146929, 147503, 148077, 150376, 150950, 153249, 158998, 159572, 160146, 162445, 163019, 165318, 171067, 171641, 173940, 179689, 191095, 191669, 192243, 194542, 195116, 195690, 197989, 198563, 199137, 201436, 202010, 204309, 210058, 210632, 211206, 213505, 214079, 214653, 216952, 217526, 219825, 225574, 226148, 226722, 229021, 229595, 231894, 237643, 238217, 240516, 246265, 257698, 258272, 258846, 261145, 261719, 262293, 264592, 265166, 267465, 273214, 273788, 274362, 276661, 277235, 279534, 285283, 285857, 288156, 293905, 305365, 305939, 306513, 308812, 309386, 311685, 317434, 318008, 320307, 326056, 337537, 338111, 340410, 346159, 357652]; M(ci) = c(27); ci = [1653, 2227, 2801, 5100, 5674, 6248, 8547, 9121, 9695, 11994, 12568, 14867, 20616, 21190, 21764, 24063, 24637, 25211, 27510, 28084, 28658, 30957, 31531, 33830, 39579, 40153, 40727, 43026, 43600, 44174, 46473, 47047, 47621, 49920, 50494, 52793, 58542, 59116, 59690, 61989, 62563, 63137, 65436, 66010, 68309, 74058, 74632, 75206, 77505, 78079, 80378, 86127, 86701, 89000, 94749, 106131, 106705, 107279, 109578, 110152, 110726, 113025, 113599, 114173, 116472, 117046, 119345, 125094, 125668, 126242, 128541, 129115, 129689, 131988, 132562, 133136, 135435, 136009, 138308, 144057, 144631, 145205, 147504, 148078, 148652, 150951, 151525, 153824, 159573, 160147, 160721, 163020, 163594, 165893, 171642, 172216, 174515, 180264, 191670, 192244, 192818, 195117, 195691, 196265, 198564, 199138, 199712, 202011, 202585, 204884, 210633, 211207, 211781, 214080, 214654, 215228, 217527, 218101, 220400, 226149, 226723, 227297, 229596, 230170, 232469, 238218, 238792, 241091, 246840, 258273, 258847, 259421, 261720, 262294, 262868, 265167, 265741, 268040, 273789, 274363, 274937, 277236, 277810, 280109, 285858, 286432, 288731, 294480, 305940, 306514, 307088, 309387, 309961, 312260, 318009, 318583, 320882, 326631, 338112, 338686, 340985, 346734, 358227]; M(ci) = c(28); ci = [2228, 2802, 3376, 5675, 6249, 6823, 9122, 9696, 10270, 12569, 13143, 15442, 21191, 21765, 22339, 24638, 25212, 25786, 28085, 28659, 29233, 31532, 32106, 34405, 40154, 40728, 41302, 43601, 44175, 44749, 47048, 47622, 48196, 50495, 51069, 53368, 59117, 59691, 60265, 62564, 63138, 63712, 66011, 66585, 68884, 74633, 75207, 75781, 78080, 78654, 80953, 86702, 87276, 89575, 95324, 106706, 107280, 107854, 110153, 110727, 111301, 113600, 114174, 114748, 117047, 117621, 119920, 125669, 126243, 126817, 129116, 129690, 130264, 132563, 133137, 133711, 136010, 136584, 138883, 144632, 145206, 145780, 148079, 148653, 149227, 151526, 152100, 154399, 160148, 160722, 161296, 163595, 164169, 166468, 172217, 172791, 175090, 180839, 192245, 192819, 193393, 195692, 196266, 196840, 199139, 199713, 200287, 202586, 203160, 205459, 211208, 211782, 212356, 214655, 215229, 215803, 218102, 218676, 220975, 226724, 227298, 227872, 230171, 230745, 233044, 238793, 239367, 241666, 247415, 258848, 259422, 259996, 262295, 262869, 263443, 265742, 266316, 268615, 274364, 274938, 275512, 277811, 278385, 280684, 286433, 287007, 289306, 295055, 306515, 307089, 307663, 309962, 310536, 312835, 318584, 319158, 321457, 327206, 338687, 339261, 341560, 347309, 358802]; M(ci) = c(29); ci = [4528, 5102, 5676, 7975, 8549, 9123, 10847, 11421, 11995, 13719, 14293, 16017, 23491, 24065, 24639, 26938, 27512, 28086, 29810, 30384, 30958, 32682, 33256, 34980, 42454, 43028, 43602, 45901, 46475, 47049, 48773, 49347, 49921, 51645, 52219, 53943, 61417, 61991, 62565, 64289, 64863, 65437, 67161, 67735, 69459, 76358, 76932, 77506, 79230, 79804, 81528, 87852, 88426, 90150, 95899, 109006, 109580, 110154, 112453, 113027, 113601, 115325, 115899, 116473, 118197, 118771, 120495, 127969, 128543, 129117, 131416, 131990, 132564, 134288, 134862, 135436, 137160, 137734, 139458, 146932, 147506, 148080, 149804, 150378, 150952, 152676, 153250, 154974, 161873, 162447, 163021, 164745, 165319, 167043, 173367, 173941, 175665, 181414, 194545, 195119, 195693, 197992, 198566, 199140, 200864, 201438, 202012, 203736, 204310, 206034, 213508, 214082, 214656, 216380, 216954, 217528, 219252, 219826, 221550, 228449, 229023, 229597, 231321, 231895, 233619, 239943, 240517, 242241, 247990, 261148, 261722, 262296, 264020, 264594, 265168, 266892, 267466, 269190, 276089, 276663, 277237, 278961, 279535, 281259, 287583, 288157, 289881, 295630, 308240, 308814, 309388, 311112, 311686, 313410, 319734, 320308, 322032, 327781, 339837, 340411, 342135, 347884, 359377]; M(ci) = c(30); ci = [5103, 5677, 6251, 8550, 9124, 9698, 11422, 11996, 12570, 14294, 14868, 16592, 24066, 24640, 25214, 27513, 28087, 28661, 30385, 30959, 31533, 33257, 33831, 35555, 43029, 43603, 44177, 46476, 47050, 47624, 49348, 49922, 50496, 52220, 52794, 54518, 61992, 62566, 63140, 64864, 65438, 66012, 67736, 68310, 70034, 76933, 77507, 78081, 79805, 80379, 82103, 88427, 89001, 90725, 96474, 109581, 110155, 110729, 113028, 113602, 114176, 115900, 116474, 117048, 118772, 119346, 121070, 128544, 129118, 129692, 131991, 132565, 133139, 134863, 135437, 136011, 137735, 138309, 140033, 147507, 148081, 148655, 150379, 150953, 151527, 153251, 153825, 155549, 162448, 163022, 163596, 165320, 165894, 167618, 173942, 174516, 176240, 181989, 195120, 195694, 196268, 198567, 199141, 199715, 201439, 202013, 202587, 204311, 204885, 206609, 214083, 214657, 215231, 216955, 217529, 218103, 219827, 220401, 222125, 229024, 229598, 230172, 231896, 232470, 234194, 240518, 241092, 242816, 248565, 261723, 262297, 262871, 264595, 265169, 265743, 267467, 268041, 269765, 276664, 277238, 277812, 279536, 280110, 281834, 288158, 288732, 290456, 296205, 308815, 309389, 309963, 311687, 312261, 313985, 320309, 320883, 322607, 328356, 340412, 340986, 342710, 348459, 359952]; M(ci) = c(31); ci = [5678, 6252, 6826, 9125, 9699, 10273, 11997, 12571, 13145, 14869, 15443, 17167, 24641, 25215, 25789, 28088, 28662, 29236, 30960, 31534, 32108, 33832, 34406, 36130, 43604, 44178, 44752, 47051, 47625, 48199, 49923, 50497, 51071, 52795, 53369, 55093, 62567, 63141, 63715, 65439, 66013, 66587, 68311, 68885, 70609, 77508, 78082, 78656, 80380, 80954, 82678, 89002, 89576, 91300, 97049, 110156, 110730, 111304, 113603, 114177, 114751, 116475, 117049, 117623, 119347, 119921, 121645, 129119, 129693, 130267, 132566, 133140, 133714, 135438, 136012, 136586, 138310, 138884, 140608, 148082, 148656, 149230, 150954, 151528, 152102, 153826, 154400, 156124, 163023, 163597, 164171, 165895, 166469, 168193, 174517, 175091, 176815, 182564, 195695, 196269, 196843, 199142, 199716, 200290, 202014, 202588, 203162, 204886, 205460, 207184, 214658, 215232, 215806, 217530, 218104, 218678, 220402, 220976, 222700, 229599, 230173, 230747, 232471, 233045, 234769, 241093, 241667, 243391, 249140, 262298, 262872, 263446, 265170, 265744, 266318, 268042, 268616, 270340, 277239, 277813, 278387, 280111, 280685, 282409, 288733, 289307, 291031, 296780, 309390, 309964, 310538, 312262, 312836, 314560, 320884, 321458, 323182, 328931, 340987, 341561, 343285, 349034, 360527]; M(ci) = c(32); ci = [8553, 9127, 9701, 11425, 11999, 12573, 13722, 14296, 14870, 16019, 16593, 17742, 27516, 28090, 28664, 30388, 30962, 31536, 32685, 33259, 33833, 34982, 35556, 36705, 46479, 47053, 47627, 49351, 49925, 50499, 51648, 52222, 52796, 53945, 54519, 55668, 64867, 65441, 66015, 67164, 67738, 68312, 69461, 70035, 71184, 79233, 79807, 80381, 81530, 82104, 83253, 90152, 90726, 91875, 97624, 113031, 113605, 114179, 115903, 116477, 117051, 118200, 118774, 119348, 120497, 121071, 122220, 131994, 132568, 133142, 134866, 135440, 136014, 137163, 137737, 138311, 139460, 140034, 141183, 150382, 150956, 151530, 152679, 153253, 153827, 154976, 155550, 156699, 164748, 165322, 165896, 167045, 167619, 168768, 175667, 176241, 177390, 183139, 198570, 199144, 199718, 201442, 202016, 202590, 203739, 204313, 204887, 206036, 206610, 207759, 216958, 217532, 218106, 219255, 219829, 220403, 221552, 222126, 223275, 231324, 231898, 232472, 233621, 234195, 235344, 242243, 242817, 243966, 249715, 264598, 265172, 265746, 266895, 267469, 268043, 269192, 269766, 270915, 278964, 279538, 280112, 281261, 281835, 282984, 289883, 290457, 291606, 297355, 311115, 311689, 312263, 313412, 313986, 315135, 322034, 322608, 323757, 329506, 342137, 342711, 343860, 349609, 361102]; M(ci) = c(33); ci = [9128, 9702, 10276, 12000, 12574, 13148, 14297, 14871, 15445, 16594, 17168, 18317, 28091, 28665, 29239, 30963, 31537, 32111, 33260, 33834, 34408, 35557, 36131, 37280, 47054, 47628, 48202, 49926, 50500, 51074, 52223, 52797, 53371, 54520, 55094, 56243, 65442, 66016, 66590, 67739, 68313, 68887, 70036, 70610, 71759, 79808, 80382, 80956, 82105, 82679, 83828, 90727, 91301, 92450, 98199, 113606, 114180, 114754, 116478, 117052, 117626, 118775, 119349, 119923, 121072, 121646, 122795, 132569, 133143, 133717, 135441, 136015, 136589, 137738, 138312, 138886, 140035, 140609, 141758, 150957, 151531, 152105, 153254, 153828, 154402, 155551, 156125, 157274, 165323, 165897, 166471, 167620, 168194, 169343, 176242, 176816, 177965, 183714, 199145, 199719, 200293, 202017, 202591, 203165, 204314, 204888, 205462, 206611, 207185, 208334, 217533, 218107, 218681, 219830, 220404, 220978, 222127, 222701, 223850, 231899, 232473, 233047, 234196, 234770, 235919, 242818, 243392, 244541, 250290, 265173, 265747, 266321, 267470, 268044, 268618, 269767, 270341, 271490, 279539, 280113, 280687, 281836, 282410, 283559, 290458, 291032, 292181, 297930, 311690, 312264, 312838, 313987, 314561, 315710, 322609, 323183, 324332, 330081, 342712, 343286, 344435, 350184, 361677]; M(ci) = c(34); ci = [12003, 12577, 13151, 14300, 14874, 15448, 16022, 16596, 17170, 17744, 18318, 18892, 30966, 31540, 32114, 33263, 33837, 34411, 34985, 35559, 36133, 36707, 37281, 37855, 49929, 50503, 51077, 52226, 52800, 53374, 53948, 54522, 55096, 55670, 56244, 56818, 67742, 68316, 68890, 69464, 70038, 70612, 71186, 71760, 72334, 81533, 82107, 82681, 83255, 83829, 84403, 91877, 92451, 93025, 98774, 116481, 117055, 117629, 118778, 119352, 119926, 120500, 121074, 121648, 122222, 122796, 123370, 135444, 136018, 136592, 137741, 138315, 138889, 139463, 140037, 140611, 141185, 141759, 142333, 153257, 153831, 154405, 154979, 155553, 156127, 156701, 157275, 157849, 167048, 167622, 168196, 168770, 169344, 169918, 177392, 177966, 178540, 184289, 202020, 202594, 203168, 204317, 204891, 205465, 206039, 206613, 207187, 207761, 208335, 208909, 219833, 220407, 220981, 221555, 222129, 222703, 223277, 223851, 224425, 233624, 234198, 234772, 235346, 235920, 236494, 243968, 244542, 245116, 250865, 267473, 268047, 268621, 269195, 269769, 270343, 270917, 271491, 272065, 281264, 281838, 282412, 282986, 283560, 284134, 291608, 292182, 292756, 298505, 313415, 313989, 314563, 315137, 315711, 316285, 323759, 324333, 324907, 330656, 343862, 344436, 345010, 350759, 362252]; M(ci) = c(35); ci = [23503, 24077, 24651, 26950, 27524, 28098, 29822, 30396, 30970, 32694, 33268, 34992, 42466, 43040, 43614, 45913, 46487, 47061, 48785, 49359, 49933, 51657, 52231, 53955, 57979, 58553, 59127, 61426, 62000, 62574, 64298, 64872, 65446, 67170, 67744, 69468, 73492, 74066, 74640, 76364, 76938, 77512, 79236, 79810, 81534, 84983, 85557, 86131, 87855, 88429, 90153, 93602, 94176, 95900, 99349, 127981, 128555, 129129, 131428, 132002, 132576, 134300, 134874, 135448, 137172, 137746, 139470, 143494, 144068, 144642, 146941, 147515, 148089, 149813, 150387, 150961, 152685, 153259, 154983, 159007, 159581, 160155, 161879, 162453, 163027, 164751, 165325, 167049, 170498, 171072, 171646, 173370, 173944, 175668, 179117, 179691, 181415, 184864, 210070, 210644, 211218, 213517, 214091, 214665, 216389, 216963, 217537, 219261, 219835, 221559, 225583, 226157, 226731, 228455, 229029, 229603, 231327, 231901, 233625, 237074, 237648, 238222, 239946, 240520, 242244, 245693, 246267, 247991, 251440, 273223, 273797, 274371, 276095, 276669, 277243, 278967, 279541, 281265, 284714, 285288, 285862, 287586, 288160, 289884, 293333, 293907, 295631, 299080, 316865, 317439, 318013, 319737, 320311, 322035, 325484, 326058, 327782, 331231, 345587, 346161, 347885, 351334, 362827]; M(ci) = c(36); ci = [24078, 24652, 25226, 27525, 28099, 28673, 30397, 30971, 31545, 33269, 33843, 35567, 43041, 43615, 44189, 46488, 47062, 47636, 49360, 49934, 50508, 52232, 52806, 54530, 58554, 59128, 59702, 62001, 62575, 63149, 64873, 65447, 66021, 67745, 68319, 70043, 74067, 74641, 75215, 76939, 77513, 78087, 79811, 80385, 82109, 85558, 86132, 86706, 88430, 89004, 90728, 94177, 94751, 96475, 99924, 128556, 129130, 129704, 132003, 132577, 133151, 134875, 135449, 136023, 137747, 138321, 140045, 144069, 144643, 145217, 147516, 148090, 148664, 150388, 150962, 151536, 153260, 153834, 155558, 159582, 160156, 160730, 162454, 163028, 163602, 165326, 165900, 167624, 171073, 171647, 172221, 173945, 174519, 176243, 179692, 180266, 181990, 185439, 210645, 211219, 211793, 214092, 214666, 215240, 216964, 217538, 218112, 219836, 220410, 222134, 226158, 226732, 227306, 229030, 229604, 230178, 231902, 232476, 234200, 237649, 238223, 238797, 240521, 241095, 242819, 246268, 246842, 248566, 252015, 273798, 274372, 274946, 276670, 277244, 277818, 279542, 280116, 281840, 285289, 285863, 286437, 288161, 288735, 290459, 293908, 294482, 296206, 299655, 317440, 318014, 318588, 320312, 320886, 322610, 326059, 326633, 328357, 331806, 346162, 346736, 348460, 351909, 363402]; M(ci) = c(37); ci = [24653, 25227, 25801, 28100, 28674, 29248, 30972, 31546, 32120, 33844, 34418, 36142, 43616, 44190, 44764, 47063, 47637, 48211, 49935, 50509, 51083, 52807, 53381, 55105, 59129, 59703, 60277, 62576, 63150, 63724, 65448, 66022, 66596, 68320, 68894, 70618, 74642, 75216, 75790, 77514, 78088, 78662, 80386, 80960, 82684, 86133, 86707, 87281, 89005, 89579, 91303, 94752, 95326, 97050, 100499, 129131, 129705, 130279, 132578, 133152, 133726, 135450, 136024, 136598, 138322, 138896, 140620, 144644, 145218, 145792, 148091, 148665, 149239, 150963, 151537, 152111, 153835, 154409, 156133, 160157, 160731, 161305, 163029, 163603, 164177, 165901, 166475, 168199, 171648, 172222, 172796, 174520, 175094, 176818, 180267, 180841, 182565, 186014, 211220, 211794, 212368, 214667, 215241, 215815, 217539, 218113, 218687, 220411, 220985, 222709, 226733, 227307, 227881, 229605, 230179, 230753, 232477, 233051, 234775, 238224, 238798, 239372, 241096, 241670, 243394, 246843, 247417, 249141, 252590, 274373, 274947, 275521, 277245, 277819, 278393, 280117, 280691, 282415, 285864, 286438, 287012, 288736, 289310, 291034, 294483, 295057, 296781, 300230, 318015, 318589, 319163, 320887, 321461, 323185, 326634, 327208, 328932, 332381, 346737, 347311, 349035, 352484, 363977]; M(ci) = c(38); ci = [27528, 28102, 28676, 30400, 30974, 31548, 32697, 33271, 33845, 34994, 35568, 36717, 46491, 47065, 47639, 49363, 49937, 50511, 51660, 52234, 52808, 53957, 54531, 55680, 62004, 62578, 63152, 64876, 65450, 66024, 67173, 67747, 68321, 69470, 70044, 71193, 76942, 77516, 78090, 79239, 79813, 80387, 81536, 82110, 83259, 87858, 88432, 89006, 90155, 90729, 91878, 95902, 96476, 97625, 101074, 132006, 132580, 133154, 134878, 135452, 136026, 137175, 137749, 138323, 139472, 140046, 141195, 147519, 148093, 148667, 150391, 150965, 151539, 152688, 153262, 153836, 154985, 155559, 156708, 162457, 163031, 163605, 164754, 165328, 165902, 167051, 167625, 168774, 173373, 173947, 174521, 175670, 176244, 177393, 181417, 181991, 183140, 186589, 214095, 214669, 215243, 216967, 217541, 218115, 219264, 219838, 220412, 221561, 222135, 223284, 229033, 229607, 230181, 231330, 231904, 232478, 233627, 234201, 235350, 239949, 240523, 241097, 242246, 242820, 243969, 247993, 248567, 249716, 253165, 276673, 277247, 277821, 278970, 279544, 280118, 281267, 281841, 282990, 287589, 288163, 288737, 289886, 290460, 291609, 295633, 296207, 297356, 300805, 319740, 320314, 320888, 322037, 322611, 323760, 327784, 328358, 329507, 332956, 347887, 348461, 349610, 353059, 364552]; M(ci) = c(39); ci = [28103, 28677, 29251, 30975, 31549, 32123, 33272, 33846, 34420, 35569, 36143, 37292, 47066, 47640, 48214, 49938, 50512, 51086, 52235, 52809, 53383, 54532, 55106, 56255, 62579, 63153, 63727, 65451, 66025, 66599, 67748, 68322, 68896, 70045, 70619, 71768, 77517, 78091, 78665, 79814, 80388, 80962, 82111, 82685, 83834, 88433, 89007, 89581, 90730, 91304, 92453, 96477, 97051, 98200, 101649, 132581, 133155, 133729, 135453, 136027, 136601, 137750, 138324, 138898, 140047, 140621, 141770, 148094, 148668, 149242, 150966, 151540, 152114, 153263, 153837, 154411, 155560, 156134, 157283, 163032, 163606, 164180, 165329, 165903, 166477, 167626, 168200, 169349, 173948, 174522, 175096, 176245, 176819, 177968, 181992, 182566, 183715, 187164, 214670, 215244, 215818, 217542, 218116, 218690, 219839, 220413, 220987, 222136, 222710, 223859, 229608, 230182, 230756, 231905, 232479, 233053, 234202, 234776, 235925, 240524, 241098, 241672, 242821, 243395, 244544, 248568, 249142, 250291, 253740, 277248, 277822, 278396, 279545, 280119, 280693, 281842, 282416, 283565, 288164, 288738, 289312, 290461, 291035, 292184, 296208, 296782, 297931, 301380, 320315, 320889, 321463, 322612, 323186, 324335, 328359, 328933, 330082, 333531, 348462, 349036, 350185, 353634, 365127]; M(ci) = c(40); ci = [30978, 31552, 32126, 33275, 33849, 34423, 34997, 35571, 36145, 36719, 37293, 37867, 49941, 50515, 51089, 52238, 52812, 53386, 53960, 54534, 55108, 55682, 56256, 56830, 65454, 66028, 66602, 67751, 68325, 68899, 69473, 70047, 70621, 71195, 71769, 72343, 79817, 80391, 80965, 81539, 82113, 82687, 83261, 83835, 84409, 90158, 90732, 91306, 91880, 92454, 93028, 97627, 98201, 98775, 102224, 135456, 136030, 136604, 137753, 138327, 138901, 139475, 140049, 140623, 141197, 141771, 142345, 150969, 151543, 152117, 153266, 153840, 154414, 154988, 155562, 156136, 156710, 157284, 157858, 165332, 165906, 166480, 167054, 167628, 168202, 168776, 169350, 169924, 175673, 176247, 176821, 177395, 177969, 178543, 183142, 183716, 184290, 187739, 217545, 218119, 218693, 219842, 220416, 220990, 221564, 222138, 222712, 223286, 223860, 224434, 231908, 232482, 233056, 233630, 234204, 234778, 235352, 235926, 236500, 242249, 242823, 243397, 243971, 244545, 245119, 249718, 250292, 250866, 254315, 279548, 280122, 280696, 281270, 281844, 282418, 282992, 283566, 284140, 289889, 290463, 291037, 291611, 292185, 292759, 297358, 297932, 298506, 301955, 322040, 322614, 323188, 323762, 324336, 324910, 329509, 330083, 330657, 334106, 349612, 350186, 350760, 354209, 365702]; M(ci) = c(41); ci = [46503, 47077, 47651, 49375, 49949, 50523, 51672, 52246, 52820, 53969, 54543, 55692, 62016, 62590, 63164, 64888, 65462, 66036, 67185, 67759, 68333, 69482, 70056, 71205, 74079, 74653, 75227, 76951, 77525, 78099, 79248, 79822, 80396, 81545, 82119, 83268, 85567, 86141, 86715, 87864, 88438, 89012, 90161, 90735, 91884, 93608, 94182, 94756, 95905, 96479, 97628, 99352, 99926, 101075, 102799, 147531, 148105, 148679, 150403, 150977, 151551, 152700, 153274, 153848, 154997, 155571, 156720, 159594, 160168, 160742, 162466, 163040, 163614, 164763, 165337, 165911, 167060, 167634, 168783, 171082, 171656, 172230, 173379, 173953, 174527, 175676, 176250, 177399, 179123, 179697, 180271, 181420, 181994, 183143, 184867, 185441, 186590, 188314, 226170, 226744, 227318, 229042, 229616, 230190, 231339, 231913, 232487, 233636, 234210, 235359, 237658, 238232, 238806, 239955, 240529, 241103, 242252, 242826, 243975, 245699, 246273, 246847, 247996, 248570, 249719, 251443, 252017, 253166, 254890, 285298, 285872, 286446, 287595, 288169, 288743, 289892, 290466, 291615, 293339, 293913, 294487, 295636, 296210, 297359, 299083, 299657, 300806, 302530, 325490, 326064, 326638, 327787, 328361, 329510, 331234, 331808, 332957, 334681, 351337, 351911, 353060, 354784, 366277]; M(ci) = c(42); ci = [47078, 47652, 48226, 49950, 50524, 51098, 52247, 52821, 53395, 54544, 55118, 56267, 62591, 63165, 63739, 65463, 66037, 66611, 67760, 68334, 68908, 70057, 70631, 71780, 74654, 75228, 75802, 77526, 78100, 78674, 79823, 80397, 80971, 82120, 82694, 83843, 86142, 86716, 87290, 88439, 89013, 89587, 90736, 91310, 92459, 94183, 94757, 95331, 96480, 97054, 98203, 99927, 100501, 101650, 103374, 148106, 148680, 149254, 150978, 151552, 152126, 153275, 153849, 154423, 155572, 156146, 157295, 160169, 160743, 161317, 163041, 163615, 164189, 165338, 165912, 166486, 167635, 168209, 169358, 171657, 172231, 172805, 173954, 174528, 175102, 176251, 176825, 177974, 179698, 180272, 180846, 181995, 182569, 183718, 185442, 186016, 187165, 188889, 226745, 227319, 227893, 229617, 230191, 230765, 231914, 232488, 233062, 234211, 234785, 235934, 238233, 238807, 239381, 240530, 241104, 241678, 242827, 243401, 244550, 246274, 246848, 247422, 248571, 249145, 250294, 252018, 252592, 253741, 255465, 285873, 286447, 287021, 288170, 288744, 289318, 290467, 291041, 292190, 293914, 294488, 295062, 296211, 296785, 297934, 299658, 300232, 301381, 303105, 326065, 326639, 327213, 328362, 328936, 330085, 331809, 332383, 333532, 335256, 351912, 352486, 353635, 355359, 366852]; M(ci) = c(43); ci = [49953, 50527, 51101, 52250, 52824, 53398, 53972, 54546, 55120, 55694, 56268, 56842, 65466, 66040, 66614, 67763, 68337, 68911, 69485, 70059, 70633, 71207, 71781, 72355, 77529, 78103, 78677, 79826, 80400, 80974, 81548, 82122, 82696, 83270, 83844, 84418, 88442, 89016, 89590, 90164, 90738, 91312, 91886, 92460, 93034, 95908, 96482, 97056, 97630, 98204, 98778, 101077, 101651, 102225, 103949, 150981, 151555, 152129, 153278, 153852, 154426, 155000, 155574, 156148, 156722, 157296, 157870, 163044, 163618, 164192, 165341, 165915, 166489, 167063, 167637, 168211, 168785, 169359, 169933, 173957, 174531, 175105, 175679, 176253, 176827, 177401, 177975, 178549, 181423, 181997, 182571, 183145, 183719, 184293, 186592, 187166, 187740, 189464, 229620, 230194, 230768, 231917, 232491, 233065, 233639, 234213, 234787, 235361, 235935, 236509, 240533, 241107, 241681, 242255, 242829, 243403, 243977, 244551, 245125, 247999, 248573, 249147, 249721, 250295, 250869, 253168, 253742, 254316, 256040, 288173, 288747, 289321, 289895, 290469, 291043, 291617, 292191, 292765, 295639, 296213, 296787, 297361, 297935, 298509, 300808, 301382, 301956, 303680, 327790, 328364, 328938, 329512, 330086, 330660, 332959, 333533, 334107, 335831, 353062, 353636, 354210, 355934, 367427]; M(ci) = c(44); ci = [65478, 66052, 66626, 67775, 68349, 68923, 69497, 70071, 70645, 71219, 71793, 72367, 77541, 78115, 78689, 79838, 80412, 80986, 81560, 82134, 82708, 83282, 83856, 84430, 86154, 86728, 87302, 88451, 89025, 89599, 90173, 90747, 91321, 91895, 92469, 93043, 94192, 94766, 95340, 95914, 96488, 97062, 97636, 98210, 98784, 99358, 99932, 100506, 101080, 101654, 102228, 102802, 103376, 103950, 104524, 163056, 163630, 164204, 165353, 165927, 166501, 167075, 167649, 168223, 168797, 169371, 169945, 171669, 172243, 172817, 173966, 174540, 175114, 175688, 176262, 176836, 177410, 177984, 178558, 179707, 180281, 180855, 181429, 182003, 182577, 183151, 183725, 184299, 184873, 185447, 186021, 186595, 187169, 187743, 188317, 188891, 189465, 190039, 238245, 238819, 239393, 240542, 241116, 241690, 242264, 242838, 243412, 243986, 244560, 245134, 246283, 246857, 247431, 248005, 248579, 249153, 249727, 250301, 250875, 251449, 252023, 252597, 253171, 253745, 254319, 254893, 255467, 256041, 256615, 293923, 294497, 295071, 295645, 296219, 296793, 297367, 297941, 298515, 299089, 299663, 300237, 300811, 301385, 301959, 302533, 303107, 303681, 304255, 331240, 331814, 332388, 332962, 333536, 334110, 334684, 335258, 335832, 336406, 354787, 355361, 355935, 356509, 368002]; M(ci) = c(45); ci = [198878, 199452, 200026, 201750, 202324, 202898, 204047, 204621, 205195, 206344, 206918, 208067, 214391, 214965, 215539, 217263, 217837, 218411, 219560, 220134, 220708, 221857, 222431, 223580, 226454, 227028, 227602, 229326, 229900, 230474, 231623, 232197, 232771, 233920, 234494, 235643, 237942, 238516, 239090, 240239, 240813, 241387, 242536, 243110, 244259, 245983, 246557, 247131, 248280, 248854, 250003, 251727, 252301, 253450, 255174, 261956, 262530, 263104, 264828, 265402, 265976, 267125, 267699, 268273, 269422, 269996, 271145, 274019, 274593, 275167, 276891, 277465, 278039, 279188, 279762, 280336, 281485, 282059, 283208, 285507, 286081, 286655, 287804, 288378, 288952, 290101, 290675, 291824, 293548, 294122, 294696, 295845, 296419, 297568, 299292, 299866, 301015, 302739, 306095, 306669, 307243, 308967, 309541, 310115, 311264, 311838, 312412, 313561, 314135, 315284, 317583, 318157, 318731, 319880, 320454, 321028, 322177, 322751, 323900, 325624, 326198, 326772, 327921, 328495, 329644, 331368, 331942, 333091, 334815, 337623, 338197, 338771, 339920, 340494, 341068, 342217, 342791, 343940, 345664, 346238, 346812, 347961, 348535, 349684, 351408, 351982, 353131, 354855, 357115, 357689, 358263, 359412, 359986, 361135, 362859, 363433, 364582, 366306, 368587, 369161, 370310, 372034, 374327]; M(ci) = c(46); ci = [199453, 200027, 200601, 202325, 202899, 203473, 204622, 205196, 205770, 206919, 207493, 208642, 214966, 215540, 216114, 217838, 218412, 218986, 220135, 220709, 221283, 222432, 223006, 224155, 227029, 227603, 228177, 229901, 230475, 231049, 232198, 232772, 233346, 234495, 235069, 236218, 238517, 239091, 239665, 240814, 241388, 241962, 243111, 243685, 244834, 246558, 247132, 247706, 248855, 249429, 250578, 252302, 252876, 254025, 255749, 262531, 263105, 263679, 265403, 265977, 266551, 267700, 268274, 268848, 269997, 270571, 271720, 274594, 275168, 275742, 277466, 278040, 278614, 279763, 280337, 280911, 282060, 282634, 283783, 286082, 286656, 287230, 288379, 288953, 289527, 290676, 291250, 292399, 294123, 294697, 295271, 296420, 296994, 298143, 299867, 300441, 301590, 303314, 306670, 307244, 307818, 309542, 310116, 310690, 311839, 312413, 312987, 314136, 314710, 315859, 318158, 318732, 319306, 320455, 321029, 321603, 322752, 323326, 324475, 326199, 326773, 327347, 328496, 329070, 330219, 331943, 332517, 333666, 335390, 338198, 338772, 339346, 340495, 341069, 341643, 342792, 343366, 344515, 346239, 346813, 347387, 348536, 349110, 350259, 351983, 352557, 353706, 355430, 357690, 358264, 358838, 359987, 360561, 361710, 363434, 364008, 365157, 366881, 369162, 369736, 370885, 372609, 374902]; M(ci) = c(47); ci = [202328, 202902, 203476, 204625, 205199, 205773, 206347, 206921, 207495, 208069, 208643, 209217, 217841, 218415, 218989, 220138, 220712, 221286, 221860, 222434, 223008, 223582, 224156, 224730, 229904, 230478, 231052, 232201, 232775, 233349, 233923, 234497, 235071, 235645, 236219, 236793, 240817, 241391, 241965, 242539, 243113, 243687, 244261, 244835, 245409, 248283, 248857, 249431, 250005, 250579, 251153, 253452, 254026, 254600, 256324, 265406, 265980, 266554, 267703, 268277, 268851, 269425, 269999, 270573, 271147, 271721, 272295, 277469, 278043, 278617, 279766, 280340, 280914, 281488, 282062, 282636, 283210, 283784, 284358, 288382, 288956, 289530, 290104, 290678, 291252, 291826, 292400, 292974, 295848, 296422, 296996, 297570, 298144, 298718, 301017, 301591, 302165, 303889, 309545, 310119, 310693, 311842, 312416, 312990, 313564, 314138, 314712, 315286, 315860, 316434, 320458, 321032, 321606, 322180, 322754, 323328, 323902, 324476, 325050, 327924, 328498, 329072, 329646, 330220, 330794, 333093, 333667, 334241, 335965, 340498, 341072, 341646, 342220, 342794, 343368, 343942, 344516, 345090, 347964, 348538, 349112, 349686, 350260, 350834, 353133, 353707, 354281, 356005, 359415, 359989, 360563, 361137, 361711, 362285, 364584, 365158, 365732, 367456, 370312, 370886, 371460, 373184, 375477]; M(ci) = c(48); ci = [217853, 218427, 219001, 220150, 220724, 221298, 221872, 222446, 223020, 223594, 224168, 224742, 229916, 230490, 231064, 232213, 232787, 233361, 233935, 234509, 235083, 235657, 236231, 236805, 238529, 239103, 239677, 240826, 241400, 241974, 242548, 243122, 243696, 244270, 244844, 245418, 246567, 247141, 247715, 248289, 248863, 249437, 250011, 250585, 251159, 251733, 252307, 252881, 253455, 254029, 254603, 255177, 255751, 256325, 256899, 277481, 278055, 278629, 279778, 280352, 280926, 281500, 282074, 282648, 283222, 283796, 284370, 286094, 286668, 287242, 288391, 288965, 289539, 290113, 290687, 291261, 291835, 292409, 292983, 294132, 294706, 295280, 295854, 296428, 297002, 297576, 298150, 298724, 299298, 299872, 300446, 301020, 301594, 302168, 302742, 303316, 303890, 304464, 318170, 318744, 319318, 320467, 321041, 321615, 322189, 322763, 323337, 323911, 324485, 325059, 326208, 326782, 327356, 327930, 328504, 329078, 329652, 330226, 330800, 331374, 331948, 332522, 333096, 333670, 334244, 334818, 335392, 335966, 336540, 346248, 346822, 347396, 347970, 348544, 349118, 349692, 350266, 350840, 351414, 351988, 352562, 353136, 353710, 354284, 354858, 355432, 356006, 356580, 362865, 363439, 364013, 364587, 365161, 365735, 366309, 366883, 367457, 368031, 372037, 372611, 373185, 373759, 376052]; M(ci) = c(49); ci = [265578, 266152, 266726, 267875, 268449, 269023, 269597, 270171, 270745, 271319, 271893, 272467, 277641, 278215, 278789, 279938, 280512, 281086, 281660, 282234, 282808, 283382, 283956, 284530, 286254, 286828, 287402, 288551, 289125, 289699, 290273, 290847, 291421, 291995, 292569, 293143, 294292, 294866, 295440, 296014, 296588, 297162, 297736, 298310, 298884, 299458, 300032, 300606, 301180, 301754, 302328, 302902, 303476, 304050, 304624, 309681, 310255, 310829, 311978, 312552, 313126, 313700, 314274, 314848, 315422, 315996, 316570, 318294, 318868, 319442, 320591, 321165, 321739, 322313, 322887, 323461, 324035, 324609, 325183, 326332, 326906, 327480, 328054, 328628, 329202, 329776, 330350, 330924, 331498, 332072, 332646, 333220, 333794, 334368, 334942, 335516, 336090, 336664, 338295, 338869, 339443, 340592, 341166, 341740, 342314, 342888, 343462, 344036, 344610, 345184, 346333, 346907, 347481, 348055, 348629, 349203, 349777, 350351, 350925, 351499, 352073, 352647, 353221, 353795, 354369, 354943, 355517, 356091, 356665, 357748, 358322, 358896, 359470, 360044, 360618, 361192, 361766, 362340, 362914, 363488, 364062, 364636, 365210, 365784, 366358, 366932, 367506, 368080, 368615, 369189, 369763, 370337, 370911, 371485, 372059, 372633, 373207, 373781, 374337, 374911, 375485, 376059, 376627]; M(ci) = c(50); ci = [1698, 4572, 5146, 7445, 8019, 8593, 10892, 11466, 13765, 20664, 23538, 24112, 26411, 26985, 27559, 29858, 30432, 32731, 39630, 42504, 43078, 45377, 45951, 46525, 48824, 49398, 51697, 58021, 58595, 60894, 61468, 62042, 64341, 64915, 67214, 72963, 73537, 74111, 76410, 76984, 79283, 85032, 85606, 87905, 93654, 106167, 109041, 109615, 111914, 112488, 113062, 115361, 115935, 118234, 125133, 128007, 128581, 130880, 131454, 132028, 134327, 134901, 137200, 143524, 144098, 146397, 146971, 147545, 149844, 150418, 152717, 158466, 159040, 159614, 161913, 162487, 164786, 170535, 171109, 173408, 179157, 191697, 194571, 195145, 197444, 198018, 198592, 200891, 201465, 203764, 210088, 210662, 212961, 213535, 214109, 216408, 216982, 219281, 225030, 225604, 226178, 228477, 229051, 231350, 237099, 237673, 239972, 245721, 257716, 258290, 260589, 261163, 261737, 264036, 264610, 266909, 272658, 273232, 273806, 276105, 276679, 278978, 284727, 285301, 287600, 293349, 304800, 305374, 305948, 308247, 308821, 311120, 316869, 317443, 319742, 325491, 336966, 337540, 339839, 345588, 357078]; M(ci) = c(51); ci = [2273, 5147, 5721, 8020, 8594, 9168, 11467, 12041, 14340, 21239, 24113, 24687, 26986, 27560, 28134, 30433, 31007, 33306, 40205, 43079, 43653, 45952, 46526, 47100, 49399, 49973, 52272, 58596, 59170, 61469, 62043, 62617, 64916, 65490, 67789, 73538, 74112, 74686, 76985, 77559, 79858, 85607, 86181, 88480, 94229, 106742, 109616, 110190, 112489, 113063, 113637, 115936, 116510, 118809, 125708, 128582, 129156, 131455, 132029, 132603, 134902, 135476, 137775, 144099, 144673, 146972, 147546, 148120, 150419, 150993, 153292, 159041, 159615, 160189, 162488, 163062, 165361, 171110, 171684, 173983, 179732, 192272, 195146, 195720, 198019, 198593, 199167, 201466, 202040, 204339, 210663, 211237, 213536, 214110, 214684, 216983, 217557, 219856, 225605, 226179, 226753, 229052, 229626, 231925, 237674, 238248, 240547, 246296, 258291, 258865, 261164, 261738, 262312, 264611, 265185, 267484, 273233, 273807, 274381, 276680, 277254, 279553, 285302, 285876, 288175, 293924, 305375, 305949, 306523, 308822, 309396, 311695, 317444, 318018, 320317, 326066, 337541, 338115, 340414, 346163, 357653]; M(ci) = c(52); ci = [2848, 5722, 6296, 8595, 9169, 9743, 12042, 12616, 14915, 21814, 24688, 25262, 27561, 28135, 28709, 31008, 31582, 33881, 40780, 43654, 44228, 46527, 47101, 47675, 49974, 50548, 52847, 59171, 59745, 62044, 62618, 63192, 65491, 66065, 68364, 74113, 74687, 75261, 77560, 78134, 80433, 86182, 86756, 89055, 94804, 107317, 110191, 110765, 113064, 113638, 114212, 116511, 117085, 119384, 126283, 129157, 129731, 132030, 132604, 133178, 135477, 136051, 138350, 144674, 145248, 147547, 148121, 148695, 150994, 151568, 153867, 159616, 160190, 160764, 163063, 163637, 165936, 171685, 172259, 174558, 180307, 192847, 195721, 196295, 198594, 199168, 199742, 202041, 202615, 204914, 211238, 211812, 214111, 214685, 215259, 217558, 218132, 220431, 226180, 226754, 227328, 229627, 230201, 232500, 238249, 238823, 241122, 246871, 258866, 259440, 261739, 262313, 262887, 265186, 265760, 268059, 273808, 274382, 274956, 277255, 277829, 280128, 285877, 286451, 288750, 294499, 305950, 306524, 307098, 309397, 309971, 312270, 318019, 318593, 320892, 326641, 338116, 338690, 340989, 346738, 358228]; M(ci) = c(53); ci = [3423, 6297, 6871, 9170, 9744, 10318, 12617, 13191, 15490, 22389, 25263, 25837, 28136, 28710, 29284, 31583, 32157, 34456, 41355, 44229, 44803, 47102, 47676, 48250, 50549, 51123, 53422, 59746, 60320, 62619, 63193, 63767, 66066, 66640, 68939, 74688, 75262, 75836, 78135, 78709, 81008, 86757, 87331, 89630, 95379, 107892, 110766, 111340, 113639, 114213, 114787, 117086, 117660, 119959, 126858, 129732, 130306, 132605, 133179, 133753, 136052, 136626, 138925, 145249, 145823, 148122, 148696, 149270, 151569, 152143, 154442, 160191, 160765, 161339, 163638, 164212, 166511, 172260, 172834, 175133, 180882, 193422, 196296, 196870, 199169, 199743, 200317, 202616, 203190, 205489, 211813, 212387, 214686, 215260, 215834, 218133, 218707, 221006, 226755, 227329, 227903, 230202, 230776, 233075, 238824, 239398, 241697, 247446, 259441, 260015, 262314, 262888, 263462, 265761, 266335, 268634, 274383, 274957, 275531, 277830, 278404, 280703, 286452, 287026, 289325, 295074, 306525, 307099, 307673, 309972, 310546, 312845, 318594, 319168, 321467, 327216, 338691, 339265, 341564, 347313, 358803]; M(ci) = c(54); ci = [5723, 8597, 9171, 10895, 11469, 12043, 13767, 14341, 16065, 24689, 27563, 28137, 29861, 30435, 31009, 32733, 33307, 35031, 43655, 46529, 47103, 48827, 49401, 49975, 51699, 52273, 53997, 62046, 62620, 64344, 64918, 65492, 67216, 67790, 69514, 76413, 76987, 77561, 79285, 79859, 81583, 87907, 88481, 90205, 95954, 110192, 113066, 113640, 115364, 115938, 116512, 118236, 118810, 120534, 129158, 132032, 132606, 134330, 134904, 135478, 137202, 137776, 139500, 147549, 148123, 149847, 150421, 150995, 152719, 153293, 155017, 161916, 162490, 163064, 164788, 165362, 167086, 173410, 173984, 175708, 181457, 195722, 198596, 199170, 200894, 201468, 202042, 203766, 204340, 206064, 214113, 214687, 216411, 216985, 217559, 219283, 219857, 221581, 228480, 229054, 229628, 231352, 231926, 233650, 239974, 240548, 242272, 248021, 261741, 262315, 264039, 264613, 265187, 266911, 267485, 269209, 276108, 276682, 277256, 278980, 279554, 281278, 287602, 288176, 289900, 295649, 308250, 308824, 309398, 311122, 311696, 313420, 319744, 320318, 322042, 327791, 339841, 340415, 342139, 347888, 359378]; M(ci) = c(55); ci = [6298, 9172, 9746, 11470, 12044, 12618, 14342, 14916, 16640, 25264, 28138, 28712, 30436, 31010, 31584, 33308, 33882, 35606, 44230, 47104, 47678, 49402, 49976, 50550, 52274, 52848, 54572, 62621, 63195, 64919, 65493, 66067, 67791, 68365, 70089, 76988, 77562, 78136, 79860, 80434, 82158, 88482, 89056, 90780, 96529, 110767, 113641, 114215, 115939, 116513, 117087, 118811, 119385, 121109, 129733, 132607, 133181, 134905, 135479, 136053, 137777, 138351, 140075, 148124, 148698, 150422, 150996, 151570, 153294, 153868, 155592, 162491, 163065, 163639, 165363, 165937, 167661, 173985, 174559, 176283, 182032, 196297, 199171, 199745, 201469, 202043, 202617, 204341, 204915, 206639, 214688, 215262, 216986, 217560, 218134, 219858, 220432, 222156, 229055, 229629, 230203, 231927, 232501, 234225, 240549, 241123, 242847, 248596, 262316, 262890, 264614, 265188, 265762, 267486, 268060, 269784, 276683, 277257, 277831, 279555, 280129, 281853, 288177, 288751, 290475, 296224, 308825, 309399, 309973, 311697, 312271, 313995, 320319, 320893, 322617, 328366, 340416, 340990, 342714, 348463, 359953]; M(ci) = c(56); ci = [6873, 9747, 10321, 12045, 12619, 13193, 14917, 15491, 17215, 25839, 28713, 29287, 31011, 31585, 32159, 33883, 34457, 36181, 44805, 47679, 48253, 49977, 50551, 51125, 52849, 53423, 55147, 63196, 63770, 65494, 66068, 66642, 68366, 68940, 70664, 77563, 78137, 78711, 80435, 81009, 82733, 89057, 89631, 91355, 97104, 111342, 114216, 114790, 116514, 117088, 117662, 119386, 119960, 121684, 130308, 133182, 133756, 135480, 136054, 136628, 138352, 138926, 140650, 148699, 149273, 150997, 151571, 152145, 153869, 154443, 156167, 163066, 163640, 164214, 165938, 166512, 168236, 174560, 175134, 176858, 182607, 196872, 199746, 200320, 202044, 202618, 203192, 204916, 205490, 207214, 215263, 215837, 217561, 218135, 218709, 220433, 221007, 222731, 229630, 230204, 230778, 232502, 233076, 234800, 241124, 241698, 243422, 249171, 262891, 263465, 265189, 265763, 266337, 268061, 268635, 270359, 277258, 277832, 278406, 280130, 280704, 282428, 288752, 289326, 291050, 296799, 309400, 309974, 310548, 312272, 312846, 314570, 320894, 321468, 323192, 328941, 340991, 341565, 343289, 349038, 360528]; M(ci) = c(57); ci = [9748, 12047, 12621, 13770, 14344, 14918, 16067, 16641, 17790, 28714, 31013, 31587, 32736, 33310, 33884, 35033, 35607, 36756, 47680, 49979, 50553, 51702, 52276, 52850, 53999, 54573, 55722, 65496, 66070, 67219, 67793, 68367, 69516, 70090, 71239, 79288, 79862, 80436, 81585, 82159, 83308, 90207, 90781, 91930, 97679, 114217, 116516, 117090, 118239, 118813, 119387, 120536, 121110, 122259, 133183, 135482, 136056, 137205, 137779, 138353, 139502, 140076, 141225, 150999, 151573, 152722, 153296, 153870, 155019, 155593, 156742, 164791, 165365, 165939, 167088, 167662, 168811, 175710, 176284, 177433, 183182, 199747, 202046, 202620, 203769, 204343, 204917, 206066, 206640, 207789, 217563, 218137, 219286, 219860, 220434, 221583, 222157, 223306, 231355, 231929, 232503, 233652, 234226, 235375, 242274, 242848, 243997, 249746, 265191, 265765, 266914, 267488, 268062, 269211, 269785, 270934, 278983, 279557, 280131, 281280, 281854, 283003, 289902, 290476, 291625, 297374, 311125, 311699, 312273, 313422, 313996, 315145, 322044, 322618, 323767, 329516, 342141, 342715, 343864, 349613, 361103]; M(ci) = c(58); ci = [10323, 12622, 13196, 14345, 14919, 15493, 16642, 17216, 18365, 29289, 31588, 32162, 33311, 33885, 34459, 35608, 36182, 37331, 48255, 50554, 51128, 52277, 52851, 53425, 54574, 55148, 56297, 66071, 66645, 67794, 68368, 68942, 70091, 70665, 71814, 79863, 80437, 81011, 82160, 82734, 83883, 90782, 91356, 92505, 98254, 114792, 117091, 117665, 118814, 119388, 119962, 121111, 121685, 122834, 133758, 136057, 136631, 137780, 138354, 138928, 140077, 140651, 141800, 151574, 152148, 153297, 153871, 154445, 155594, 156168, 157317, 165366, 165940, 166514, 167663, 168237, 169386, 176285, 176859, 178008, 183757, 200322, 202621, 203195, 204344, 204918, 205492, 206641, 207215, 208364, 218138, 218712, 219861, 220435, 221009, 222158, 222732, 223881, 231930, 232504, 233078, 234227, 234801, 235950, 242849, 243423, 244572, 250321, 265766, 266340, 267489, 268063, 268637, 269786, 270360, 271509, 279558, 280132, 280706, 281855, 282429, 283578, 290477, 291051, 292200, 297949, 311700, 312274, 312848, 313997, 314571, 315720, 322619, 323193, 324342, 330091, 342716, 343290, 344439, 350188, 361678]; M(ci) = c(59); ci = [13198, 14922, 15496, 16070, 16644, 17218, 17792, 18366, 18940, 32164, 33888, 34462, 35036, 35610, 36184, 36758, 37332, 37906, 51130, 52854, 53428, 54002, 54576, 55150, 55724, 56298, 56872, 68371, 68945, 69519, 70093, 70667, 71241, 71815, 72389, 81588, 82162, 82736, 83310, 83884, 84458, 91932, 92506, 93080, 98829, 117667, 119391, 119965, 120539, 121113, 121687, 122261, 122835, 123409, 136633, 138357, 138931, 139505, 140079, 140653, 141227, 141801, 142375, 153874, 154448, 155022, 155596, 156170, 156744, 157318, 157892, 167091, 167665, 168239, 168813, 169387, 169961, 177435, 178009, 178583, 184332, 203197, 204921, 205495, 206069, 206643, 207217, 207791, 208365, 208939, 220438, 221012, 221586, 222160, 222734, 223308, 223882, 224456, 233655, 234229, 234803, 235377, 235951, 236525, 243999, 244573, 245147, 250896, 268066, 268640, 269214, 269788, 270362, 270936, 271510, 272084, 281283, 281857, 282431, 283005, 283579, 284153, 291627, 292201, 292775, 298524, 313425, 313999, 314573, 315147, 315721, 316295, 323769, 324343, 324917, 330666, 343866, 344440, 345014, 350763, 362253]; M(ci) = c(60); ci = [24698, 27572, 28146, 29870, 30444, 31018, 32742, 33316, 35040, 43664, 46538, 47112, 48836, 49410, 49984, 51708, 52282, 54006, 59180, 62054, 62628, 64352, 64926, 65500, 67224, 67798, 69522, 74121, 74695, 76419, 76993, 77567, 79291, 79865, 81589, 85038, 85612, 86186, 87910, 88484, 90208, 93657, 94231, 95955, 99404, 129167, 132041, 132615, 134339, 134913, 135487, 137211, 137785, 139509, 144683, 147557, 148131, 149855, 150429, 151003, 152727, 153301, 155025, 159624, 160198, 161922, 162496, 163070, 164794, 165368, 167092, 170541, 171115, 171689, 173413, 173987, 175711, 179160, 179734, 181458, 184907, 211247, 214121, 214695, 216419, 216993, 217567, 219291, 219865, 221589, 226188, 226762, 228486, 229060, 229634, 231358, 231932, 233656, 237105, 237679, 238253, 239977, 240551, 242275, 245724, 246298, 248022, 251471, 273816, 274390, 276114, 276688, 277262, 278986, 279560, 281284, 284733, 285307, 285881, 287605, 288179, 289903, 293352, 293926, 295650, 299099, 316875, 317449, 318023, 319747, 320321, 322045, 325494, 326068, 327792, 331241, 345591, 346165, 347889, 351338, 362828]; M(ci) = c(61); ci = [25273, 28147, 28721, 30445, 31019, 31593, 33317, 33891, 35615, 44239, 47113, 47687, 49411, 49985, 50559, 52283, 52857, 54581, 59755, 62629, 63203, 64927, 65501, 66075, 67799, 68373, 70097, 74696, 75270, 76994, 77568, 78142, 79866, 80440, 82164, 85613, 86187, 86761, 88485, 89059, 90783, 94232, 94806, 96530, 99979, 129742, 132616, 133190, 134914, 135488, 136062, 137786, 138360, 140084, 145258, 148132, 148706, 150430, 151004, 151578, 153302, 153876, 155600, 160199, 160773, 162497, 163071, 163645, 165369, 165943, 167667, 171116, 171690, 172264, 173988, 174562, 176286, 179735, 180309, 182033, 185482, 211822, 214696, 215270, 216994, 217568, 218142, 219866, 220440, 222164, 226763, 227337, 229061, 229635, 230209, 231933, 232507, 234231, 237680, 238254, 238828, 240552, 241126, 242850, 246299, 246873, 248597, 252046, 274391, 274965, 276689, 277263, 277837, 279561, 280135, 281859, 285308, 285882, 286456, 288180, 288754, 290478, 293927, 294501, 296225, 299674, 317450, 318024, 318598, 320322, 320896, 322620, 326069, 326643, 328367, 331816, 346166, 346740, 348464, 351913, 363403]; M(ci) = c(62); ci = [25848, 28722, 29296, 31020, 31594, 32168, 33892, 34466, 36190, 44814, 47688, 48262, 49986, 50560, 51134, 52858, 53432, 55156, 60330, 63204, 63778, 65502, 66076, 66650, 68374, 68948, 70672, 75271, 75845, 77569, 78143, 78717, 80441, 81015, 82739, 86188, 86762, 87336, 89060, 89634, 91358, 94807, 95381, 97105, 100554, 130317, 133191, 133765, 135489, 136063, 136637, 138361, 138935, 140659, 145833, 148707, 149281, 151005, 151579, 152153, 153877, 154451, 156175, 160774, 161348, 163072, 163646, 164220, 165944, 166518, 168242, 171691, 172265, 172839, 174563, 175137, 176861, 180310, 180884, 182608, 186057, 212397, 215271, 215845, 217569, 218143, 218717, 220441, 221015, 222739, 227338, 227912, 229636, 230210, 230784, 232508, 233082, 234806, 238255, 238829, 239403, 241127, 241701, 243425, 246874, 247448, 249172, 252621, 274966, 275540, 277264, 277838, 278412, 280136, 280710, 282434, 285883, 286457, 287031, 288755, 289329, 291053, 294502, 295076, 296800, 300249, 318025, 318599, 319173, 320897, 321471, 323195, 326644, 327218, 328942, 332391, 346741, 347315, 349039, 352488, 363978]; M(ci) = c(63); ci = [28723, 31022, 31596, 32745, 33319, 33893, 35042, 35616, 36765, 47689, 49988, 50562, 51711, 52285, 52859, 54008, 54582, 55731, 63205, 65504, 66078, 67227, 67801, 68375, 69524, 70098, 71247, 77571, 78145, 79294, 79868, 80442, 81591, 82165, 83314, 87913, 88487, 89061, 90210, 90784, 91933, 95957, 96531, 97680, 101129, 133192, 135491, 136065, 137214, 137788, 138362, 139511, 140085, 141234, 148708, 151007, 151581, 152730, 153304, 153878, 155027, 155601, 156750, 163074, 163648, 164797, 165371, 165945, 167094, 167668, 168817, 173416, 173990, 174564, 175713, 176287, 177436, 181460, 182034, 183183, 186632, 215272, 217571, 218145, 219294, 219868, 220442, 221591, 222165, 223314, 229638, 230212, 231361, 231935, 232509, 233658, 234232, 235381, 239980, 240554, 241128, 242277, 242851, 244000, 248024, 248598, 249747, 253196, 277266, 277840, 278989, 279563, 280137, 281286, 281860, 283009, 287608, 288182, 288756, 289905, 290479, 291628, 295652, 296226, 297375, 300824, 319750, 320324, 320898, 322047, 322621, 323770, 327794, 328368, 329517, 332966, 347891, 348465, 349614, 353063, 364553]; M(ci) = c(64); ci = [29298, 31597, 32171, 33320, 33894, 34468, 35617, 36191, 37340, 48264, 50563, 51137, 52286, 52860, 53434, 54583, 55157, 56306, 63780, 66079, 66653, 67802, 68376, 68950, 70099, 70673, 71822, 78146, 78720, 79869, 80443, 81017, 82166, 82740, 83889, 88488, 89062, 89636, 90785, 91359, 92508, 96532, 97106, 98255, 101704, 133767, 136066, 136640, 137789, 138363, 138937, 140086, 140660, 141809, 149283, 151582, 152156, 153305, 153879, 154453, 155602, 156176, 157325, 163649, 164223, 165372, 165946, 166520, 167669, 168243, 169392, 173991, 174565, 175139, 176288, 176862, 178011, 182035, 182609, 183758, 187207, 215847, 218146, 218720, 219869, 220443, 221017, 222166, 222740, 223889, 230213, 230787, 231936, 232510, 233084, 234233, 234807, 235956, 240555, 241129, 241703, 242852, 243426, 244575, 248599, 249173, 250322, 253771, 277841, 278415, 279564, 280138, 280712, 281861, 282435, 283584, 288183, 288757, 289331, 290480, 291054, 292203, 296227, 296801, 297950, 301399, 320325, 320899, 321473, 322622, 323196, 324345, 328369, 328943, 330092, 333541, 348466, 349040, 350189, 353638, 365128]; M(ci) = c(65); ci = [32173, 33897, 34471, 35045, 35619, 36193, 36767, 37341, 37915, 51139, 52863, 53437, 54011, 54585, 55159, 55733, 56307, 56881, 66655, 68379, 68953, 69527, 70101, 70675, 71249, 71823, 72397, 80446, 81020, 81594, 82168, 82742, 83316, 83890, 84464, 90213, 90787, 91361, 91935, 92509, 93083, 97682, 98256, 98830, 102279, 136642, 138366, 138940, 139514, 140088, 140662, 141236, 141810, 142384, 152158, 153882, 154456, 155030, 155604, 156178, 156752, 157326, 157900, 165949, 166523, 167097, 167671, 168245, 168819, 169393, 169967, 175716, 176290, 176864, 177438, 178012, 178586, 183185, 183759, 184333, 187782, 218722, 220446, 221020, 221594, 222168, 222742, 223316, 223890, 224464, 232513, 233087, 233661, 234235, 234809, 235383, 235957, 236531, 242280, 242854, 243428, 244002, 244576, 245150, 249749, 250323, 250897, 254346, 280141, 280715, 281289, 281863, 282437, 283011, 283585, 284159, 289908, 290482, 291056, 291630, 292204, 292778, 297377, 297951, 298525, 301974, 322050, 322624, 323198, 323772, 324346, 324920, 329519, 330093, 330667, 334116, 349616, 350190, 350764, 354213, 365703]; M(ci) = c(66); ci = [47698, 49997, 50571, 51720, 52294, 52868, 54017, 54591, 55740, 63214, 65513, 66087, 67236, 67810, 68384, 69533, 70107, 71256, 75280, 77579, 78153, 79302, 79876, 80450, 81599, 82173, 83322, 86196, 86770, 87919, 88493, 89067, 90216, 90790, 91939, 93663, 94237, 94811, 95960, 96534, 97683, 99407, 99981, 101130, 102854, 148717, 151016, 151590, 152739, 153313, 153887, 155036, 155610, 156759, 160783, 163082, 163656, 164805, 165379, 165953, 167102, 167676, 168825, 171699, 172273, 173422, 173996, 174570, 175719, 176293, 177442, 179166, 179740, 180314, 181463, 182037, 183186, 184910, 185484, 186633, 188357, 227347, 229646, 230220, 231369, 231943, 232517, 233666, 234240, 235389, 238263, 238837, 239986, 240560, 241134, 242283, 242857, 244006, 245730, 246304, 246878, 248027, 248601, 249750, 251474, 252048, 253197, 254921, 285891, 286465, 287614, 288188, 288762, 289911, 290485, 291634, 293358, 293932, 294506, 295655, 296229, 297378, 299102, 299676, 300825, 302549, 325500, 326074, 326648, 327797, 328371, 329520, 331244, 331818, 332967, 334691, 351341, 351915, 353064, 354788, 366278]; M(ci) = c(67); ci = [48273, 50572, 51146, 52295, 52869, 53443, 54592, 55166, 56315, 63789, 66088, 66662, 67811, 68385, 68959, 70108, 70682, 71831, 75855, 78154, 78728, 79877, 80451, 81025, 82174, 82748, 83897, 86771, 87345, 88494, 89068, 89642, 90791, 91365, 92514, 94238, 94812, 95386, 96535, 97109, 98258, 99982, 100556, 101705, 103429, 149292, 151591, 152165, 153314, 153888, 154462, 155611, 156185, 157334, 161358, 163657, 164231, 165380, 165954, 166528, 167677, 168251, 169400, 172274, 172848, 173997, 174571, 175145, 176294, 176868, 178017, 179741, 180315, 180889, 182038, 182612, 183761, 185485, 186059, 187208, 188932, 227922, 230221, 230795, 231944, 232518, 233092, 234241, 234815, 235964, 238838, 239412, 240561, 241135, 241709, 242858, 243432, 244581, 246305, 246879, 247453, 248602, 249176, 250325, 252049, 252623, 253772, 255496, 286466, 287040, 288189, 288763, 289337, 290486, 291060, 292209, 293933, 294507, 295081, 296230, 296804, 297953, 299677, 300251, 301400, 303124, 326075, 326649, 327223, 328372, 328946, 330095, 331819, 332393, 333542, 335266, 351916, 352490, 353639, 355363, 366853]; M(ci) = c(68); ci = [51148, 52872, 53446, 54020, 54594, 55168, 55742, 56316, 56890, 66664, 68388, 68962, 69536, 70110, 70684, 71258, 71832, 72406, 78730, 80454, 81028, 81602, 82176, 82750, 83324, 83898, 84472, 89071, 89645, 90219, 90793, 91367, 91941, 92515, 93089, 95963, 96537, 97111, 97685, 98259, 98833, 101132, 101706, 102280, 104004, 152167, 153891, 154465, 155039, 155613, 156187, 156761, 157335, 157909, 164233, 165957, 166531, 167105, 167679, 168253, 168827, 169401, 169975, 174574, 175148, 175722, 176296, 176870, 177444, 178018, 178592, 181466, 182040, 182614, 183188, 183762, 184336, 186635, 187209, 187783, 189507, 230797, 232521, 233095, 233669, 234243, 234817, 235391, 235965, 236539, 241138, 241712, 242286, 242860, 243434, 244008, 244582, 245156, 248030, 248604, 249178, 249752, 250326, 250900, 253199, 253773, 254347, 256071, 288766, 289340, 289914, 290488, 291062, 291636, 292210, 292784, 295658, 296232, 296806, 297380, 297954, 298528, 300827, 301401, 301975, 303699, 327800, 328374, 328948, 329522, 330096, 330670, 332969, 333543, 334117, 335841, 353066, 353640, 354214, 355938, 367428]; M(ci) = c(69); ci = [66673, 68397, 68971, 69545, 70119, 70693, 71267, 71841, 72415, 78739, 80463, 81037, 81611, 82185, 82759, 83333, 83907, 84481, 87355, 89079, 89653, 90227, 90801, 91375, 91949, 92523, 93097, 94821, 95395, 95969, 96543, 97117, 97691, 98265, 98839, 99413, 99987, 100561, 101135, 101709, 102283, 102857, 103431, 104005, 104579, 164242, 165966, 166540, 167114, 167688, 168262, 168836, 169410, 169984, 172858, 174582, 175156, 175730, 176304, 176878, 177452, 178026, 178600, 180324, 180898, 181472, 182046, 182620, 183194, 183768, 184342, 184916, 185490, 186064, 186638, 187212, 187786, 188360, 188934, 189508, 190082, 239422, 241146, 241720, 242294, 242868, 243442, 244016, 244590, 245164, 246888, 247462, 248036, 248610, 249184, 249758, 250332, 250906, 251480, 252054, 252628, 253202, 253776, 254350, 254924, 255498, 256072, 256646, 294516, 295090, 295664, 296238, 296812, 297386, 297960, 298534, 299108, 299682, 300256, 300830, 301404, 301978, 302552, 303126, 303700, 304274, 331250, 331824, 332398, 332972, 333546, 334120, 334694, 335268, 335842, 336416, 354791, 355365, 355939, 356513, 368003]; M(ci) = c(70); ci = [200073, 202372, 202946, 204095, 204669, 205243, 206392, 206966, 208115, 215589, 217888, 218462, 219611, 220185, 220759, 221908, 222482, 223631, 227655, 229954, 230528, 231677, 232251, 232825, 233974, 234548, 235697, 238571, 239145, 240294, 240868, 241442, 242591, 243165, 244314, 246038, 246612, 247186, 248335, 248909, 250058, 251782, 252356, 253505, 255229, 263142, 265441, 266015, 267164, 267738, 268312, 269461, 270035, 271184, 275208, 277507, 278081, 279230, 279804, 280378, 281527, 282101, 283250, 286124, 286698, 287847, 288421, 288995, 290144, 290718, 291867, 293591, 294165, 294739, 295888, 296462, 297611, 299335, 299909, 301058, 302782, 307272, 309571, 310145, 311294, 311868, 312442, 313591, 314165, 315314, 318188, 318762, 319911, 320485, 321059, 322208, 322782, 323931, 325655, 326229, 326803, 327952, 328526, 329675, 331399, 331973, 333122, 334846, 338216, 338790, 339939, 340513, 341087, 342236, 342810, 343959, 345683, 346257, 346831, 347980, 348554, 349703, 351427, 352001, 353150, 354874, 357125, 357699, 358273, 359422, 359996, 361145, 362869, 363443, 364592, 366316, 368591, 369165, 370314, 372038, 374328]; M(ci) = c(71); ci = [200648, 202947, 203521, 204670, 205244, 205818, 206967, 207541, 208690, 216164, 218463, 219037, 220186, 220760, 221334, 222483, 223057, 224206, 228230, 230529, 231103, 232252, 232826, 233400, 234549, 235123, 236272, 239146, 239720, 240869, 241443, 242017, 243166, 243740, 244889, 246613, 247187, 247761, 248910, 249484, 250633, 252357, 252931, 254080, 255804, 263717, 266016, 266590, 267739, 268313, 268887, 270036, 270610, 271759, 275783, 278082, 278656, 279805, 280379, 280953, 282102, 282676, 283825, 286699, 287273, 288422, 288996, 289570, 290719, 291293, 292442, 294166, 294740, 295314, 296463, 297037, 298186, 299910, 300484, 301633, 303357, 307847, 310146, 310720, 311869, 312443, 313017, 314166, 314740, 315889, 318763, 319337, 320486, 321060, 321634, 322783, 323357, 324506, 326230, 326804, 327378, 328527, 329101, 330250, 331974, 332548, 333697, 335421, 338791, 339365, 340514, 341088, 341662, 342811, 343385, 344534, 346258, 346832, 347406, 348555, 349129, 350278, 352002, 352576, 353725, 355449, 357700, 358274, 358848, 359997, 360571, 361720, 363444, 364018, 365167, 366891, 369166, 369740, 370889, 372613, 374903]; M(ci) = c(72); ci = [203523, 205247, 205821, 206395, 206969, 207543, 208117, 208691, 209265, 219039, 220763, 221337, 221911, 222485, 223059, 223633, 224207, 224781, 231105, 232829, 233403, 233977, 234551, 235125, 235699, 236273, 236847, 241446, 242020, 242594, 243168, 243742, 244316, 244890, 245464, 248338, 248912, 249486, 250060, 250634, 251208, 253507, 254081, 254655, 256379, 266592, 268316, 268890, 269464, 270038, 270612, 271186, 271760, 272334, 278658, 280382, 280956, 281530, 282104, 282678, 283252, 283826, 284400, 288999, 289573, 290147, 290721, 291295, 291869, 292443, 293017, 295891, 296465, 297039, 297613, 298187, 298761, 301060, 301634, 302208, 303932, 310722, 312446, 313020, 313594, 314168, 314742, 315316, 315890, 316464, 321063, 321637, 322211, 322785, 323359, 323933, 324507, 325081, 327955, 328529, 329103, 329677, 330251, 330825, 333124, 333698, 334272, 335996, 341091, 341665, 342239, 342813, 343387, 343961, 344535, 345109, 347983, 348557, 349131, 349705, 350279, 350853, 353152, 353726, 354300, 356024, 359425, 359999, 360573, 361147, 361721, 362295, 364594, 365168, 365742, 367466, 370316, 370890, 371464, 373188, 375478]; M(ci) = c(73); ci = [219048, 220772, 221346, 221920, 222494, 223068, 223642, 224216, 224790, 231114, 232838, 233412, 233986, 234560, 235134, 235708, 236282, 236856, 239730, 241454, 242028, 242602, 243176, 243750, 244324, 244898, 245472, 247196, 247770, 248344, 248918, 249492, 250066, 250640, 251214, 251788, 252362, 252936, 253510, 254084, 254658, 255232, 255806, 256380, 256954, 278667, 280391, 280965, 281539, 282113, 282687, 283261, 283835, 284409, 287283, 289007, 289581, 290155, 290729, 291303, 291877, 292451, 293025, 294749, 295323, 295897, 296471, 297045, 297619, 298193, 298767, 299341, 299915, 300489, 301063, 301637, 302211, 302785, 303359, 303933, 304507, 319347, 321071, 321645, 322219, 322793, 323367, 323941, 324515, 325089, 326813, 327387, 327961, 328535, 329109, 329683, 330257, 330831, 331405, 331979, 332553, 333127, 333701, 334275, 334849, 335423, 335997, 336571, 346841, 347415, 347989, 348563, 349137, 349711, 350285, 350859, 351433, 352007, 352581, 353155, 353729, 354303, 354877, 355451, 356025, 356599, 362875, 363449, 364023, 364597, 365171, 365745, 366319, 366893, 367467, 368041, 372041, 372615, 373189, 373763, 376053]; M(ci) = c(74); ci = [266773, 268497, 269071, 269645, 270219, 270793, 271367, 271941, 272515, 278839, 280563, 281137, 281711, 282285, 282859, 283433, 284007, 284581, 287455, 289179, 289753, 290327, 290901, 291475, 292049, 292623, 293197, 294921, 295495, 296069, 296643, 297217, 297791, 298365, 298939, 299513, 300087, 300661, 301235, 301809, 302383, 302957, 303531, 304105, 304679, 310867, 312591, 313165, 313739, 314313, 314887, 315461, 316035, 316609, 319483, 321207, 321781, 322355, 322929, 323503, 324077, 324651, 325225, 326949, 327523, 328097, 328671, 329245, 329819, 330393, 330967, 331541, 332115, 332689, 333263, 333837, 334411, 334985, 335559, 336133, 336707, 339472, 341196, 341770, 342344, 342918, 343492, 344066, 344640, 345214, 346938, 347512, 348086, 348660, 349234, 349808, 350382, 350956, 351530, 352104, 352678, 353252, 353826, 354400, 354974, 355548, 356122, 356696, 358341, 358915, 359489, 360063, 360637, 361211, 361785, 362359, 362933, 363507, 364081, 364655, 365229, 365803, 366377, 366951, 367525, 368099, 368625, 369199, 369773, 370347, 370921, 371495, 372069, 372643, 373217, 373791, 374341, 374915, 375489, 376063, 376628]; M(ci) = c(75); ci = [13800, 29899, 30473, 32772, 45421, 45995, 46569, 48868, 49442, 51741, 58640, 60939, 61513, 62087, 64386, 64960, 67259, 73008, 73582, 74156, 76455, 77029, 79328, 85077, 85651, 87950, 93699, 115393, 115967, 118266, 130915, 131489, 132063, 134362, 134936, 137235, 144134, 146433, 147007, 147581, 149880, 150454, 152753, 158502, 159076, 159650, 161949, 162523, 164822, 170571, 171145, 173444, 179193, 197470, 198044, 198618, 200917, 201491, 203790, 210689, 212988, 213562, 214136, 216435, 217009, 219308, 225057, 225631, 226205, 228504, 229078, 231377, 237126, 237700, 239999, 245748, 258308, 260607, 261181, 261755, 264054, 264628, 266927, 272676, 273250, 273824, 276123, 276697, 278996, 284745, 285319, 287618, 293367, 304810, 305384, 305958, 308257, 308831, 311130, 316879, 317453, 319752, 325501, 336970, 337544, 339843, 345592, 357079]; M(ci) = c(76); ci = [14375, 30474, 31048, 33347, 45996, 46570, 47144, 49443, 50017, 52316, 59215, 61514, 62088, 62662, 64961, 65535, 67834, 73583, 74157, 74731, 77030, 77604, 79903, 85652, 86226, 88525, 94274, 115968, 116542, 118841, 131490, 132064, 132638, 134937, 135511, 137810, 144709, 147008, 147582, 148156, 150455, 151029, 153328, 159077, 159651, 160225, 162524, 163098, 165397, 171146, 171720, 174019, 179768, 198045, 198619, 199193, 201492, 202066, 204365, 211264, 213563, 214137, 214711, 217010, 217584, 219883, 225632, 226206, 226780, 229079, 229653, 231952, 237701, 238275, 240574, 246323, 258883, 261182, 261756, 262330, 264629, 265203, 267502, 273251, 273825, 274399, 276698, 277272, 279571, 285320, 285894, 288193, 293942, 305385, 305959, 306533, 308832, 309406, 311705, 317454, 318028, 320327, 326076, 337545, 338119, 340418, 346167, 357654]; M(ci) = c(77); ci = [14950, 31049, 31623, 33922, 46571, 47145, 47719, 50018, 50592, 52891, 59790, 62089, 62663, 63237, 65536, 66110, 68409, 74158, 74732, 75306, 77605, 78179, 80478, 86227, 86801, 89100, 94849, 116543, 117117, 119416, 132065, 132639, 133213, 135512, 136086, 138385, 145284, 147583, 148157, 148731, 151030, 151604, 153903, 159652, 160226, 160800, 163099, 163673, 165972, 171721, 172295, 174594, 180343, 198620, 199194, 199768, 202067, 202641, 204940, 211839, 214138, 214712, 215286, 217585, 218159, 220458, 226207, 226781, 227355, 229654, 230228, 232527, 238276, 238850, 241149, 246898, 259458, 261757, 262331, 262905, 265204, 265778, 268077, 273826, 274400, 274974, 277273, 277847, 280146, 285895, 286469, 288768, 294517, 305960, 306534, 307108, 309407, 309981, 312280, 318029, 318603, 320902, 326651, 338120, 338694, 340993, 346742, 358229]; M(ci) = c(78); ci = [15525, 31624, 32198, 34497, 47146, 47720, 48294, 50593, 51167, 53466, 60365, 62664, 63238, 63812, 66111, 66685, 68984, 74733, 75307, 75881, 78180, 78754, 81053, 86802, 87376, 89675, 95424, 117118, 117692, 119991, 132640, 133214, 133788, 136087, 136661, 138960, 145859, 148158, 148732, 149306, 151605, 152179, 154478, 160227, 160801, 161375, 163674, 164248, 166547, 172296, 172870, 175169, 180918, 199195, 199769, 200343, 202642, 203216, 205515, 212414, 214713, 215287, 215861, 218160, 218734, 221033, 226782, 227356, 227930, 230229, 230803, 233102, 238851, 239425, 241724, 247473, 260033, 262332, 262906, 263480, 265779, 266353, 268652, 274401, 274975, 275549, 277848, 278422, 280721, 286470, 287044, 289343, 295092, 306535, 307109, 307683, 309982, 310556, 312855, 318604, 319178, 321477, 327226, 338695, 339269, 341568, 347317, 358804]; M(ci) = c(79); ci = [16100, 32774, 33348, 35072, 48871, 49445, 50019, 51743, 52317, 54041, 62665, 64389, 64963, 65537, 67261, 67835, 69559, 76458, 77032, 77606, 79330, 79904, 81628, 87952, 88526, 90250, 95999, 118268, 118842, 120566, 134365, 134939, 135513, 137237, 137811, 139535, 148159, 149883, 150457, 151031, 152755, 153329, 155053, 161952, 162526, 163100, 164824, 165398, 167122, 173446, 174020, 175744, 181493, 200920, 201494, 202068, 203792, 204366, 206090, 214714, 216438, 217012, 217586, 219310, 219884, 221608, 228507, 229081, 229655, 231379, 231953, 233677, 240001, 240575, 242299, 248048, 262333, 264057, 264631, 265205, 266929, 267503, 269227, 276126, 276700, 277274, 278998, 279572, 281296, 287620, 288194, 289918, 295667, 308260, 308834, 309408, 311132, 311706, 313430, 319754, 320328, 322052, 327801, 339845, 340419, 342143, 347892, 359379]; M(ci) = c(80); ci = [16675, 33349, 33923, 35647, 49446, 50020, 50594, 52318, 52892, 54616, 63240, 64964, 65538, 66112, 67836, 68410, 70134, 77033, 77607, 78181, 79905, 80479, 82203, 88527, 89101, 90825, 96574, 118843, 119417, 121141, 134940, 135514, 136088, 137812, 138386, 140110, 148734, 150458, 151032, 151606, 153330, 153904, 155628, 162527, 163101, 163675, 165399, 165973, 167697, 174021, 174595, 176319, 182068, 201495, 202069, 202643, 204367, 204941, 206665, 215289, 217013, 217587, 218161, 219885, 220459, 222183, 229082, 229656, 230230, 231954, 232528, 234252, 240576, 241150, 242874, 248623, 262908, 264632, 265206, 265780, 267504, 268078, 269802, 276701, 277275, 277849, 279573, 280147, 281871, 288195, 288769, 290493, 296242, 308835, 309409, 309983, 311707, 312281, 314005, 320329, 320903, 322627, 328376, 340420, 340994, 342718, 348467, 359954]; M(ci) = c(81); ci = [17250, 33924, 34498, 36222, 50021, 50595, 51169, 52893, 53467, 55191, 63815, 65539, 66113, 66687, 68411, 68985, 70709, 77608, 78182, 78756, 80480, 81054, 82778, 89102, 89676, 91400, 97149, 119418, 119992, 121716, 135515, 136089, 136663, 138387, 138961, 140685, 149309, 151033, 151607, 152181, 153905, 154479, 156203, 163102, 163676, 164250, 165974, 166548, 168272, 174596, 175170, 176894, 182643, 202070, 202644, 203218, 204942, 205516, 207240, 215864, 217588, 218162, 218736, 220460, 221034, 222758, 229657, 230231, 230805, 232529, 233103, 234827, 241151, 241725, 243449, 249198, 263483, 265207, 265781, 266355, 268079, 268653, 270377, 277276, 277850, 278424, 280148, 280722, 282446, 288770, 289344, 291068, 296817, 309410, 309984, 310558, 312282, 312856, 314580, 320904, 321478, 323202, 328951, 340995, 341569, 343293, 349042, 360529]; M(ci) = c(82); ci = [17825, 35074, 35648, 36797, 51746, 52320, 52894, 54043, 54617, 55766, 66115, 67264, 67838, 68412, 69561, 70135, 71284, 79333, 79907, 80481, 81630, 82204, 83353, 90252, 90826, 91975, 97724, 120568, 121142, 122291, 137240, 137814, 138388, 139537, 140111, 141260, 151609, 152758, 153332, 153906, 155055, 155629, 156778, 164827, 165401, 165975, 167124, 167698, 168847, 175746, 176320, 177469, 183218, 203795, 204369, 204943, 206092, 206666, 207815, 218164, 219313, 219887, 220461, 221610, 222184, 223333, 231382, 231956, 232530, 233679, 234253, 235402, 242301, 242875, 244024, 249773, 265783, 266932, 267506, 268080, 269229, 269803, 270952, 279001, 279575, 280149, 281298, 281872, 283021, 289920, 290494, 291643, 297392, 311135, 311709, 312283, 313432, 314006, 315155, 322054, 322628, 323777, 329526, 342145, 342719, 343868, 349617, 361104]; M(ci) = c(83); ci = [18400, 35649, 36223, 37372, 52321, 52895, 53469, 54618, 55192, 56341, 66690, 67839, 68413, 68987, 70136, 70710, 71859, 79908, 80482, 81056, 82205, 82779, 83928, 90827, 91401, 92550, 98299, 121143, 121717, 122866, 137815, 138389, 138963, 140112, 140686, 141835, 152184, 153333, 153907, 154481, 155630, 156204, 157353, 165402, 165976, 166550, 167699, 168273, 169422, 176321, 176895, 178044, 183793, 204370, 204944, 205518, 206667, 207241, 208390, 218739, 219888, 220462, 221036, 222185, 222759, 223908, 231957, 232531, 233105, 234254, 234828, 235977, 242876, 243450, 244599, 250348, 266358, 267507, 268081, 268655, 269804, 270378, 271527, 279576, 280150, 280724, 281873, 282447, 283596, 290495, 291069, 292218, 297967, 311710, 312284, 312858, 314007, 314581, 315730, 322629, 323203, 324352, 330101, 342720, 343294, 344443, 350192, 361679]; M(ci) = c(84); ci = [18975, 36799, 37373, 37947, 54046, 54620, 55194, 55768, 56342, 56916, 68990, 69564, 70138, 70712, 71286, 71860, 72434, 81633, 82207, 82781, 83355, 83929, 84503, 91977, 92551, 93125, 98874, 122293, 122867, 123441, 139540, 140114, 140688, 141262, 141836, 142410, 154484, 155058, 155632, 156206, 156780, 157354, 157928, 167127, 167701, 168275, 168849, 169423, 169997, 177471, 178045, 178619, 184368, 206095, 206669, 207243, 207817, 208391, 208965, 221039, 221613, 222187, 222761, 223335, 223909, 224483, 233682, 234256, 234830, 235404, 235978, 236552, 244026, 244600, 245174, 250923, 268658, 269232, 269806, 270380, 270954, 271528, 272102, 281301, 281875, 282449, 283023, 283597, 284171, 291645, 292219, 292793, 298542, 313435, 314009, 314583, 315157, 315731, 316305, 323779, 324353, 324927, 330676, 343870, 344444, 345018, 350767, 362254]; M(ci) = c(85); ci = [35075, 51749, 52323, 54047, 64396, 64970, 65544, 67268, 67842, 69566, 74740, 76464, 77038, 77612, 79336, 79910, 81634, 85083, 85657, 86231, 87955, 88529, 90253, 93702, 94276, 96000, 99449, 137243, 137817, 139541, 149890, 150464, 151038, 152762, 153336, 155060, 160234, 161958, 162532, 163106, 164830, 165404, 167128, 170577, 171151, 171725, 173449, 174023, 175747, 179196, 179770, 181494, 184943, 216445, 217019, 217593, 219317, 219891, 221615, 226789, 228513, 229087, 229661, 231385, 231959, 233683, 237132, 237706, 238280, 240004, 240578, 242302, 245751, 246325, 248049, 251498, 274408, 276132, 276706, 277280, 279004, 279578, 281302, 284751, 285325, 285899, 287623, 288197, 289921, 293370, 293944, 295668, 299117, 316885, 317459, 318033, 319757, 320331, 322055, 325504, 326078, 327802, 331251, 345595, 346169, 347893, 351342, 362829]; M(ci) = c(86); ci = [35650, 52324, 52898, 54622, 64971, 65545, 66119, 67843, 68417, 70141, 75315, 77039, 77613, 78187, 79911, 80485, 82209, 85658, 86232, 86806, 88530, 89104, 90828, 94277, 94851, 96575, 100024, 137818, 138392, 140116, 150465, 151039, 151613, 153337, 153911, 155635, 160809, 162533, 163107, 163681, 165405, 165979, 167703, 171152, 171726, 172300, 174024, 174598, 176322, 179771, 180345, 182069, 185518, 217020, 217594, 218168, 219892, 220466, 222190, 227364, 229088, 229662, 230236, 231960, 232534, 234258, 237707, 238281, 238855, 240579, 241153, 242877, 246326, 246900, 248624, 252073, 274983, 276707, 277281, 277855, 279579, 280153, 281877, 285326, 285900, 286474, 288198, 288772, 290496, 293945, 294519, 296243, 299692, 317460, 318034, 318608, 320332, 320906, 322630, 326079, 326653, 328377, 331826, 346170, 346744, 348468, 351917, 363404]; M(ci) = c(87); ci = [36225, 52899, 53473, 55197, 65546, 66120, 66694, 68418, 68992, 70716, 75890, 77614, 78188, 78762, 80486, 81060, 82784, 86233, 86807, 87381, 89105, 89679, 91403, 94852, 95426, 97150, 100599, 138393, 138967, 140691, 151040, 151614, 152188, 153912, 154486, 156210, 161384, 163108, 163682, 164256, 165980, 166554, 168278, 171727, 172301, 172875, 174599, 175173, 176897, 180346, 180920, 182644, 186093, 217595, 218169, 218743, 220467, 221041, 222765, 227939, 229663, 230237, 230811, 232535, 233109, 234833, 238282, 238856, 239430, 241154, 241728, 243452, 246901, 247475, 249199, 252648, 275558, 277282, 277856, 278430, 280154, 280728, 282452, 285901, 286475, 287049, 288773, 289347, 291071, 294520, 295094, 296818, 300267, 318035, 318609, 319183, 320907, 321481, 323205, 326654, 327228, 328952, 332401, 346745, 347319, 349043, 352492, 363979]; M(ci) = c(88); ci = [36800, 54049, 54623, 55772, 67271, 67845, 68419, 69568, 70142, 71291, 78190, 79339, 79913, 80487, 81636, 82210, 83359, 87958, 88532, 89106, 90255, 90829, 91978, 96002, 96576, 97725, 101174, 139543, 140117, 141266, 152765, 153339, 153913, 155062, 155636, 156785, 163684, 164833, 165407, 165981, 167130, 167704, 168853, 173452, 174026, 174600, 175749, 176323, 177472, 181496, 182070, 183219, 186668, 219320, 219894, 220468, 221617, 222191, 223340, 230239, 231388, 231962, 232536, 233685, 234259, 235408, 240007, 240581, 241155, 242304, 242878, 244027, 248051, 248625, 249774, 253223, 277858, 279007, 279581, 280155, 281304, 281878, 283027, 287626, 288200, 288774, 289923, 290497, 291646, 295670, 296244, 297393, 300842, 319760, 320334, 320908, 322057, 322631, 323780, 327804, 328378, 329527, 332976, 347895, 348469, 349618, 353067, 364554]; M(ci) = c(89); ci = [37375, 54624, 55198, 56347, 67846, 68420, 68994, 70143, 70717, 71866, 78765, 79914, 80488, 81062, 82211, 82785, 83934, 88533, 89107, 89681, 90830, 91404, 92553, 96577, 97151, 98300, 101749, 140118, 140692, 141841, 153340, 153914, 154488, 155637, 156211, 157360, 164259, 165408, 165982, 166556, 167705, 168279, 169428, 174027, 174601, 175175, 176324, 176898, 178047, 182071, 182645, 183794, 187243, 219895, 220469, 221043, 222192, 222766, 223915, 230814, 231963, 232537, 233111, 234260, 234834, 235983, 240582, 241156, 241730, 242879, 243453, 244602, 248626, 249200, 250349, 253798, 278433, 279582, 280156, 280730, 281879, 282453, 283602, 288201, 288775, 289349, 290498, 291072, 292221, 296245, 296819, 297968, 301417, 320335, 320909, 321483, 322632, 323206, 324355, 328379, 328953, 330102, 333551, 348470, 349044, 350193, 353642, 365129]; M(ci) = c(90); ci = [37950, 55774, 56348, 56922, 69571, 70145, 70719, 71293, 71867, 72441, 81065, 81639, 82213, 82787, 83361, 83935, 84509, 90258, 90832, 91406, 91980, 92554, 93128, 97727, 98301, 98875, 102324, 141268, 141842, 142416, 155065, 155639, 156213, 156787, 157361, 157935, 166559, 167133, 167707, 168281, 168855, 169429, 170003, 175752, 176326, 176900, 177474, 178048, 178622, 183221, 183795, 184369, 187818, 221620, 222194, 222768, 223342, 223916, 224490, 233114, 233688, 234262, 234836, 235410, 235984, 236558, 242307, 242881, 243455, 244029, 244603, 245177, 249776, 250350, 250924, 254373, 280733, 281307, 281881, 282455, 283029, 283603, 284177, 289926, 290500, 291074, 291648, 292222, 292796, 297395, 297969, 298543, 301992, 322060, 322634, 323208, 323782, 324356, 324930, 329529, 330103, 330677, 334126, 349620, 350194, 350768, 354217, 365704]; M(ci) = c(91); ci = [55775, 69574, 70148, 71297, 79346, 79920, 80494, 81643, 82217, 83366, 86815, 87964, 88538, 89112, 90261, 90835, 91984, 93708, 94282, 94856, 96005, 96579, 97728, 99452, 100026, 101175, 102899, 155068, 155642, 156791, 164840, 165414, 165988, 167137, 167711, 168860, 172309, 173458, 174032, 174606, 175755, 176329, 177478, 179202, 179776, 180350, 181499, 182073, 183222, 184946, 185520, 186669, 188393, 231395, 231969, 232543, 233692, 234266, 235415, 238864, 240013, 240587, 241161, 242310, 242884, 244033, 245757, 246331, 246905, 248054, 248628, 249777, 251501, 252075, 253224, 254948, 286483, 287632, 288206, 288780, 289929, 290503, 291652, 293376, 293950, 294524, 295673, 296247, 297396, 299120, 299694, 300843, 302567, 325510, 326084, 326658, 327807, 328381, 329530, 331254, 331828, 332977, 334701, 351345, 351919, 353068, 354792, 366279]; M(ci) = c(92); ci = [56350, 70149, 70723, 71872, 79921, 80495, 81069, 82218, 82792, 83941, 87390, 88539, 89113, 89687, 90836, 91410, 92559, 94283, 94857, 95431, 96580, 97154, 98303, 100027, 100601, 101750, 103474, 155643, 156217, 157366, 165415, 165989, 166563, 167712, 168286, 169435, 172884, 174033, 174607, 175181, 176330, 176904, 178053, 179777, 180351, 180925, 182074, 182648, 183797, 185521, 186095, 187244, 188968, 231970, 232544, 233118, 234267, 234841, 235990, 239439, 240588, 241162, 241736, 242885, 243459, 244608, 246332, 246906, 247480, 248629, 249203, 250352, 252076, 252650, 253799, 255523, 287058, 288207, 288781, 289355, 290504, 291078, 292227, 293951, 294525, 295099, 296248, 296822, 297971, 299695, 300269, 301418, 303142, 326085, 326659, 327233, 328382, 328956, 330105, 331829, 332403, 333552, 335276, 351920, 352494, 353643, 355367, 366854]; M(ci) = c(93); ci = [56925, 71299, 71873, 72447, 81646, 82220, 82794, 83368, 83942, 84516, 89690, 90264, 90838, 91412, 91986, 92560, 93134, 96008, 96582, 97156, 97730, 98304, 98878, 101177, 101751, 102325, 104049, 156793, 157367, 157941, 167140, 167714, 168288, 168862, 169436, 170010, 175184, 175758, 176332, 176906, 177480, 178054, 178628, 181502, 182076, 182650, 183224, 183798, 184372, 186671, 187245, 187819, 189543, 233695, 234269, 234843, 235417, 235991, 236565, 241739, 242313, 242887, 243461, 244035, 244609, 245183, 248057, 248631, 249205, 249779, 250353, 250927, 253226, 253800, 254374, 256098, 289358, 289932, 290506, 291080, 291654, 292228, 292802, 295676, 296250, 296824, 297398, 297972, 298546, 300845, 301419, 301993, 303717, 327810, 328384, 328958, 329532, 330106, 330680, 332979, 333553, 334127, 335851, 353070, 353644, 354218, 355942, 367429]; M(ci) = c(94); ci = [72450, 83374, 83948, 84522, 90271, 90845, 91419, 91993, 92567, 93141, 95440, 96014, 96588, 97162, 97736, 98310, 98884, 99458, 100032, 100606, 101180, 101754, 102328, 102902, 103476, 104050, 104624, 168868, 169442, 170016, 175765, 176339, 176913, 177487, 178061, 178635, 180934, 181508, 182082, 182656, 183230, 183804, 184378, 184952, 185526, 186100, 186674, 187248, 187822, 188396, 188970, 189544, 190118, 242320, 242894, 243468, 244042, 244616, 245190, 247489, 248063, 248637, 249211, 249785, 250359, 250933, 251507, 252081, 252655, 253229, 253803, 254377, 254951, 255525, 256099, 256673, 295108, 295682, 296256, 296830, 297404, 297978, 298552, 299126, 299700, 300274, 300848, 301422, 301996, 302570, 303144, 303718, 304292, 331260, 331834, 332408, 332982, 333556, 334130, 334704, 335278, 335852, 336426, 354795, 355369, 355943, 356517, 368004]; M(ci) = c(95); ci = [208150, 221949, 222523, 223672, 231721, 232295, 232869, 234018, 234592, 235741, 239190, 240339, 240913, 241487, 242636, 243210, 244359, 246083, 246657, 247231, 248380, 248954, 250103, 251827, 252401, 253550, 255274, 269493, 270067, 271216, 279265, 279839, 280413, 281562, 282136, 283285, 286734, 287883, 288457, 289031, 290180, 290754, 291903, 293627, 294201, 294775, 295924, 296498, 297647, 299371, 299945, 301094, 302818, 311320, 311894, 312468, 313617, 314191, 315340, 318789, 319938, 320512, 321086, 322235, 322809, 323958, 325682, 326256, 326830, 327979, 328553, 329702, 331426, 332000, 333149, 334873, 338808, 339957, 340531, 341105, 342254, 342828, 343977, 345701, 346275, 346849, 347998, 348572, 349721, 351445, 352019, 353168, 354892, 357135, 357709, 358283, 359432, 360006, 361155, 362879, 363453, 364602, 366326, 368595, 369169, 370318, 372042, 374329]; M(ci) = c(96); ci = [208725, 222524, 223098, 224247, 232296, 232870, 233444, 234593, 235167, 236316, 239765, 240914, 241488, 242062, 243211, 243785, 244934, 246658, 247232, 247806, 248955, 249529, 250678, 252402, 252976, 254125, 255849, 270068, 270642, 271791, 279840, 280414, 280988, 282137, 282711, 283860, 287309, 288458, 289032, 289606, 290755, 291329, 292478, 294202, 294776, 295350, 296499, 297073, 298222, 299946, 300520, 301669, 303393, 311895, 312469, 313043, 314192, 314766, 315915, 319364, 320513, 321087, 321661, 322810, 323384, 324533, 326257, 326831, 327405, 328554, 329128, 330277, 332001, 332575, 333724, 335448, 339383, 340532, 341106, 341680, 342829, 343403, 344552, 346276, 346850, 347424, 348573, 349147, 350296, 352020, 352594, 353743, 355467, 357710, 358284, 358858, 360007, 360581, 361730, 363454, 364028, 365177, 366901, 369170, 369744, 370893, 372617, 374904]; M(ci) = c(97); ci = [209300, 223674, 224248, 224822, 234021, 234595, 235169, 235743, 236317, 236891, 242065, 242639, 243213, 243787, 244361, 244935, 245509, 248383, 248957, 249531, 250105, 250679, 251253, 253552, 254126, 254700, 256424, 271218, 271792, 272366, 281565, 282139, 282713, 283287, 283861, 284435, 289609, 290183, 290757, 291331, 291905, 292479, 293053, 295927, 296501, 297075, 297649, 298223, 298797, 301096, 301670, 302244, 303968, 313620, 314194, 314768, 315342, 315916, 316490, 321664, 322238, 322812, 323386, 323960, 324534, 325108, 327982, 328556, 329130, 329704, 330278, 330852, 333151, 333725, 334299, 336023, 341683, 342257, 342831, 343405, 343979, 344553, 345127, 348001, 348575, 349149, 349723, 350297, 350871, 353170, 353744, 354318, 356042, 359435, 360009, 360583, 361157, 361731, 362305, 364604, 365178, 365752, 367476, 370320, 370894, 371468, 373192, 375479]; M(ci) = c(98); ci = [224825, 235749, 236323, 236897, 242646, 243220, 243794, 244368, 244942, 245516, 247815, 248389, 248963, 249537, 250111, 250685, 251259, 251833, 252407, 252981, 253555, 254129, 254703, 255277, 255851, 256425, 256999, 283293, 283867, 284441, 290190, 290764, 291338, 291912, 292486, 293060, 295359, 295933, 296507, 297081, 297655, 298229, 298803, 299377, 299951, 300525, 301099, 301673, 302247, 302821, 303395, 303969, 304543, 322245, 322819, 323393, 323967, 324541, 325115, 327414, 327988, 328562, 329136, 329710, 330284, 330858, 331432, 332006, 332580, 333154, 333728, 334302, 334876, 335450, 336024, 336598, 347433, 348007, 348581, 349155, 349729, 350303, 350877, 351451, 352025, 352599, 353173, 353747, 354321, 354895, 355469, 356043, 356617, 362885, 363459, 364033, 364607, 365181, 365755, 366329, 366903, 367477, 368051, 372045, 372619, 373193, 373767, 376054]; M(ci) = c(99); ci = [272550, 283474, 284048, 284622, 290371, 290945, 291519, 292093, 292667, 293241, 295540, 296114, 296688, 297262, 297836, 298410, 298984, 299558, 300132, 300706, 301280, 301854, 302428, 303002, 303576, 304150, 304724, 315493, 316067, 316641, 322390, 322964, 323538, 324112, 324686, 325260, 327559, 328133, 328707, 329281, 329855, 330429, 331003, 331577, 332151, 332725, 333299, 333873, 334447, 335021, 335595, 336169, 336743, 342370, 342944, 343518, 344092, 344666, 345240, 347539, 348113, 348687, 349261, 349835, 350409, 350983, 351557, 352131, 352705, 353279, 353853, 354427, 355001, 355575, 356149, 356723, 358933, 359507, 360081, 360655, 361229, 361803, 362377, 362951, 363525, 364099, 364673, 365247, 365821, 366395, 366969, 367543, 368117, 368635, 369209, 369783, 370357, 370931, 371505, 372079, 372653, 373227, 373801, 374345, 374919, 375493, 376067, 376629]; M(ci) = c(100); %Mr = rref(M); % replace me with a MEX index1 = [1:330, 332:443, 448:520, 531:570, 587:598, 602:605, 622:625]; index2 = [656 655 654 653 652 651 650 649 648 647 646 645 644 643 642 641 640 639 638 637 636 635 634 633 632 631 630 629 628 627 626 621 620 619 618 617 616 615 614 613 612 611 610 609 608 607 606 601 600 599 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 530 529 528 527 526 525 524 523 522 521 447 446 445 444 331]; Mr = M(:,index1)\M(:,index2); A = zeros(81); %amcols = [656 655 654 653 652 651 650 649 648 647 646 645 644 643 642 641 640 639 638 637 636 635 634 633 632 631 630 629 628 627 626 621 620 619 618 617 616 615 614 613 612 611 610 609 608 607 606 601 600 599 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 530 529 528 527 526 525 524 523 522 521 447 446 445 444 331]; A(1, 5) = 1; A(2, 9) = 1; A(3, 12) = 1; A(4, 14) = 1; A(5, 15) = 1; A(6, 19) = 1; A(7, 22) = 1; A(8, 24) = 1; A(9, 25) = 1; A(10, 28) = 1; A(11, 30) = 1; A(12, 31) = 1; A(13, :) = -Mr(574, :); A(14, :) = -Mr(573, :); A(15, :) = -Mr(572, :); A(16, 35) = 1; A(17, 38) = 1; A(18, 40) = 1; A(19, 41) = 1; A(20, 44) = 1; A(21, 46) = 1; A(22, 47) = 1; A(23, :) = -Mr(570, :); A(24, :) = -Mr(569, :); A(25, :) = -Mr(568, :); A(26, 50) = 1; A(27, :) = -Mr(566, :); A(28, :) = -Mr(565, :); A(29, :) = -Mr(563, :); A(30, :) = -Mr(562, :); A(31, :) = -Mr(561, :); A(32, 54) = 1; A(33, 57) = 1; A(34, 59) = 1; A(35, 60) = 1; A(36, 63) = 1; A(37, 65) = 1; A(38, 66) = 1; A(39, :) = -Mr(554, :); A(40, :) = -Mr(553, :); A(41, :) = -Mr(552, :); A(42, :) = -Mr(549, :); A(43, :) = -Mr(547, :); A(44, :) = -Mr(546, :); A(45, :) = -Mr(544, :); A(46, :) = -Mr(543, :); A(47, :) = -Mr(542, :); A(48, :) = -Mr(534, :); A(49, :) = -Mr(532, :); A(50, :) = -Mr(531, :); A(51, 70) = 1; A(52, 73) = 1; A(53, 75) = 1; A(54, 76) = 1; A(55, :) = -Mr(513, :); A(56, :) = -Mr(511, :); A(57, :) = -Mr(510, :); A(58, :) = -Mr(508, :); A(59, :) = -Mr(507, :); A(60, :) = -Mr(506, :); A(61, :) = -Mr(503, :); A(62, :) = -Mr(501, :); A(63, :) = -Mr(500, :); A(64, :) = -Mr(498, :); A(65, :) = -Mr(497, :); A(66, :) = -Mr(496, :); A(67, 80) = 1; A(68, :) = -Mr(440, :); A(69, :) = -Mr(438, :); A(70, :) = -Mr(437, :); A(71, :) = -Mr(434, :); A(72, :) = -Mr(432, :); A(73, :) = -Mr(431, :); A(74, :) = -Mr(429, :); A(75, :) = -Mr(428, :); A(76, :) = -Mr(427, :); A(77, :) = -Mr(328, :); A(78, :) = -Mr(325, :); A(79, :) = -Mr(323, :); A(80, :) = -Mr(322, :); A(81, :) = -Mr(179, :); [V D] = eig(A); sol = V([5, 4, 3, 2],:)./(ones(4, 1)*V(1,:)); if (find(isnan(sol(:))) > 0) b = []; a = []; c = []; d = []; else I = find(not(imag( sol(1,:) ))); b = sol(1,I); a = sol(2,I); c = sol(3,I); d = sol(4,I); end end
github
urbste/MLPnP_matlab_toolbox-master
quaternion2matrix.m
.m
MLPnP_matlab_toolbox-master/OPnP/quaternion2matrix.m
1,431
utf_8
49448898df2a32720040da4eb82aced9
% QUATERNION2MATRIX - Quaternion to a 4x4 homogeneous transformation matrix % % Usage: T = quaternion2matrix(Q) % % Argument: Q - a quaternion in the form [w xi yj zk] % Returns: T - 4x4 Homogeneous rotation matrix % % See also MATRIX2QUATERNION, NEWQUATERNION, QUATERNIONROTATE % Copyright (c) 2008 Peter Kovesi % School of Computer Science & Software Engineering % The University of Western Australia % pk at csse uwa edu au % http://www.csse.uwa.edu.au/ % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal % in the Software without restriction, subject to the following conditions: % % The above copyright notice and this permission notice shall be included in % all copies or substantial portions of the Software. % % The Software is provided "as is", without warranty of any kind. function T = quaternion2matrix(Q) Q = Q/norm(Q); % Ensure Q has unit norm % Set up convenience variables w = Q(1); x = Q(2); y = Q(3); z = Q(4); w2 = w^2; x2 = x^2; y2 = y^2; z2 = z^2; xy = x*y; xz = x*z; yz = y*z; wx = w*x; wy = w*y; wz = w*z; T = [w2+x2-y2-z2 , 2*(xy - wz) , 2*(wy + xz) , 0 2*(wz + xy) , w2-x2+y2-z2 , 2*(yz - wx) , 0 2*(xz - wy) , 2*(wx + yz) , w2-x2-y2+z2 , 0 0 , 0 , 0 , 1]; T = T(1:3,1:3); end
github
urbste/MLPnP_matlab_toolbox-master
CEPPnP.m
.m
MLPnP_matlab_toolbox-master/CEPPnP/CEPPnP.m
1,516
utf_8
862e2e8d00285510a4f31b17bc47c70c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the CEPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Leveraging Feature Uncertainty in the PnP Problem. % In Proceedings of BMVC, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, September 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T, err] = CEPPnP(Pts,impts,Cu) sol_iter = 1; %indicates if the initial solution must be optimized dims = 4; %kernel dimensions %Compute M [M, dM, Cw, Alph] = PrepareData2(Pts,impts); [~,~,Km] = svd(M'*M); [~,tKm,~] = FNSani(M,dM,Cu,Km(:,end)); Km = tKm(:,[end-dims+1:end]); [R, T, err] = KernelPnP(Cw, Km, dims, sol_iter); end
github
urbste/MLPnP_matlab_toolbox-master
CEPPnP_planar.m
.m
MLPnP_matlab_toolbox-master/CEPPnP/CEPPnP_planar.m
2,096
utf_8
e3a6a69fbe1af233d45a921e01811d70
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the CEPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Leveraging Feature Uncertainty in the PnP Problem. % In Proceedings of BMVC, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, September 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T, err] = CEPPnP(Pts,impts,Cu) sol_iter = 1; %indicates if the initial solution must be optimized dims = 3; %kernel dimensions % meanPts = mean(Pts,2); % mPts = Pts-repmat(meanPts,1,size(Pts,2)); %Compute M [M, dM, Cw, ~] = PrepareData2(Pts,impts); idx = find(sum((reshape(sum(M.^2),[3,4])))<0.001); if(~isempty(idx)) if (idx == 1) M = M(:,[4:12]); dM = dM(:,[4:12]); Cw = Cw(:,[2,3,4]); elseif (idx ==2) M = M(:,[1:3,7:12]); dM = dM(:,[1:3,7:12]); Cw = Cw(:,[1,3,4]); else M = M(:,[1:6,10:12]); dM = dM(:,[1:6,10:12]); Cw = Cw(:,[1,2,4]); end end [~,~,Km] = svd(M'*M); [~,tKm,~] = FNSani(M,dM,Cu,Km(:,end)); Km = tKm(:,[end-dims+1:end]); [R, T, err] = KernelPnP(Cw, Km, dims, sol_iter); % T = T - R * meanPts; end
github
urbste/MLPnP_matlab_toolbox-master
PrepareData2.m
.m
MLPnP_matlab_toolbox-master/CEPPnP/PrepareData2.m
1,772
utf_8
2d6d732658041c8b2179aa3803dda9c7
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the CEPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Leveraging Feature Uncertainty in the PnP Problem. % In Proceedings of BMVC, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, September 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [M, dM, Cw, Alph] = PrepareData(Pts,impts,Cw) if ~exist('Cw','var') Cw=define_control_points()'; end Xw=Pts'; U=impts; %compute alphas (linear combination of the control points to represent the 3d points) Alph=compute_alphas(Xw,Cw'); %Compute M M =ComputeM(U(:),Alph); %Compute gradient of M dM =ComputedM(Alph); end function M = ComputeM(U,Alph) %ATTENTION U must be multiplied by K previously M = kron(Alph,[1 0 -1; 0 1 -1]); M(:,[[3,6,9,12]]) = M(:,[3,6,9,12]) .* (U * ones(1,4)); end function dM = ComputedM(Alph) dM = kron(Alph,[0 0 -1; 0 0 -1]); end
github
urbste/MLPnP_matlab_toolbox-master
FNSani.m
.m
MLPnP_matlab_toolbox-master/CEPPnP/FNSani.m
3,016
utf_8
80213643eb98be64bbcdd0f7c5415f7e
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the CEPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Leveraging Feature Uncertainty in the PnP Problem. % In Proceedings of BMVC, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, September 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [ resTheta, vecTheta, valTheta] = FNS(M,dM,Cu,Vn) %% Fundamental Numerical Scheme nU = size(M,1)/2; nV = size(M,2); W = ones(1,nU); CMu2 = zeros(nV,nV*nU); M22 = zeros(nV,nV*nU); tones = ones(nV,nV); Mt = M'; dMt = dM'; ssCu = sqrt(squeeze([sum(sum(Cu(:,:,:)))])'); %sum(sum(Cu(:,:,j))) ssCu = [ssCu; ssCu]; ssCu = repmat(ssCu(:)',nV,1); dMt = dMt .* ssCu; tdMt = dMt(:,1:2:2*nU); idx = 1:nV*nU; idx = reshape(idx,nV,nU); mMt = reshape(Mt,nV,2,nU); for id = 1:nU dMit = tdMt(:,id); CMu2(:,idx(:,id)) = dMit * dMit'; Mti = mMt(:,:,id); M22(:,idx(:,id)) = Mti * Mti'; end %indices for kronecker product ma = 1; na = nU; mb = nV; nb = nV; [ia,ib] = meshgrid(1:ma,1:mb); [ja,jb] = meshgrid(1:na,1:nb); for it = 1:100 % 2.- Compute Vnt = Vn'; W = Vnt * reshape(Vnt * CMu2,nV,nU); W = 1./W; W = W./norm(W); W2 = W.^2; %hessian %"for" unfolding tW = W(ia,ja).*tones(ib,jb); tW2 = W2(ia,ja).*tones(ib,jb); tN = M22.*tW; N = sum(reshape(tN,nV,nV,nU),3); tCMuW2 = CMu2 .* tW2; VntM2Vn = Vnt * reshape(Vnt * M22,nV,nU); tVntM2Vn = VntM2Vn(ia,ja).*tones(ib,jb); %kron(VntM2Vn,tones); tL = tVntM2Vn .* tCMuW2; L = sum(reshape(full(tL),nV,nV,nU),3); [~,s,v] = svd(N-L); rv = real(v(:,end)); % 4.- If Theta = Theta0 up to sign => stop if sum(abs(sign(Vn) - sign(rv(:,1)))) < eps break; else Vn = rv(:,1); end end resTheta = Vn; vecTheta = v; valTheta = s; end
github
urbste/MLPnP_matlab_toolbox-master
robust_dls_pnp.m
.m
MLPnP_matlab_toolbox-master/dls_pnp_matlab/robust_dls_pnp.m
1,864
utf_8
4a3e052a96136d67b99b5dcbb76cf155
function [C_est, t_est, cost, flag] = robust_dls_pnp(p, z) C_temp1 = zeros(3,3,0); t_temp1 = zeros(3,0); C_temp2 = zeros(3,3,0); t_temp2 = zeros(3,0); R = cat(3, rotx(pi/2), roty(pi/2), rotz(pi/2)); t = mean(p,2); cost = inf; for i = 1:3 % Make a random rotation pp = R(:,:,i) * (p - repmat(t, 1, size(p,2))); [C_est_i, t_est_i, cost_i, flag_i] = dls_pnp(pp, z); for j = 1:length(cost_i) t_est_i(:,j) = t_est_i(:,j) - C_est_i(:,:,j) * R(:,:,i) * t; C_est_i(:,:,j) = C_est_i(:,:,j) * R(:,:,i); end % if min(cost_i) < min(cost) % C_est = C_est_i; % t_est = t_est_i; % cost = cost_i; % flag = flag_i; % end min_cost_i = min(cost_i); index = find(cost_i < min_cost_i*2); C_temp1 = cat(3,C_temp1, C_est_i(:,:,index)); t_temp1 = [t_temp1 t_est_i(:,index)]; C_temp2 = cat(3,C_temp2, C_est_i); t_temp2 = [t_temp2 t_est_i]; end if size(p,2) <= 6 C_est = C_temp1; t_est = t_temp1; else %since there are three different objectives in DLS+++, %we should use a single objective to select the final solution. %here, we use the reprojection error. for i = 1:size(C_temp2,3) proj = C_temp2(:,:,i)*p + t_temp2(:,i)*ones(1,size(p,2)); proj = proj(1:2,:)./repmat(proj(3,:),2,1); cost_i = norm(z-proj,'fro'); if cost_i < cost C_est = C_temp2(:,:,i); t_est = t_temp2(:,i); cost = cost_i; end end end end function r = rotx(t) ct = cos(t); st = sin(t); r = [1 0 0; 0 ct -st; 0 st ct]; end function r = roty(t) % roty: rotation about y-axi- ct = cos(t); st = sin(t); r = [ct 0 st; 0 1 0; -st 0 ct]; end function r = rotz(t) % rotz: rotation about z-axis ct = cos(t); st = sin(t); r = [ct -st 0 st ct 0 0 0 1]; end
github
urbste/MLPnP_matlab_toolbox-master
rws.m
.m
MLPnP_matlab_toolbox-master/dls_pnp_matlab/rws.m
1,946
utf_8
24dabc05143cbf2c126ab352eb83b32f
function [C, t, p, z] = rws(N, sigma) % this function generates a random camera pose, along with N random points, % and also the perspective projections of those points. % Generate a random global-to-camera rotation. This is the orientation of % the global frame expressed in the camera frame of refence. angle = 15; C = rotx(angle * randn * pi/180 ) * roty( angle * randn * pi/180 ); % Generate a random global-to-camera translation. This is the origin of the % global frame expressed in the camera frame. t = randn(3,1); % Create random 3D points within a 45 deg FOV (vertical and horizontal) of % the camera. The points are between 0.5 and 5.5 meters from the camera. Psens = zeros(3,N); theta = (rand(N,1)*45 - 22.5) * pi/180; phi = (rand(N,1)*45 - 22.5) * pi/180; for i = 1:N psens_unit = rotx(theta(i)) * roty(phi(i)) * [0;0;1]; alpha = rand * 5 + 0.5; Psens(:,i) = alpha * psens_unit; end % Express the points in the global frame of reference p = C' *(Psens - repmat(t,1,N)); % Construct the vector of perspective projections (i.e., image % measurements) of the points, z = zeros(2,N); for i = 1:N % create an instance of 2x1 pixel noise noise = sigma * randn(2,1); % You can uncomment the following lines in order to limit the noise to +/- % 3 sigma % % % if abs(noise(1)) > 3 * sigma % noise(1) = sign(noise(1)) * 3 * sigma; % end % if abs(noise(2)) > 3 * sigma % noise(2) = sign(noise(2)) * 3 * sigma; % end % Create the image measurement using the standard pinhole camera model z(:,i) = [ Psens(1,i) / Psens(3,i) ; Psens(2,i) / Psens(3,i)] + noise; end end function r = rotx(t) %rotx: rotation around the x-axis ct = cos(t); st = sin(t); r = [1 0 0; 0 ct -st; 0 st ct]; end function r = roty(t) % roty: rotation about y-axis ct = cos(t); st = sin(t); r = [ct 0 st; 0 1 0; -st 0 ct]; end
github
urbste/MLPnP_matlab_toolbox-master
dls_pnp_all.m
.m
MLPnP_matlab_toolbox-master/dls_pnp_matlab/dls_pnp_all.m
52,349
utf_8
cfb64972d23830236aafa3ca0ea6ca31
function [C_est, t_est, cost, flag] = dls_pnp(p, z) % DLS-PnP: % % This function performs the DLS-PnP method introduced at ICCV 2011 % Joel A. Hesch and Stergios I. Roumeliotis. "A direct least-squares (dls) % solution for PnP". In Proc. of the Int. Conf. on Computer Vision, % Barcelona, Spain, November 6-13, 2011. % % inputs: % p: 3xN vector of 3D known point features % z: 2xN vector of correpsonding image measurements (calibrated) % Check the inputs if size(z,1) > size(z,2) || size(p,1) > size(p,2) fprintf('Usage: dls_pnp(p,z) \n p: 3xN matrix of 3D points \n z: 2xN matrix of corresponding 2D image measurements (normalized pixel coordinates)') end % make z into unit vectors from normalized pixel coords z = [z; ones(1,size(z,2))]; z = z./ repmat(sqrt(sum(z.*z,1)),3,1); % some preliminaries flag = 0; N = size(z,2); % build coeff matrix % An intermediate matrix, the inverse of what is called "H" in the paper % (see eq. 25) H = zeros(3); for i = 1:N H = H + eye(3) - z(:,i)*z(:,i)'; end A = zeros(3,9); for i = 1:N A = A + (z(:,i)*z(:,i)' - eye(3)) * LeftMultVec(p(:,i)); end A = H\A; D = zeros(9); for i = 1:N D = D + (LeftMultVec(p(:,i)) + A)' * (eye(3) - z(:,i)*z(:,i)') * (LeftMultVec(p(:,i)) + A); end f1coeff = [2*D(1,6) - 2*D(1,8) + 2*D(5,6) - 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) - 2*D(8,1) - 2*D(8,5) - 2*D(8,9) + 2*D(9,6) - 2*D(9,8); % constant term (6*D(1,2) + 6*D(1,4) + 6*D(2,1) - 6*D(2,5) - 6*D(2,9) + 6*D(4,1) - 6*D(4,5) - 6*D(4,9) - 6*D(5,2) - 6*D(5,4) - 6*D(9,2) - 6*D(9,4)); % s1^2 * s2 (4*D(1,7) - 4*D(1,3) + 8*D(2,6) - 8*D(2,8) - 4*D(3,1) + 4*D(3,5) + 4*D(3,9) + 8*D(4,6) - 8*D(4,8) + 4*D(5,3) - 4*D(5,7) + 8*D(6,2) + 8*D(6,4) + 4*D(7,1) - 4*D(7,5) - 4*D(7,9) - 8*D(8,2) - 8*D(8,4) + 4*D(9,3) - 4*D(9,7)); % s1 * s2 (4*D(1,2) - 4*D(1,4) + 4*D(2,1) - 4*D(2,5) - 4*D(2,9) + 8*D(3,6) - 8*D(3,8) - 4*D(4,1) + 4*D(4,5) + 4*D(4,9) - 4*D(5,2) + 4*D(5,4) + 8*D(6,3) + 8*D(6,7) + 8*D(7,6) - 8*D(7,8) - 8*D(8,3) - 8*D(8,7) - 4*D(9,2) + 4*D(9,4)); % s1 * s3 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s2 * s3 (4*D(2,6) - 2*D(1,7) - 2*D(1,3) + 4*D(2,8) - 2*D(3,1) + 2*D(3,5) - 2*D(3,9) + 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) + 4*D(6,4) - 2*D(7,1) + 2*D(7,5) - 2*D(7,9) + 4*D(8,2) + 4*D(8,4) - 2*D(9,3) - 2*D(9,7)); % s2^2 * s3 (2*D(2,5) - 2*D(1,4) - 2*D(2,1) - 2*D(1,2) - 2*D(2,9) - 2*D(4,1) + 2*D(4,5) - 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 2*D(9,2) - 2*D(9,4)); % s2^3 (4*D(1,9) - 4*D(1,1) + 8*D(3,3) + 8*D(3,7) + 4*D(5,5) + 8*D(7,3) + 8*D(7,7) + 4*D(9,1) - 4*D(9,9)); % s1 * s3^2 (4*D(1,1) - 4*D(5,5) - 4*D(5,9) + 8*D(6,6) - 8*D(6,8) - 8*D(8,6) + 8*D(8,8) - 4*D(9,5) - 4*D(9,9)); % s1 (2*D(1,3) + 2*D(1,7) + 4*D(2,6) - 4*D(2,8) + 2*D(3,1) + 2*D(3,5) + 2*D(3,9) - 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) - 4*D(6,4) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 4*D(8,2) + 4*D(8,4) + 2*D(9,3) + 2*D(9,7)); % s3 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 4*D(3,6) + 4*D(3,8) + 2*D(4,1) + 2*D(4,5) + 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) + 4*D(8,3) - 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s2 (2*D(2,9) - 2*D(1,4) - 2*D(2,1) - 2*D(2,5) - 2*D(1,2) + 4*D(3,6) + 4*D(3,8) - 2*D(4,1) - 2*D(4,5) + 2*D(4,9) - 2*D(5,2) - 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) + 4*D(8,3) + 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s2 * s3^2 (6*D(1,6) - 6*D(1,8) - 6*D(5,6) + 6*D(5,8) + 6*D(6,1) - 6*D(6,5) - 6*D(6,9) - 6*D(8,1) + 6*D(8,5) + 6*D(8,9) - 6*D(9,6) + 6*D(9,8)); % s1^2 (2*D(1,8) - 2*D(1,6) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) - 4*D(3,4) - 4*D(4,3) - 4*D(4,7) - 2*D(5,6) + 2*D(5,8) - 2*D(6,1) - 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) - 2*D(8,9) + 2*D(9,6) - 2*D(9,8)); % s3^2 (2*D(1,8) - 2*D(1,6) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) - 4*D(3,4) - 4*D(4,3) + 4*D(4,7) + 2*D(5,6) - 2*D(5,8) - 2*D(6,1) + 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) + 2*D(8,9) - 2*D(9,6) + 2*D(9,8)); % s2^2 (2*D(3,9) - 2*D(1,7) - 2*D(3,1) - 2*D(3,5) - 2*D(1,3) - 2*D(5,3) - 2*D(5,7) - 2*D(7,1) - 2*D(7,5) + 2*D(7,9) + 2*D(9,3) + 2*D(9,7)); % s3^3 (4*D(1,6) + 4*D(1,8) + 8*D(2,3) + 8*D(2,7) + 8*D(3,2) + 8*D(3,4) + 8*D(4,3) + 8*D(4,7) - 4*D(5,6) - 4*D(5,8) + 4*D(6,1) - 4*D(6,5) - 4*D(6,9) + 8*D(7,2) + 8*D(7,4) + 4*D(8,1) - 4*D(8,5) - 4*D(8,9) - 4*D(9,6) - 4*D(9,8)); % s1 * s2 * s3 (4*D(1,5) - 4*D(1,1) + 8*D(2,2) + 8*D(2,4) + 8*D(4,2) + 8*D(4,4) + 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s1 * s2^2 (6*D(1,3) + 6*D(1,7) + 6*D(3,1) - 6*D(3,5) - 6*D(3,9) - 6*D(5,3) - 6*D(5,7) + 6*D(7,1) - 6*D(7,5) - 6*D(7,9) - 6*D(9,3) - 6*D(9,7)); % s1^2 * s3 (4*D(1,1) - 4*D(1,5) - 4*D(1,9) - 4*D(5,1) + 4*D(5,5) + 4*D(5,9) - 4*D(9,1) + 4*D(9,5) + 4*D(9,9))]; % s1^3 f2coeff = [- 2*D(1,3) + 2*D(1,7) - 2*D(3,1) - 2*D(3,5) - 2*D(3,9) - 2*D(5,3) + 2*D(5,7) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 2*D(9,3) + 2*D(9,7); % constant term (4*D(1,5) - 4*D(1,1) + 8*D(2,2) + 8*D(2,4) + 8*D(4,2) + 8*D(4,4) + 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s1^2 * s2 (4*D(1,8) - 4*D(1,6) - 8*D(2,3) + 8*D(2,7) - 8*D(3,2) - 8*D(3,4) - 8*D(4,3) + 8*D(4,7) + 4*D(5,6) - 4*D(5,8) - 4*D(6,1) + 4*D(6,5) - 4*D(6,9) + 8*D(7,2) + 8*D(7,4) + 4*D(8,1) - 4*D(8,5) + 4*D(8,9) - 4*D(9,6) + 4*D(9,8)); % s1 * s2 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s1 * s3 (4*D(1,4) - 4*D(1,2) - 4*D(2,1) + 4*D(2,5) - 4*D(2,9) - 8*D(3,6) - 8*D(3,8) + 4*D(4,1) - 4*D(4,5) + 4*D(4,9) + 4*D(5,2) - 4*D(5,4) - 8*D(6,3) + 8*D(6,7) + 8*D(7,6) + 8*D(7,8) - 8*D(8,3) + 8*D(8,7) - 4*D(9,2) + 4*D(9,4)); % s2 * s3 (6*D(5,6) - 6*D(1,8) - 6*D(1,6) + 6*D(5,8) - 6*D(6,1) + 6*D(6,5) - 6*D(6,9) - 6*D(8,1) + 6*D(8,5) - 6*D(8,9) - 6*D(9,6) - 6*D(9,8)); % s2^2 * s3 (4*D(1,1) - 4*D(1,5) + 4*D(1,9) - 4*D(5,1) + 4*D(5,5) - 4*D(5,9) + 4*D(9,1) - 4*D(9,5) + 4*D(9,9)); % s2^3 (2*D(2,9) - 2*D(1,4) - 2*D(2,1) - 2*D(2,5) - 2*D(1,2) + 4*D(3,6) + 4*D(3,8) - 2*D(4,1) - 2*D(4,5) + 2*D(4,9) - 2*D(5,2) - 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) + 4*D(8,3) + 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s1 * s3^2 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 4*D(3,6) + 4*D(3,8) + 2*D(4,1) + 2*D(4,5) + 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) + 4*D(8,3) - 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s1 (2*D(1,6) + 2*D(1,8) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) + 4*D(3,4) + 4*D(4,3) - 4*D(4,7) + 2*D(5,6) + 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s3 (8*D(3,3) - 4*D(1,9) - 4*D(1,1) - 8*D(3,7) + 4*D(5,5) - 8*D(7,3) + 8*D(7,7) - 4*D(9,1) - 4*D(9,9)); % s2 (4*D(1,1) - 4*D(5,5) + 4*D(5,9) + 8*D(6,6) + 8*D(6,8) + 8*D(8,6) + 8*D(8,8) + 4*D(9,5) - 4*D(9,9)); % s2 * s3^2 (2*D(1,7) - 2*D(1,3) + 4*D(2,6) - 4*D(2,8) - 2*D(3,1) + 2*D(3,5) + 2*D(3,9) + 4*D(4,6) - 4*D(4,8) + 2*D(5,3) - 2*D(5,7) + 4*D(6,2) + 4*D(6,4) + 2*D(7,1) - 2*D(7,5) - 2*D(7,9) - 4*D(8,2) - 4*D(8,4) + 2*D(9,3) - 2*D(9,7)); % s1^2 (2*D(1,3) - 2*D(1,7) + 4*D(2,6) + 4*D(2,8) + 2*D(3,1) + 2*D(3,5) - 2*D(3,9) - 4*D(4,6) - 4*D(4,8) + 2*D(5,3) - 2*D(5,7) + 4*D(6,2) - 4*D(6,4) - 2*D(7,1) - 2*D(7,5) + 2*D(7,9) + 4*D(8,2) - 4*D(8,4) - 2*D(9,3) + 2*D(9,7)); % s3^2 (6*D(1,3) - 6*D(1,7) + 6*D(3,1) - 6*D(3,5) + 6*D(3,9) - 6*D(5,3) + 6*D(5,7) - 6*D(7,1) + 6*D(7,5) - 6*D(7,9) + 6*D(9,3) - 6*D(9,7)); % s2^2 (2*D(6,9) - 2*D(1,8) - 2*D(5,6) - 2*D(5,8) - 2*D(6,1) - 2*D(6,5) - 2*D(1,6) - 2*D(8,1) - 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s3^3 (8*D(2,6) - 4*D(1,7) - 4*D(1,3) + 8*D(2,8) - 4*D(3,1) + 4*D(3,5) - 4*D(3,9) + 8*D(4,6) + 8*D(4,8) + 4*D(5,3) + 4*D(5,7) + 8*D(6,2) + 8*D(6,4) - 4*D(7,1) + 4*D(7,5) - 4*D(7,9) + 8*D(8,2) + 8*D(8,4) - 4*D(9,3) - 4*D(9,7)); % s1 * s2 * s3 (6*D(2,5) - 6*D(1,4) - 6*D(2,1) - 6*D(1,2) - 6*D(2,9) - 6*D(4,1) + 6*D(4,5) - 6*D(4,9) + 6*D(5,2) + 6*D(5,4) - 6*D(9,2) - 6*D(9,4)); % s1 * s2^2 (2*D(1,6) + 2*D(1,8) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) + 4*D(3,4) + 4*D(4,3) + 4*D(4,7) - 2*D(5,6) - 2*D(5,8) + 2*D(6,1) - 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s1^2 * s3 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) - 2*D(2,5) - 2*D(2,9) + 2*D(4,1) - 2*D(4,5) - 2*D(4,9) - 2*D(5,2) - 2*D(5,4) - 2*D(9,2) - 2*D(9,4))]; % s1^3 f3coeff = [2*D(1,2) - 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 2*D(4,1) - 2*D(4,5) - 2*D(4,9) + 2*D(5,2) - 2*D(5,4) + 2*D(9,2) - 2*D(9,4); % constant term (2*D(1,6) + 2*D(1,8) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) + 4*D(3,4) + 4*D(4,3) + 4*D(4,7) - 2*D(5,6) - 2*D(5,8) + 2*D(6,1) - 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s1^2 * s2 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s1 * s2 (4*D(1,8) - 4*D(1,6) + 8*D(2,3) + 8*D(2,7) + 8*D(3,2) - 8*D(3,4) - 8*D(4,3) - 8*D(4,7) - 4*D(5,6) + 4*D(5,8) - 4*D(6,1) - 4*D(6,5) + 4*D(6,9) + 8*D(7,2) - 8*D(7,4) + 4*D(8,1) + 4*D(8,5) - 4*D(8,9) + 4*D(9,6) - 4*D(9,8)); % s1 * s3 (4*D(1,3) - 4*D(1,7) + 8*D(2,6) + 8*D(2,8) + 4*D(3,1) + 4*D(3,5) - 4*D(3,9) - 8*D(4,6) - 8*D(4,8) + 4*D(5,3) - 4*D(5,7) + 8*D(6,2) - 8*D(6,4) - 4*D(7,1) - 4*D(7,5) + 4*D(7,9) + 8*D(8,2) - 8*D(8,4) - 4*D(9,3) + 4*D(9,7)); % s2 * s3 (4*D(1,1) - 4*D(5,5) + 4*D(5,9) + 8*D(6,6) + 8*D(6,8) + 8*D(8,6) + 8*D(8,8) + 4*D(9,5) - 4*D(9,9)); % s2^2 * s3 (2*D(5,6) - 2*D(1,8) - 2*D(1,6) + 2*D(5,8) - 2*D(6,1) + 2*D(6,5) - 2*D(6,9) - 2*D(8,1) + 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s2^3 (6*D(3,9) - 6*D(1,7) - 6*D(3,1) - 6*D(3,5) - 6*D(1,3) - 6*D(5,3) - 6*D(5,7) - 6*D(7,1) - 6*D(7,5) + 6*D(7,9) + 6*D(9,3) + 6*D(9,7)); % s1 * s3^2 (2*D(1,3) + 2*D(1,7) + 4*D(2,6) - 4*D(2,8) + 2*D(3,1) + 2*D(3,5) + 2*D(3,9) - 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) - 4*D(6,4) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 4*D(8,2) + 4*D(8,4) + 2*D(9,3) + 2*D(9,7)); % s1 (8*D(2,2) - 4*D(1,5) - 4*D(1,1) - 8*D(2,4) - 8*D(4,2) + 8*D(4,4) - 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s3 (2*D(1,6) + 2*D(1,8) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) + 4*D(3,4) + 4*D(4,3) - 4*D(4,7) + 2*D(5,6) + 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s2 (6*D(6,9) - 6*D(1,8) - 6*D(5,6) - 6*D(5,8) - 6*D(6,1) - 6*D(6,5) - 6*D(1,6) - 6*D(8,1) - 6*D(8,5) + 6*D(8,9) + 6*D(9,6) + 6*D(9,8)); % s2 * s3^2 (2*D(1,2) - 2*D(1,4) + 2*D(2,1) - 2*D(2,5) - 2*D(2,9) + 4*D(3,6) - 4*D(3,8) - 2*D(4,1) + 2*D(4,5) + 2*D(4,9) - 2*D(5,2) + 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) - 4*D(8,3) - 4*D(8,7) - 2*D(9,2) + 2*D(9,4)); % s1^2 (6*D(1,4) - 6*D(1,2) - 6*D(2,1) - 6*D(2,5) + 6*D(2,9) + 6*D(4,1) + 6*D(4,5) - 6*D(4,9) - 6*D(5,2) + 6*D(5,4) + 6*D(9,2) - 6*D(9,4)); % s3^2 (2*D(1,4) - 2*D(1,2) - 2*D(2,1) + 2*D(2,5) - 2*D(2,9) - 4*D(3,6) - 4*D(3,8) + 2*D(4,1) - 2*D(4,5) + 2*D(4,9) + 2*D(5,2) - 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) - 4*D(8,3) + 4*D(8,7) - 2*D(9,2) + 2*D(9,4)); % s2^2 (4*D(1,1) + 4*D(1,5) - 4*D(1,9) + 4*D(5,1) + 4*D(5,5) - 4*D(5,9) - 4*D(9,1) - 4*D(9,5) + 4*D(9,9)); % s3^3 (4*D(2,9) - 4*D(1,4) - 4*D(2,1) - 4*D(2,5) - 4*D(1,2) + 8*D(3,6) + 8*D(3,8) - 4*D(4,1) - 4*D(4,5) + 4*D(4,9) - 4*D(5,2) - 4*D(5,4) + 8*D(6,3) + 8*D(6,7) + 8*D(7,6) + 8*D(7,8) + 8*D(8,3) + 8*D(8,7) + 4*D(9,2) + 4*D(9,4)); % s1 * s2 * s3 (4*D(2,6) - 2*D(1,7) - 2*D(1,3) + 4*D(2,8) - 2*D(3,1) + 2*D(3,5) - 2*D(3,9) + 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) + 4*D(6,4) - 2*D(7,1) + 2*D(7,5) - 2*D(7,9) + 4*D(8,2) + 4*D(8,4) - 2*D(9,3) - 2*D(9,7)); % s1 * s2^2 (4*D(1,9) - 4*D(1,1) + 8*D(3,3) + 8*D(3,7) + 4*D(5,5) + 8*D(7,3) + 8*D(7,7) + 4*D(9,1) - 4*D(9,9)); % s1^2 * s3 (2*D(1,3) + 2*D(1,7) + 2*D(3,1) - 2*D(3,5) - 2*D(3,9) - 2*D(5,3) - 2*D(5,7) + 2*D(7,1) - 2*D(7,5) - 2*D(7,9) - 2*D(9,3) - 2*D(9,7))]; % s1^3 % Construct the Macaulay matrix % u0 = round(randn(1)*100); % u1 = round(randn(1)*100); % u2 = round(randn(1)*100); % u3 = round(randn(1)*100); %M2 = cayley_LS_M(f1coeff, f2coeff, f3coeff,u0,u1,u2,u3); u = round(randn(4,1) * 100); M2 = cayley_LS_M(f1coeff, f2coeff, f3coeff,u); % construct the multiplication matrix via schur compliment of the Macaulay % matrix Mtilde = M2(1:27,1:27) - M2(1:27,28:120)/M2(28:120,28:120)*M2(28:120,1:27); [V,~] = eig(Mtilde); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Now check the solutions %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % extract the optimal solutions from the eigen decomposition of the % Multiplication matrix sols = zeros(3,27); cost = zeros(27,1); i = 1; for k = 1:27 V(:,k) = V(:,k)/V(1,k); if (imag(V(2,k)) == 0) stmp = V([10 4 2],k); H = Hessian(f1coeff, f2coeff, f3coeff, stmp); if eig(H) > 0 sols(:,i) = stmp; Cbar = cayley2rotbar(stmp); CbarVec = Cbar'; CbarVec = CbarVec(:); cost(i) = CbarVec' * D * CbarVec; i = i+1; end end end sols = sols(:,1:i-1); cost = cost(1:i-1); C_est = zeros(3,3,size(sols,2)); t_est = zeros(3, size(sols,2)); for j = 1:size(sols,2) % recover the optimal orientation C_est(:,:,j) = 1/(1 + sols(:,j)' * sols(:,j)) * cayley2rotbar(sols(:,j)); A2 = zeros(3); for i = 1:N A2 = A2 + eye(3) - z(:,i)*z(:,i)'; end b2 = zeros(3,1); for i = 1:N b2 = b2 + (z(:,i)*z(:,i)' - eye(3)) * C_est(:,:,j) * p(:,i); end % recover the optimal translation t_est(:,j) = A2\b2; end %in case of Cayley-degenerate rotations, DLS might not return any solution. %To make the comparison possible, we simply return all solutions. sols_valid = 1:size(sols,2); % check that the points are infront of the center of perspectivity % sols_valid = []; % for k = 1:size(sols,2) % cam_points = C_est(:,:,k) * p + repmat(t_est(:,k),1, length(p)); % % if isempty(find(cam_points(3,:) < 0)) % sols_valid = [sols_valid; k]; % end % % end t_est = t_est(:,sols_valid); C_est = C_est(:,:,sols_valid); cost = cost(sols_valid); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Some helper functions %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function C = cayley2rotbar(s) C = ( (1-s'*s) * eye(3) + 2 * skewsymm(s) + 2 * (s * s'))'; end function C = skewsymm(X1) % generates skew symmetric matrix C = [0 , -X1(3) , X1(2) X1(3) , 0 , -X1(1) -X1(2) , X1(1) , 0]; end function M = LeftMultVec(v) % R * p = LeftMultVec(p) * vec(R) M = [v' zeros(1,6); zeros(1,3) v' zeros(1,3); zeros(1,6) v']; end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c(3) 0 c(5) c(17) 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u(2) 0 0 0 0 0 u(3) 0 0 u(1) 0 0 0 0 a(9) a(13) 0 0 0 0 0 a(18) 0 a(11) a(3) 0 0 0 0 0 0 0 0 0 a(2) 0 0 a(1) a(15) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(1) b(9) b(13) b(2) 0 b(11) b(3) 0 0 b(15) 0 b(18) 0 0 c(15) c(18) 0 0 0 c(11) c(1) c(9) 0 c(3) 0 0 0 0 0 0 0 0 0 0 c(13) 0 0 0 0 0 0 0 0 0 0 0 c(2); 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u(2) 0 0 0 0 0 u(3) 0 u(4) u(1) 0 0 0 a(4) a(19) 0 a(15) a(18) 0 0 0 0 a(5) a(17) a(11) 0 0 a(2) a(9) a(13) 0 a(3) 0 0 0 0 a(10) a(6) 0 0 0 0 0 b(18) b(3) b(15) 0 b(13) 0 0 0 0 b(9) 0 0 b(2) b(11) b(10) b(4) b(19) 0 0 b(5) b(17) 0 0 b(6) 0 0 0 0 c(6) 0 0 c(3) 0 c(5) c(10) c(4) c(11) c(17) c(9) 0 0 c(2) 0 0 0 0 0 0 c(19) 0 0 0 0 c(13) 0 0 0 c(15) c(18) 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u(2) 0 0 0 0 0 u(3) 0 u(4) u(1) a(15) a(18) a(8) 0 0 a(6) 0 0 0 0 0 a(12) 0 a(5) a(2) a(3) 0 a(4) a(19) a(13) a(17) 0 0 0 0 a(14) 0 0 b(15) b(3) b(18) 0 0 b(17) b(6) b(2) b(19) 0 0 b(13) 0 b(4) 0 0 0 b(5) b(14) b(8) 0 0 0 b(12) 0 0 0 0 0 0 0 0 0 0 0 c(17) 0 c(12) c(14) c(8) c(5) 0 c(4) 0 0 0 0 c(13) 0 0 0 c(3) 0 0 0 0 c(2) c(19) c(15) c(18) 0 c(6) 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(14) 0 a(8) 0 0 0 0 b(13) 0 b(20) b(4) 0 0 b(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(8) b(14) 0 0 0 c(14) c(8) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(13) c(20) c(4) c(19) 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(20) 0 0 0 a(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(8) 0 0 0 0 0 0 b(20) 0 0 b(19) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(8) 0 0 0 c(8) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(20) 0 c(19) 0 0 0 0]'; end function [H] = Hessian(f1coeff, f2coeff, f3coeff, s) % the vector of monomials is % m = [ const ; s1^2 * s2 ; s1 * s2 ; s1 * s3 ; s2 * s3 ; s2^2 * s3 ; s2^3 ; ... % s1 * s3^2 ; s1 ; s3 ; s2 ; s2 * s3^2 ; s1^2 ; s3^2 ; s2^2 ; s3^3 ; ... % s1 * s2 * s3 ; s1 * s2^2 ; s1^2 * s3 ; s1^3] % % deriv of m w.r.t. s1 Hs1 = [0 ; 2 * s(1) * s(2) ; s(2) ; s(3) ; 0 ; 0 ; 0 ; ... s(3)^2 ; 1 ; 0 ; 0 ; 0 ; 2 * s(1) ; 0 ; 0 ; 0 ; ... s(2) * s(3) ; s(2)^2 ; 2*s(1)*s(3); 3 * s(1)^2]; % deriv of m w.r.t. s2 Hs2 = [0 ; s(1)^2 ; s(1) ; 0 ; s(3) ; 2 * s(2) * s(3) ; 3 * s(2)^2 ; ... 0 ; 0 ; 0 ; 1 ; s(3)^2 ; 0 ; 0 ; 2 * s(2) ; 0 ; ... s(1) * s(3) ; s(1) * 2 * s(2) ; 0 ; 0]; % deriv of m w.r.t. s3 Hs3 = [0 ; 0 ; 0 ; s(1) ; s(2) ; s(2)^2 ; 0 ; ... s(1) * 2 * s(3) ; 0 ; 1 ; 0 ; s(2) * 2 * s(3) ; 0 ; 2 * s(3) ; 0 ; 3 * s(3)^2 ; ... s(1) * s(2) ; 0 ; s(1)^2 ; 0]; H = [ f1coeff' * Hs1 , f1coeff' * Hs2 , f1coeff' * Hs3; f2coeff' * Hs1 , f2coeff' * Hs2 , f2coeff' * Hs3; f3coeff' * Hs1 , f3coeff' * Hs2 , f3coeff' * Hs3]; end %function [C] = cayley2rot(s) % C = ( (1-s'*s) * eye(3) + 2 * skewsymm(s) + 2 * s * s')' / ( 1 + s' * s); %end
github
urbste/MLPnP_matlab_toolbox-master
dls_pnp.m
.m
MLPnP_matlab_toolbox-master/dls_pnp_matlab/dls_pnp.m
52,158
utf_8
d6e96e3b74cc29c6f5ddd01bbdb2e1eb
function [C_est, t_est, cost, flag] = dls_pnp(p, z) % DLS-PnP: % % This function performs the DLS-PnP method introduced at ICCV 2011 % Joel A. Hesch and Stergios I. Roumeliotis. "A direct least-squares (dls) % solution for PnP". In Proc. of the Int. Conf. on Computer Vision, % Barcelona, Spain, November 6-13, 2011. % % inputs: % p: 3xN vector of 3D known point features % z: 2xN vector of correpsonding image measurements (calibrated) % Check the inputs if size(z,1) > size(z,2) || size(p,1) > size(p,2) fprintf('Usage: dls_pnp(p,z) \n p: 3xN matrix of 3D points \n z: 2xN matrix of corresponding 2D image measurements (normalized pixel coordinates)') end % make z into unit vectors from normalized pixel coords z = [z; ones(1,size(z,2))]; z = z./ repmat(sqrt(sum(z.*z,1)),3,1); % some preliminaries flag = 0; N = size(z,2); % build coeff matrix % An intermediate matrix, the inverse of what is called "H" in the paper % (see eq. 25) H = zeros(3); for i = 1:N H = H + eye(3) - z(:,i)*z(:,i)'; end A = zeros(3,9); for i = 1:N A = A + (z(:,i)*z(:,i)' - eye(3)) * LeftMultVec(p(:,i)); end A = H\A; D = zeros(9); for i = 1:N D = D + (LeftMultVec(p(:,i)) + A)' * (eye(3) - z(:,i)*z(:,i)') * (LeftMultVec(p(:,i)) + A); end f1coeff = [2*D(1,6) - 2*D(1,8) + 2*D(5,6) - 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) - 2*D(8,1) - 2*D(8,5) - 2*D(8,9) + 2*D(9,6) - 2*D(9,8); % constant term (6*D(1,2) + 6*D(1,4) + 6*D(2,1) - 6*D(2,5) - 6*D(2,9) + 6*D(4,1) - 6*D(4,5) - 6*D(4,9) - 6*D(5,2) - 6*D(5,4) - 6*D(9,2) - 6*D(9,4)); % s1^2 * s2 (4*D(1,7) - 4*D(1,3) + 8*D(2,6) - 8*D(2,8) - 4*D(3,1) + 4*D(3,5) + 4*D(3,9) + 8*D(4,6) - 8*D(4,8) + 4*D(5,3) - 4*D(5,7) + 8*D(6,2) + 8*D(6,4) + 4*D(7,1) - 4*D(7,5) - 4*D(7,9) - 8*D(8,2) - 8*D(8,4) + 4*D(9,3) - 4*D(9,7)); % s1 * s2 (4*D(1,2) - 4*D(1,4) + 4*D(2,1) - 4*D(2,5) - 4*D(2,9) + 8*D(3,6) - 8*D(3,8) - 4*D(4,1) + 4*D(4,5) + 4*D(4,9) - 4*D(5,2) + 4*D(5,4) + 8*D(6,3) + 8*D(6,7) + 8*D(7,6) - 8*D(7,8) - 8*D(8,3) - 8*D(8,7) - 4*D(9,2) + 4*D(9,4)); % s1 * s3 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s2 * s3 (4*D(2,6) - 2*D(1,7) - 2*D(1,3) + 4*D(2,8) - 2*D(3,1) + 2*D(3,5) - 2*D(3,9) + 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) + 4*D(6,4) - 2*D(7,1) + 2*D(7,5) - 2*D(7,9) + 4*D(8,2) + 4*D(8,4) - 2*D(9,3) - 2*D(9,7)); % s2^2 * s3 (2*D(2,5) - 2*D(1,4) - 2*D(2,1) - 2*D(1,2) - 2*D(2,9) - 2*D(4,1) + 2*D(4,5) - 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 2*D(9,2) - 2*D(9,4)); % s2^3 (4*D(1,9) - 4*D(1,1) + 8*D(3,3) + 8*D(3,7) + 4*D(5,5) + 8*D(7,3) + 8*D(7,7) + 4*D(9,1) - 4*D(9,9)); % s1 * s3^2 (4*D(1,1) - 4*D(5,5) - 4*D(5,9) + 8*D(6,6) - 8*D(6,8) - 8*D(8,6) + 8*D(8,8) - 4*D(9,5) - 4*D(9,9)); % s1 (2*D(1,3) + 2*D(1,7) + 4*D(2,6) - 4*D(2,8) + 2*D(3,1) + 2*D(3,5) + 2*D(3,9) - 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) - 4*D(6,4) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 4*D(8,2) + 4*D(8,4) + 2*D(9,3) + 2*D(9,7)); % s3 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 4*D(3,6) + 4*D(3,8) + 2*D(4,1) + 2*D(4,5) + 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) + 4*D(8,3) - 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s2 (2*D(2,9) - 2*D(1,4) - 2*D(2,1) - 2*D(2,5) - 2*D(1,2) + 4*D(3,6) + 4*D(3,8) - 2*D(4,1) - 2*D(4,5) + 2*D(4,9) - 2*D(5,2) - 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) + 4*D(8,3) + 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s2 * s3^2 (6*D(1,6) - 6*D(1,8) - 6*D(5,6) + 6*D(5,8) + 6*D(6,1) - 6*D(6,5) - 6*D(6,9) - 6*D(8,1) + 6*D(8,5) + 6*D(8,9) - 6*D(9,6) + 6*D(9,8)); % s1^2 (2*D(1,8) - 2*D(1,6) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) - 4*D(3,4) - 4*D(4,3) - 4*D(4,7) - 2*D(5,6) + 2*D(5,8) - 2*D(6,1) - 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) - 2*D(8,9) + 2*D(9,6) - 2*D(9,8)); % s3^2 (2*D(1,8) - 2*D(1,6) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) - 4*D(3,4) - 4*D(4,3) + 4*D(4,7) + 2*D(5,6) - 2*D(5,8) - 2*D(6,1) + 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) + 2*D(8,9) - 2*D(9,6) + 2*D(9,8)); % s2^2 (2*D(3,9) - 2*D(1,7) - 2*D(3,1) - 2*D(3,5) - 2*D(1,3) - 2*D(5,3) - 2*D(5,7) - 2*D(7,1) - 2*D(7,5) + 2*D(7,9) + 2*D(9,3) + 2*D(9,7)); % s3^3 (4*D(1,6) + 4*D(1,8) + 8*D(2,3) + 8*D(2,7) + 8*D(3,2) + 8*D(3,4) + 8*D(4,3) + 8*D(4,7) - 4*D(5,6) - 4*D(5,8) + 4*D(6,1) - 4*D(6,5) - 4*D(6,9) + 8*D(7,2) + 8*D(7,4) + 4*D(8,1) - 4*D(8,5) - 4*D(8,9) - 4*D(9,6) - 4*D(9,8)); % s1 * s2 * s3 (4*D(1,5) - 4*D(1,1) + 8*D(2,2) + 8*D(2,4) + 8*D(4,2) + 8*D(4,4) + 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s1 * s2^2 (6*D(1,3) + 6*D(1,7) + 6*D(3,1) - 6*D(3,5) - 6*D(3,9) - 6*D(5,3) - 6*D(5,7) + 6*D(7,1) - 6*D(7,5) - 6*D(7,9) - 6*D(9,3) - 6*D(9,7)); % s1^2 * s3 (4*D(1,1) - 4*D(1,5) - 4*D(1,9) - 4*D(5,1) + 4*D(5,5) + 4*D(5,9) - 4*D(9,1) + 4*D(9,5) + 4*D(9,9))]; % s1^3 f2coeff = [- 2*D(1,3) + 2*D(1,7) - 2*D(3,1) - 2*D(3,5) - 2*D(3,9) - 2*D(5,3) + 2*D(5,7) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 2*D(9,3) + 2*D(9,7); % constant term (4*D(1,5) - 4*D(1,1) + 8*D(2,2) + 8*D(2,4) + 8*D(4,2) + 8*D(4,4) + 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s1^2 * s2 (4*D(1,8) - 4*D(1,6) - 8*D(2,3) + 8*D(2,7) - 8*D(3,2) - 8*D(3,4) - 8*D(4,3) + 8*D(4,7) + 4*D(5,6) - 4*D(5,8) - 4*D(6,1) + 4*D(6,5) - 4*D(6,9) + 8*D(7,2) + 8*D(7,4) + 4*D(8,1) - 4*D(8,5) + 4*D(8,9) - 4*D(9,6) + 4*D(9,8)); % s1 * s2 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s1 * s3 (4*D(1,4) - 4*D(1,2) - 4*D(2,1) + 4*D(2,5) - 4*D(2,9) - 8*D(3,6) - 8*D(3,8) + 4*D(4,1) - 4*D(4,5) + 4*D(4,9) + 4*D(5,2) - 4*D(5,4) - 8*D(6,3) + 8*D(6,7) + 8*D(7,6) + 8*D(7,8) - 8*D(8,3) + 8*D(8,7) - 4*D(9,2) + 4*D(9,4)); % s2 * s3 (6*D(5,6) - 6*D(1,8) - 6*D(1,6) + 6*D(5,8) - 6*D(6,1) + 6*D(6,5) - 6*D(6,9) - 6*D(8,1) + 6*D(8,5) - 6*D(8,9) - 6*D(9,6) - 6*D(9,8)); % s2^2 * s3 (4*D(1,1) - 4*D(1,5) + 4*D(1,9) - 4*D(5,1) + 4*D(5,5) - 4*D(5,9) + 4*D(9,1) - 4*D(9,5) + 4*D(9,9)); % s2^3 (2*D(2,9) - 2*D(1,4) - 2*D(2,1) - 2*D(2,5) - 2*D(1,2) + 4*D(3,6) + 4*D(3,8) - 2*D(4,1) - 2*D(4,5) + 2*D(4,9) - 2*D(5,2) - 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) + 4*D(8,3) + 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s1 * s3^2 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 4*D(3,6) + 4*D(3,8) + 2*D(4,1) + 2*D(4,5) + 2*D(4,9) + 2*D(5,2) + 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) + 4*D(8,3) - 4*D(8,7) + 2*D(9,2) + 2*D(9,4)); % s1 (2*D(1,6) + 2*D(1,8) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) + 4*D(3,4) + 4*D(4,3) - 4*D(4,7) + 2*D(5,6) + 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s3 (8*D(3,3) - 4*D(1,9) - 4*D(1,1) - 8*D(3,7) + 4*D(5,5) - 8*D(7,3) + 8*D(7,7) - 4*D(9,1) - 4*D(9,9)); % s2 (4*D(1,1) - 4*D(5,5) + 4*D(5,9) + 8*D(6,6) + 8*D(6,8) + 8*D(8,6) + 8*D(8,8) + 4*D(9,5) - 4*D(9,9)); % s2 * s3^2 (2*D(1,7) - 2*D(1,3) + 4*D(2,6) - 4*D(2,8) - 2*D(3,1) + 2*D(3,5) + 2*D(3,9) + 4*D(4,6) - 4*D(4,8) + 2*D(5,3) - 2*D(5,7) + 4*D(6,2) + 4*D(6,4) + 2*D(7,1) - 2*D(7,5) - 2*D(7,9) - 4*D(8,2) - 4*D(8,4) + 2*D(9,3) - 2*D(9,7)); % s1^2 (2*D(1,3) - 2*D(1,7) + 4*D(2,6) + 4*D(2,8) + 2*D(3,1) + 2*D(3,5) - 2*D(3,9) - 4*D(4,6) - 4*D(4,8) + 2*D(5,3) - 2*D(5,7) + 4*D(6,2) - 4*D(6,4) - 2*D(7,1) - 2*D(7,5) + 2*D(7,9) + 4*D(8,2) - 4*D(8,4) - 2*D(9,3) + 2*D(9,7)); % s3^2 (6*D(1,3) - 6*D(1,7) + 6*D(3,1) - 6*D(3,5) + 6*D(3,9) - 6*D(5,3) + 6*D(5,7) - 6*D(7,1) + 6*D(7,5) - 6*D(7,9) + 6*D(9,3) - 6*D(9,7)); % s2^2 (2*D(6,9) - 2*D(1,8) - 2*D(5,6) - 2*D(5,8) - 2*D(6,1) - 2*D(6,5) - 2*D(1,6) - 2*D(8,1) - 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s3^3 (8*D(2,6) - 4*D(1,7) - 4*D(1,3) + 8*D(2,8) - 4*D(3,1) + 4*D(3,5) - 4*D(3,9) + 8*D(4,6) + 8*D(4,8) + 4*D(5,3) + 4*D(5,7) + 8*D(6,2) + 8*D(6,4) - 4*D(7,1) + 4*D(7,5) - 4*D(7,9) + 8*D(8,2) + 8*D(8,4) - 4*D(9,3) - 4*D(9,7)); % s1 * s2 * s3 (6*D(2,5) - 6*D(1,4) - 6*D(2,1) - 6*D(1,2) - 6*D(2,9) - 6*D(4,1) + 6*D(4,5) - 6*D(4,9) + 6*D(5,2) + 6*D(5,4) - 6*D(9,2) - 6*D(9,4)); % s1 * s2^2 (2*D(1,6) + 2*D(1,8) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) + 4*D(3,4) + 4*D(4,3) + 4*D(4,7) - 2*D(5,6) - 2*D(5,8) + 2*D(6,1) - 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s1^2 * s3 (2*D(1,2) + 2*D(1,4) + 2*D(2,1) - 2*D(2,5) - 2*D(2,9) + 2*D(4,1) - 2*D(4,5) - 2*D(4,9) - 2*D(5,2) - 2*D(5,4) - 2*D(9,2) - 2*D(9,4))]; % s1^3 f3coeff = [2*D(1,2) - 2*D(1,4) + 2*D(2,1) + 2*D(2,5) + 2*D(2,9) - 2*D(4,1) - 2*D(4,5) - 2*D(4,9) + 2*D(5,2) - 2*D(5,4) + 2*D(9,2) - 2*D(9,4); % constant term (2*D(1,6) + 2*D(1,8) + 4*D(2,3) + 4*D(2,7) + 4*D(3,2) + 4*D(3,4) + 4*D(4,3) + 4*D(4,7) - 2*D(5,6) - 2*D(5,8) + 2*D(6,1) - 2*D(6,5) - 2*D(6,9) + 4*D(7,2) + 4*D(7,4) + 2*D(8,1) - 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s1^2 * s2 (8*D(2,2) - 8*D(3,3) - 8*D(4,4) + 8*D(6,6) + 8*D(7,7) - 8*D(8,8)); % s1 * s2 (4*D(1,8) - 4*D(1,6) + 8*D(2,3) + 8*D(2,7) + 8*D(3,2) - 8*D(3,4) - 8*D(4,3) - 8*D(4,7) - 4*D(5,6) + 4*D(5,8) - 4*D(6,1) - 4*D(6,5) + 4*D(6,9) + 8*D(7,2) - 8*D(7,4) + 4*D(8,1) + 4*D(8,5) - 4*D(8,9) + 4*D(9,6) - 4*D(9,8)); % s1 * s3 (4*D(1,3) - 4*D(1,7) + 8*D(2,6) + 8*D(2,8) + 4*D(3,1) + 4*D(3,5) - 4*D(3,9) - 8*D(4,6) - 8*D(4,8) + 4*D(5,3) - 4*D(5,7) + 8*D(6,2) - 8*D(6,4) - 4*D(7,1) - 4*D(7,5) + 4*D(7,9) + 8*D(8,2) - 8*D(8,4) - 4*D(9,3) + 4*D(9,7)); % s2 * s3 (4*D(1,1) - 4*D(5,5) + 4*D(5,9) + 8*D(6,6) + 8*D(6,8) + 8*D(8,6) + 8*D(8,8) + 4*D(9,5) - 4*D(9,9)); % s2^2 * s3 (2*D(5,6) - 2*D(1,8) - 2*D(1,6) + 2*D(5,8) - 2*D(6,1) + 2*D(6,5) - 2*D(6,9) - 2*D(8,1) + 2*D(8,5) - 2*D(8,9) - 2*D(9,6) - 2*D(9,8)); % s2^3 (6*D(3,9) - 6*D(1,7) - 6*D(3,1) - 6*D(3,5) - 6*D(1,3) - 6*D(5,3) - 6*D(5,7) - 6*D(7,1) - 6*D(7,5) + 6*D(7,9) + 6*D(9,3) + 6*D(9,7)); % s1 * s3^2 (2*D(1,3) + 2*D(1,7) + 4*D(2,6) - 4*D(2,8) + 2*D(3,1) + 2*D(3,5) + 2*D(3,9) - 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) - 4*D(6,4) + 2*D(7,1) + 2*D(7,5) + 2*D(7,9) - 4*D(8,2) + 4*D(8,4) + 2*D(9,3) + 2*D(9,7)); % s1 (8*D(2,2) - 4*D(1,5) - 4*D(1,1) - 8*D(2,4) - 8*D(4,2) + 8*D(4,4) - 4*D(5,1) - 4*D(5,5) + 4*D(9,9)); % s3 (2*D(1,6) + 2*D(1,8) - 4*D(2,3) + 4*D(2,7) - 4*D(3,2) + 4*D(3,4) + 4*D(4,3) - 4*D(4,7) + 2*D(5,6) + 2*D(5,8) + 2*D(6,1) + 2*D(6,5) + 2*D(6,9) + 4*D(7,2) - 4*D(7,4) + 2*D(8,1) + 2*D(8,5) + 2*D(8,9) + 2*D(9,6) + 2*D(9,8)); % s2 (6*D(6,9) - 6*D(1,8) - 6*D(5,6) - 6*D(5,8) - 6*D(6,1) - 6*D(6,5) - 6*D(1,6) - 6*D(8,1) - 6*D(8,5) + 6*D(8,9) + 6*D(9,6) + 6*D(9,8)); % s2 * s3^2 (2*D(1,2) - 2*D(1,4) + 2*D(2,1) - 2*D(2,5) - 2*D(2,9) + 4*D(3,6) - 4*D(3,8) - 2*D(4,1) + 2*D(4,5) + 2*D(4,9) - 2*D(5,2) + 2*D(5,4) + 4*D(6,3) + 4*D(6,7) + 4*D(7,6) - 4*D(7,8) - 4*D(8,3) - 4*D(8,7) - 2*D(9,2) + 2*D(9,4)); % s1^2 (6*D(1,4) - 6*D(1,2) - 6*D(2,1) - 6*D(2,5) + 6*D(2,9) + 6*D(4,1) + 6*D(4,5) - 6*D(4,9) - 6*D(5,2) + 6*D(5,4) + 6*D(9,2) - 6*D(9,4)); % s3^2 (2*D(1,4) - 2*D(1,2) - 2*D(2,1) + 2*D(2,5) - 2*D(2,9) - 4*D(3,6) - 4*D(3,8) + 2*D(4,1) - 2*D(4,5) + 2*D(4,9) + 2*D(5,2) - 2*D(5,4) - 4*D(6,3) + 4*D(6,7) + 4*D(7,6) + 4*D(7,8) - 4*D(8,3) + 4*D(8,7) - 2*D(9,2) + 2*D(9,4)); % s2^2 (4*D(1,1) + 4*D(1,5) - 4*D(1,9) + 4*D(5,1) + 4*D(5,5) - 4*D(5,9) - 4*D(9,1) - 4*D(9,5) + 4*D(9,9)); % s3^3 (4*D(2,9) - 4*D(1,4) - 4*D(2,1) - 4*D(2,5) - 4*D(1,2) + 8*D(3,6) + 8*D(3,8) - 4*D(4,1) - 4*D(4,5) + 4*D(4,9) - 4*D(5,2) - 4*D(5,4) + 8*D(6,3) + 8*D(6,7) + 8*D(7,6) + 8*D(7,8) + 8*D(8,3) + 8*D(8,7) + 4*D(9,2) + 4*D(9,4)); % s1 * s2 * s3 (4*D(2,6) - 2*D(1,7) - 2*D(1,3) + 4*D(2,8) - 2*D(3,1) + 2*D(3,5) - 2*D(3,9) + 4*D(4,6) + 4*D(4,8) + 2*D(5,3) + 2*D(5,7) + 4*D(6,2) + 4*D(6,4) - 2*D(7,1) + 2*D(7,5) - 2*D(7,9) + 4*D(8,2) + 4*D(8,4) - 2*D(9,3) - 2*D(9,7)); % s1 * s2^2 (4*D(1,9) - 4*D(1,1) + 8*D(3,3) + 8*D(3,7) + 4*D(5,5) + 8*D(7,3) + 8*D(7,7) + 4*D(9,1) - 4*D(9,9)); % s1^2 * s3 (2*D(1,3) + 2*D(1,7) + 2*D(3,1) - 2*D(3,5) - 2*D(3,9) - 2*D(5,3) - 2*D(5,7) + 2*D(7,1) - 2*D(7,5) - 2*D(7,9) - 2*D(9,3) - 2*D(9,7))]; % s1^3 % Construct the Macaulay matrix % u0 = round(randn(1)*100); % u1 = round(randn(1)*100); % u2 = round(randn(1)*100); % u3 = round(randn(1)*100); %M2 = cayley_LS_M(f1coeff, f2coeff, f3coeff,u0,u1,u2,u3); u = round(randn(4,1) * 100); M2 = cayley_LS_M(f1coeff, f2coeff, f3coeff,u); % construct the multiplication matrix via schur compliment of the Macaulay % matrix Mtilde = M2(1:27,1:27) - M2(1:27,28:120)/M2(28:120,28:120)*M2(28:120,1:27); [V,~] = eig(Mtilde); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Now check the solutions %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % extract the optimal solutions from the eigen decomposition of the % Multiplication matrix sols = zeros(3,27); cost = zeros(27,1); i = 1; for k = 1:27 V(:,k) = V(:,k)/V(1,k); if (imag(V(2,k)) == 0) stmp = V([10 4 2],k); H = Hessian(f1coeff, f2coeff, f3coeff, stmp); if eig(H) > 0 sols(:,i) = stmp; Cbar = cayley2rotbar(stmp); CbarVec = Cbar'; CbarVec = CbarVec(:); cost(i) = CbarVec' * D * CbarVec; i = i+1; end end end sols = sols(:,1:i-1); cost = cost(1:i-1); C_est = zeros(3,3,size(sols,2)); t_est = zeros(3, size(sols,2)); for j = 1:size(sols,2) % recover the optimal orientation C_est(:,:,j) = 1/(1 + sols(:,j)' * sols(:,j)) * cayley2rotbar(sols(:,j)); A2 = zeros(3); for i = 1:N A2 = A2 + eye(3) - z(:,i)*z(:,i)'; end b2 = zeros(3,1); for i = 1:N b2 = b2 + (z(:,i)*z(:,i)' - eye(3)) * C_est(:,:,j) * p(:,i); end % recover the optimal translation t_est(:,j) = A2\b2; end % check that the points are infront of the center of perspectivity sols_valid = []; for k = 1:size(sols,2) cam_points = C_est(:,:,k) * p + repmat(t_est(:,k),1, length(p)); if isempty(find(cam_points(3,:) < 0)) sols_valid = [sols_valid; k]; end end t_est = t_est(:,sols_valid); C_est = C_est(:,:,sols_valid); cost = cost(sols_valid); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Some helper functions %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function C = cayley2rotbar(s) C = ( (1-s'*s) * eye(3) + 2 * skewsymm(s) + 2 * (s * s'))'; end function C = skewsymm(X1) % generates skew symmetric matrix C = [0 , -X1(3) , X1(2) X1(3) , 0 , -X1(1) -X1(2) , X1(1) , 0]; end function M = LeftMultVec(v) % R * p = LeftMultVec(p) * vec(R) M = [v' zeros(1,6); zeros(1,3) v' zeros(1,3); zeros(1,6) v']; end function M = cayley_LS_M(a,b,c,u) %,u1,u2,u3) % Construct the Macaulay resultant matrix M = [u(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(1) 0; u(4) u(1) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a(1) a(10) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 c(20) 0 c(19) 0 0 0 0]'; end function [H] = Hessian(f1coeff, f2coeff, f3coeff, s) % the vector of monomials is % m = [ const ; s1^2 * s2 ; s1 * s2 ; s1 * s3 ; s2 * s3 ; s2^2 * s3 ; s2^3 ; ... % s1 * s3^2 ; s1 ; s3 ; s2 ; s2 * s3^2 ; s1^2 ; s3^2 ; s2^2 ; s3^3 ; ... % s1 * s2 * s3 ; s1 * s2^2 ; s1^2 * s3 ; s1^3] % % deriv of m w.r.t. s1 Hs1 = [0 ; 2 * s(1) * s(2) ; s(2) ; s(3) ; 0 ; 0 ; 0 ; ... s(3)^2 ; 1 ; 0 ; 0 ; 0 ; 2 * s(1) ; 0 ; 0 ; 0 ; ... s(2) * s(3) ; s(2)^2 ; 2*s(1)*s(3); 3 * s(1)^2]; % deriv of m w.r.t. s2 Hs2 = [0 ; s(1)^2 ; s(1) ; 0 ; s(3) ; 2 * s(2) * s(3) ; 3 * s(2)^2 ; ... 0 ; 0 ; 0 ; 1 ; s(3)^2 ; 0 ; 0 ; 2 * s(2) ; 0 ; ... s(1) * s(3) ; s(1) * 2 * s(2) ; 0 ; 0]; % deriv of m w.r.t. s3 Hs3 = [0 ; 0 ; 0 ; s(1) ; s(2) ; s(2)^2 ; 0 ; ... s(1) * 2 * s(3) ; 0 ; 1 ; 0 ; s(2) * 2 * s(3) ; 0 ; 2 * s(3) ; 0 ; 3 * s(3)^2 ; ... s(1) * s(2) ; 0 ; s(1)^2 ; 0]; H = [ f1coeff' * Hs1 , f1coeff' * Hs2 , f1coeff' * Hs3; f2coeff' * Hs1 , f2coeff' * Hs2 , f2coeff' * Hs3; f3coeff' * Hs1 , f3coeff' * Hs2 , f3coeff' * Hs3]; end %function [C] = cayley2rot(s) % C = ( (1-s'*s) * eye(3) + 2 * skewsymm(s) + 2 * s * s')' / ( 1 + s' * s); %end
github
urbste/MLPnP_matlab_toolbox-master
compute_error.m
.m
MLPnP_matlab_toolbox-master/dls_pnp_matlab/compute_error.m
1,320
utf_8
9661477a57e8c1cd36f99c33566fb9ba
function [da, dt] = compute_error(C, t, Cm, tm) % compute the error quaternion btw. the true and the estimated solutions % (using JPL definition of quaternions) q_del = rot2quat(C' * Cm); % compute the tilt angle error da = norm(q_del(1:3) * 2); % compute the position error dt = norm(t - tm); end function q = rot2quat(R) % converts a rotational matrix to a unit quaternion, according to JPL % procedure (Breckenridge Memo) T = trace(R); [dummy maxpivot] = max([R(1,1) R(2,2) R(3,3) T]); %#ok<ASGLU> switch maxpivot case 1 q(1) = sqrt((1+2*R(1,1)-T)/4); q(2:4) = 1/(4*q(1)) * [R(1,2)+R(2,1); R(1,3)+R(3,1); R(2,3)-R(3,2) ]; case 2 q(2) = sqrt((1+2*R(2,2)-T)/4); q([1 3 4]) = 1/(4*q(2)) * [R(1,2)+R(2,1); R(2,3)+R(3,2); R(3,1)-R(1,3) ]; case 3 q(3) = sqrt((1+2*R(3,3)-T)/4); q([1 2 4]) = 1/(4*q(3)) * [R(1,3)+R(3,1); R(2,3)+R(3,2); R(1,2)-R(2,1) ]; case 4 q(4) = sqrt((1+T)/4); q(1:3) = 1/(4*q(4)) * [R(2,3)-R(3,2); R(3,1)-R(1,3); R(1,2)-R(2,1) ]; end % switch % make column vector q = q(:); % 4th element is always positive if q(4)<0 q = -q; end % quaternion normalization q = q/sqrt(q'*q); end
github
urbste/MLPnP_matlab_toolbox-master
PrepareData.m
.m
MLPnP_matlab_toolbox-master/REPPnP/PrepareData.m
1,668
utf_8
53e2d1b61c8fcd957bee7f6a86b0d173
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [M,Cw, Alph] = PrepareData(Pts,impts,Cw) if ~exist('Cw','var') Cw=define_control_points()'; end Xw=Pts'; U=impts; %compute alphas (linear combination of the control points to represent the 3d points) Alph=compute_alphas(Xw,Cw'); %Compute M M=ComputeM(U(:),Alph); end function M = ComputeM(U,Alph) %ATTENTION U must be multiplied by K previously M = kron(Alph,[1 0 -1; 0 1 -1]); M(:,[[3,6,9,12]]) = M(:,[3,6,9,12]) .* (U * ones(1,4)); end
github
urbste/MLPnP_matlab_toolbox-master
my_robust_kernel_noise.m
.m
MLPnP_matlab_toolbox-master/REPPnP/my_robust_kernel_noise.m
2,512
utf_8
cb9cfcebdbcdf7e6a3cb516c61611e6c
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [K, idinliers, i]=my_robust_kernel_noise(M,dimker, minerror) m = size(M,1); id =round(m/8); idx = 1:m; prev_sv = Inf; pairs = 1; %each correspondence is a couple of equations for i=1:10 N = M(idx,:); [~,~,v] = svd(N'*N); if (pairs) error21 = M(1:2:end,:) * v(:,end); error22 = M(2:2:end,:) * v(:,end); error2 = sqrt(error21.^2 + error22.^2); [sv, tidx] = sort(error2); med = sv(floor(m/8)); else error2 = M * v(:,end); [sv, tidx] = sort(error2.^2); med = sv(floor(m/2)); end ninliers = sum(sv<max(med,minerror)); if (med >= prev_sv) break; else prev_sv = med; resv = v; if(pairs) residx = tidx(1:ninliers); else %always pairs = 1!! :P end end if(pairs) tidx2 = tidx'*2; ttidx = [tidx2-1; tidx2]; tidx2 = ttidx(:); idx = tidx2(1:2*ninliers); else idx = tidx(1:ninliers); end end K = resv(:,end-dimker+1:end); idinliers = residx; end
github
urbste/MLPnP_matlab_toolbox-master
KernelPnP.m
.m
MLPnP_matlab_toolbox-master/REPPnP/KernelPnP.m
2,495
utf_8
c1f05f3483cc93ccf3a9cac0ad06a5a2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T, err] = KernelPnP(Cw, Km, dims, sol_iter) vK = reshape(Km(:,end),3,dims); %precomputations X.P = Cw; X.mP = mean(X.P,2); X.cP = X.P - X.mP * ones(1,dims); X.norm = norm(X.cP(:)); X.nP = X.cP/X.norm; %procrustes solution for the first kernel vector if (mean(vK(3,:)<0)) vK = -vK; end [R,b,mc] = myProcrustes(X,vK); solV = b * vK; solR = R; solmc = mc; % procrustes solution using 4 kernel eigenvectors if sol_iter err = Inf; n_iterations=10; for iter=1:n_iterations % projection of previous solution into the null space A = R * (- mc +X.P); abcd = Km \ A(:); newV = reshape(Km * abcd,3,dims); %eucliedean error newerr = norm(R' * newV + mc - X.P); if ((newerr > err) && (iter>2)) break; else %procrustes solution [R,b,mc] = myProcrustes(X,newV); solV = b * newV; solmc = mc; solR = R; err = newerr; end end end R = solR; mV = mean(solV,2); T = mV - R * X.mP; end
github
urbste/MLPnP_matlab_toolbox-master
REPPnP_planar.m
.m
MLPnP_matlab_toolbox-master/REPPnP/REPPnP_planar.m
2,128
utf_8
897ad9af142a38fc79938ee73e1c9f2e
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T,mask_inliers, robustiters, err] = REPPnP(Pts,impts,varargin) if (nargin < 3) minerror = 0.02; %for the synthetic experiments (f = 800) else nVarargs = length(varargin); for k = 1:nVarargs minerror = varargin{k}; end end sol_iter = 1; %indicates if the initial solution must be optimized dims = 3; %kernel dimensions %Compute M [M, Cw, Alph] = PrepareData(Pts,impts); idx = find(sum((reshape(sum(M.^2),[3,4])))==0); if(~isempty(idx)) M = M(:,setdiff([1:12],[3*(idx-1)+1 3*(idx-1)+2 3*(idx-1)+3])); Cw = Cw(:,setdiff([1:4],idx)); Alph = Alph(:,setdiff([1:4],idx)); end %roubst kernel estimation [Km, idinliers, robustiters] = my_robust_kernel_noise(M,dims,minerror); mask_inliers = zeros(1,size(impts,2)); mask_inliers(idinliers) = 1; [R, T, err] = KernelPnP(Cw, Km, dims, sol_iter); end
github
urbste/MLPnP_matlab_toolbox-master
EPPnP_planar.m
.m
MLPnP_matlab_toolbox-master/REPPnP/EPPnP_planar.m
1,804
utf_8
64e3b8d097cf9d62908123a4290bfa04
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T,err] = EPPnP(Pts,impts) sol_iter = 1; %indicates if the initial solution must be optimized dims = 3; %kernel dimensions % mPts = mean(Pts,2); % Pts = Pts - (mPts * ones(1,size(Pts,2))); [M, Cw, Alph] = PrepareData(Pts,impts); idx = find(sum((reshape(sum(M.^2),[3,4])))==0); if(~isempty(idx)) M = M(:,setdiff([1:12],[3*(idx-1)+1 3*(idx-1)+2 3*(idx-1)+3])); Cw = Cw(:,setdiff([1:4],idx)); Alph = Alph(:,setdiff([1:4],idx)); end Km=kernel_noise(M,dims); %Compute kernel M [R, T, err] = KernelPnP(Cw, Km, dims, sol_iter); % T = T - R * mPts; end
github
urbste/MLPnP_matlab_toolbox-master
EPPnP.m
.m
MLPnP_matlab_toolbox-master/REPPnP/EPPnP.m
1,558
utf_8
699aba608ee9de3e3b6c3f69f12a9d54
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T,err] = EPPnP(Pts,impts) sol_iter = 1; %indicates if the initial solution must be optimized dims = 4; %kernel dimensions % mPts = mean(Pts,2); % Pts = Pts - (mPts * ones(1,size(Pts,2))); [M, Cw, Alph] = PrepareData(Pts,impts); Km=kernel_noise(M,dims); %Compute kernel M [R, T, err] = KernelPnP(Cw, Km, dims, sol_iter); % T = T - R * mPts; end
github
urbste/MLPnP_matlab_toolbox-master
myProcrustes.m
.m
MLPnP_matlab_toolbox-master/REPPnP/myProcrustes.m
1,668
utf_8
1dc7421009a6a4d8985f27b648124d5a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R, b, mc] = myProcrustes(X,Y) %X is an structure containing points, points centered in the origin, points %normalized %Y are 3D points dims = size(Y,2); mY = mean(Y,2); cY = Y - mY * ones(1,dims); ncY = norm(cY(:)); tcY = cY/ncY; A = X.nP * tcY'; [L, D, M] = svd(A); % R = M * L'; % % if(mY(3)>0 && det(R)<0) R = M * diag([1,1,sign(det(M*L'))])* L'; % end b = sum(diag(D)) * X.norm/ncY; c = X.mP - b*R'*mY; mc = c * ones(1,dims); end
github
urbste/MLPnP_matlab_toolbox-master
REPPnP.m
.m
MLPnP_matlab_toolbox-master/REPPnP/REPPnP.m
1,876
utf_8
c1d6bf7f795e4bb3c975e11c43253a3d
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This toolbox illustrates how to use the REPPnP and EPPnP % algorithms described in: % % Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer. % Very Fast Solution to the PnP Problem with Algebraic Outlier Rejection. % In Proceedings of CVPR, 2014. % % Copyright (C) <2014> <Luis Ferraz, Xavier Binefa, Francesc Moreno-Noguer> % % This program is free software: you can redistribute it and/or modify % it under the terms of the version 3 of the GNU General Public License % as published by the Free Software Foundation. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Luis Ferraz, CMTech-UPF, June 2014. % [email protected],http://cmtech.upf.edu/user/62 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [R,T,mask_inliers, robustiters, err] = REPPnP(Pts,impts,varargin) if (nargin < 3) minerror = 0.02; %for the synthetic experiments (f = 800) else nVarargs = length(varargin); for k = 1:nVarargs minerror = varargin{k}; end end sol_iter = 1; %indicates if the initial solution must be optimized dims = 4; %kernel dimensions %Compute M [M, Cw, Alph] = PrepareData(Pts,impts); %roubst kernel estimation [Km, idinliers, robustiters] = my_robust_kernel_noise(M,dims,minerror); mask_inliers = zeros(1,size(impts,2)); mask_inliers(idinliers) = 1; [R, T, err] = KernelPnP(Cw, Km, dims, sol_iter); end
github
urbste/MLPnP_matlab_toolbox-master
gOp.m
.m
MLPnP_matlab_toolbox-master/gOp/gOp.m
31,248
utf_8
675abc190efa65ccb36a5cb208a999c5
function [R,t,E,info] = gOp(v,X_,opt) % % [R,t] = gOp(v,X) % % returns the global optimum pose % such that % sum_i norm( Q*(R*X+t+c) ) is minimal % % Q = eye(3)-v*v'/norm(v)^2 % % % opt.methode ='3D' -> we are 100 % sure that is is a 3d model % opt.methode ='choose best' -> we are not sure, but take the best result % opt.methode ='choose +t' -> we take the best solution with t(3) > 0 % % opt.acc = 1e-9 -> accuracy of the sedumi solver % % Author: Gerald Schweighofer %% what happens with that equation %% (R*X+t+c)'*Q*(R*X+t+c) %% % get the Model if size(v,1) == 6, %% this is for general camera model c = v(4:6,:); v = v(1:3,:); else c = zeros(size(v)); end if ~isfield(opt,'acc'), opt.acc = 1e-9; end if strcmp( opt.methode , '3D' ), % we call the 3d Estimator t_ = tic; [M,Mc,Mcc]=genrMr_gcm(X_,v,c); %% Mcc is a constant and therefor not used in the optimization [R,t,ok,info] = solve_sdp(@error_to_sedumi,M,Mc,Mcc,opt.acc,X_,v,c); info.time_global_pose = (double(tic) - double(t_))/1e6; if ~ok, disp('Error -> try the other options for planar cases '); return; end else t_ = tic; %% if we have a planar like structure -> bring it into [x,x,const] form !! pl = fitplane(X_); n = normRv(pl(1:3)); if abs(n(3)) == 1, R_ = eye(3); else R_ = rpyMat([pi/2 0 0])*getRotation([0;1;0]',n'); end %R_*X X = R_*X_; [M,Mc,Mcc]=genrMr_gcm(X,v,c); %% if we are unsure if there is a planar target %% we call both [R1,t1,ok1,info1] = solve_sdp(@error_to_sedumi_planar,M,Mc,Mcc,opt.acc,X,v,c); %% check the absolute value of the rotation -> if it is close to zero we get a problem ! if ok1, if abs(R1(1,1)) < 0.2, %% simple approach -> change the rotation R_ = rpyMat([0 0 pi/2])*R_; X = R_*X_; [M,Mc,Mcc]=genrMr_gcm(X,v,c); [R1,t1,ok1,info1] = solve_sdp(@error_to_sedumi_planar,M,Mc,Mcc,opt.acc,X,v,c); end end [R2,t2,ok2,info2] = solve_sdp(@error_to_sedumi_planar_inv,M,Mc,Mcc,opt.acc,X,v,c); %% remove the rotation of the beginning %% X = R_*X; %% Ri*X+t -> Ri*R_*X + t %% info1.time_global_pose = (double(tic) - double(t_))/1e6; info2.time_global_pose = info1.time_global_pose; %% sum up the timings ! time_sedum_call = info1.time_sedum_call + info2.time_sedum_call; info1.time_sedum_call = time_sedum_call; info2.time_sedum_call = time_sedum_call; e=[]; if ok1, R1 = R1*R_; e(end+1).e = get_Error(R1,t1,X_,v,c); e(end).R = R1; e(end).t = t1; e(end).info = info1; end if ok2, R2 = R2*R_; e(end+1).e = get_Error(R2,t2,X_,v,c); e(end).R = R2; e(end).t = t2; e(end).info = info2; end %% take the best if strcmp( opt.methode , 'choose best' ), ee = cat(1,e.e); fi = find( ee == min(ee) ); else if strcmp( opt.methode , 'choose +t' ) ee = cat(2,e.t); fi = find( ee(3,:) > 0 ); if length(fi) > 1, disp('There are two solutions with t(3) > 0 :-) '); %% take the best one e = e(fi); ee = cat(1,e.e); fi = find( ee == min(ee) ); end else disp('something went wrong -> bad option '); kl end end if length(fi) < 1, disp('No Solution found'); kl %% we schould use the constrainained t_opt(3) > 0 -> in that case !! %% and not the R(1,1) > 0 %% That's not implemented yet -> but should be no problem :-) %% An error happens if R(1,1) is close to zereo so that R(1,1) = 0 is a good solution %% then we get that as a result end fi=fi(1); R = e(fi).R; t = e(fi).t; info = e(fi).info; end %% estimate the true value of that function r = R'; r=r(:); info.ErrorM = r' * M * r + Mc.'*r + Mcc; if nargout >= 3 E=get_Error(R,t,X_,v,c); end return; %% ------------------- helper functions -------------------------- function [R,t,ok,info] = solve_sdp(fun,M,Mc,Mcc,acc,X,v,c) % [At_,b_,c_,K_,pars_] = error_to_sedumi(M,Mc,Mcc); [At_,b_,c_,K_,pars_] = feval(fun,M,Mc,Mcc); pars_.eps = acc; pars_.fid = 0; % Here we tried other solvers :-( without any luck %At = At_; b=b_;c=c_;K=K_; %save /var/tmp/sedumi.mat At b c K - V4; % addpath /var/tmp/SDPT3-4.0-beta/ % addpath /var/tmp/SDPT3-4.0-beta/Solver/ % addpath /var/tmp/SDPT3-4.0-beta/Solver/Mexfun % [blk,At,C,b] = read_sedumi(At_,b_,c_,K_); % [obj,X,y,Z] = sqlp(blk,At,C,b); % %solve csdp -> no free variables supported ! % [x,y,z,info]=csdp(At_,b_,c_,K_,pars_) % solve sedumi t = tic; [x,y,info] = sedumi(At_,b_,c_,K_,pars_); info.time_sedum_call = (double(tic) - double(t))/1e6; % extract the solution opt = -y([ 36 16 6 2]); gam = x(16); info.gamma = gam + Mcc; %% thats the lower bound of the system % get the translation R = quat2mat( opt )'; if norm( det(R)-1 ) > 1e-3, disp('Sedumi Failed -> are you sure you don t have a planar target'); ok = 0; t=[]; else t=get_opt_t(R,X,v,c); ok = 1; end function e=get_Error(R,t,X,v,c) clear V for pi_=1:size(v,2), V(pi_).V= (v(:,pi_)*v(:,pi_)')./(v(:,pi_)'*v(:,pi_)); end e = 0; for pi_=1:size(v,2), ei = (V(pi_).V-eye(3)) * (R*X(:,pi_)+t+c(:,pi_)); e = e + ei'*ei; end function t=get_opt_t(R,X,v,c) clear V for pi_=1:size(v,2), V(pi_).V= (v(:,pi_)*v(:,pi_)')./(v(:,pi_)'*v(:,pi_)); end G=zeros(3); for pi_=1:size(v,2), G=G+ V(pi_).V; end G=inv(eye(3)-G/size(v,2))/size(v,2); t_opt = zeros(3,1) ; for pi_=1:size(v,2), t_opt = t_opt + (V(pi_).V-eye(3))*(R*X(:,pi_)+c(:,pi_)); end t = G*t_opt; function [At,b,c,K,pars] = error_to_sedumi_planar_inv(M,Mc,Mcc) % % transfers the function r'*M*r+r'*Mc+Mcc with planar case % -> M([3,6,9],:) approx zero % -> M(:,[3,6,9]) approx zero % % constrains: r1 > 0 , ||r1..4|| = 1 % constrains: R(1,1) < 0 -> to fix the scale of the Rotation % but we use the data in it -> to get a better solution ! % m11 = M(1,1); m12 = M(1,2); m13 = M(1,3); m14 = M(1,4); m15 = M(1,5); m16 = M(1,6); m17 = M(1,7); m18 = M(1,8); m19 = M(1,9); mc1 = Mc(1); m22 = M(2,2); m23 = M(2,3); m24 = M(2,4); m25 = M(2,5); m26 = M(2,6); m27 = M(2,7); m28 = M(2,8); m29 = M(2,9); mc2 = Mc(2); m33 = M(3,3); m34 = M(3,4); m35 = M(3,5); m36 = M(3,6); m37 = M(3,7); m38 = M(3,8); m39 = M(3,9); mc3 = Mc(3); m44 = M(4,4); m45 = M(4,5); m46 = M(4,6); m47 = M(4,7); m48 = M(4,8); m49 = M(4,9); mc4 = Mc(4); m55 = M(5,5); m56 = M(5,6); m57 = M(5,7); m58 = M(5,8); m59 = M(5,9); mc5 = Mc(5); m66 = M(6,6); m67 = M(6,7); m68 = M(6,8); m69 = M(6,9); mc6 = Mc(6); m77 = M(7,7); m78 = M(7,8); m79 = M(7,9); mc7 = Mc(7); m88 = M(8,8); m89 = M(8,9); mc8 = Mc(8); m99 = M(9,9); mc9 = Mc(9); pars.eps = 1e-12; pars.alg = 2; K.s=[5 5 1 15]; K.f=[16]; At=sparse(zeros([292 70])); At(1,1)=-1; At(1,3)=1; At(1,10)=1; At(1,26)=1; At(1,56)=1; At(2,36)=-1; At(2,38)=1; At(2,43)=1; At(2,52)=1; At(2,66)=1; At(3,16)=-1; At(3,18)=1; At(3,23)=1; At(3,32)=1; At(3,62)=1; At(4,6)=-1; At(4,8)=1; At(4,13)=1; At(4,29)=1; At(4,59)=1; At(5,2)=-1; At(5,4)=1; At(5,11)=1; At(5,27)=1; At(5,57)=1; At(6,56)=-1; At(6,58)=1; At(6,61)=1; At(6,65)=1; At(6,70)=1; At(7,46)=-1; At(7,48)=1; At(7,51)=1; At(7,55)=1; At(7,69)=1; At(8,26)=-1; At(8,28)=1; At(8,31)=1; At(8,35)=1; At(8,65)=1; At(9,40)=-1; At(9,42)=1; At(9,45)=1; At(9,54)=1; At(9,68)=1; At(10,20)=-1; At(10,22)=1; At(10,25)=1; At(10,34)=1; At(10,64)=1; At(11,10)=-1; At(11,12)=1; At(11,15)=1; At(11,31)=1; At(11,61)=1; At(12,37)=-1; At(12,39)=1; At(12,44)=1; At(12,53)=1; At(12,67)=1; At(13,17)=-1; At(13,19)=1; At(13,24)=1; At(13,33)=1; At(13,63)=1; At(14,7)=-1; At(14,9)=1; At(14,14)=1; At(14,30)=1; At(14,60)=1; At(15,3)=-1; At(15,5)=1; At(15,12)=1; At(15,28)=1; At(15,58)=1; At(16,1)=1; At(17,3)=1; At(17,10)=1; At(17,26)=-1; At(17,56)=-1; At(18,38)=1; At(18,43)=1; At(18,52)=-1; At(18,66)=-1; At(19,18)=1; At(19,23)=1; At(19,32)=-1; At(19,62)=-1; At(20,8)=1; At(20,13)=1; At(20,29)=-1; At(20,59)=-1; At(21,4)=1; At(21,11)=1; At(21,27)=-1; At(21,57)=-1; At(22,38)=1; At(22,43)=1; At(22,52)=-1; At(22,66)=-1; At(23,58)=1; At(23,61)=1; At(23,65)=-1; At(23,70)=-1; At(24,48)=1; At(24,51)=1; At(24,55)=-1; At(24,69)=-1; At(25,42)=1; At(25,45)=1; At(25,54)=-1; At(25,68)=-1; At(26,39)=1; At(26,44)=1; At(26,53)=-1; At(26,67)=-1; At(27,18)=1; At(27,23)=1; At(27,32)=-1; At(27,62)=-1; At(28,48)=1; At(28,51)=1; At(28,55)=-1; At(28,69)=-1; At(29,28)=1; At(29,31)=1; At(29,35)=-1; At(29,65)=-1; At(30,22)=1; At(30,25)=1; At(30,34)=-1; At(30,64)=-1; At(31,19)=1; At(31,24)=1; At(31,33)=-1; At(31,63)=-1; At(32,8)=1; At(32,13)=1; At(32,29)=-1; At(32,59)=-1; At(33,42)=1; At(33,45)=1; At(33,54)=-1; At(33,68)=-1; At(34,22)=1; At(34,25)=1; At(34,34)=-1; At(34,64)=-1; At(35,12)=1; At(35,15)=1; At(35,31)=-1; At(35,61)=-1; At(36,9)=1; At(36,14)=1; At(36,30)=-1; At(36,60)=-1; At(37,4)=1; At(37,11)=1; At(37,27)=-1; At(37,57)=-1; At(38,39)=1; At(38,44)=1; At(38,53)=-1; At(38,67)=-1; At(39,19)=1; At(39,24)=1; At(39,33)=-1; At(39,63)=-1; At(40,9)=1; At(40,14)=1; At(40,30)=-1; At(40,60)=-1; At(41,5)=1; At(41,12)=1; At(41,28)=-1; At(41,58)=-1; At(42,36)=1; At(43,56)=1; At(44,46)=1; At(45,40)=1; At(46,37)=1; At(47,56)=1; At(48,66)=1; At(49,62)=1; At(50,59)=1; At(51,57)=1; At(52,46)=1; At(53,62)=1; At(54,52)=1; At(55,49)=1; At(56,47)=1; At(57,40)=1; At(58,59)=1; At(59,49)=1; At(60,43)=1; At(61,41)=1; At(62,37)=1; At(63,57)=1; At(64,47)=1; At(65,41)=1; At(66,38)=1; At(67,38)=1; At(67,43)=1; At(67,52)=-1; At(67,66)=-1; At(68,1)=1; At(69,36)=1; At(70,16)=1; At(71,6)=1; At(72,2)=1; At(73,56)=1; At(74,46)=1; At(75,26)=1; At(76,40)=1; At(77,20)=1; At(78,10)=1; At(79,37)=1; At(80,17)=1; At(81,7)=1; At(82,3)=1; At(83,36)=1; At(84,56)=1; At(85,46)=1; At(86,40)=1; At(87,37)=1; At(88,66)=1; At(89,62)=1; At(90,52)=1; At(91,59)=1; At(92,49)=1; At(93,43)=1; At(94,57)=1; At(95,47)=1; At(96,41)=1; At(97,38)=1; At(98,16)=1; At(99,46)=1; At(100,26)=1; At(101,20)=1; At(102,17)=1; At(103,62)=1; At(104,52)=1; At(105,32)=1; At(106,49)=1; At(107,29)=1; At(108,23)=1; At(109,47)=1; At(110,27)=1; At(111,21)=1; At(112,18)=1; At(113,6)=1; At(114,40)=1; At(115,20)=1; At(116,10)=1; At(117,7)=1; At(118,59)=1; At(119,49)=1; At(120,29)=1; At(121,43)=1; At(122,23)=1; At(123,13)=1; At(124,41)=1; At(125,21)=1; At(126,11)=1; At(127,8)=1; At(128,2)=1; At(129,37)=1; At(130,17)=1; At(131,7)=1; At(132,3)=1; At(133,57)=1; At(134,47)=1; At(135,27)=1; At(136,41)=1; At(137,21)=1; At(138,11)=1; At(139,38)=1; At(140,18)=1; At(141,8)=1; At(142,4)=1; At(143,56)=1; At(144,66)=1; At(145,62)=1; At(146,59)=1; At(147,57)=1; At(148,70)=1; At(149,69)=1; At(150,65)=1; At(151,68)=1; At(152,64)=1; At(153,61)=1; At(154,67)=1; At(155,63)=1; At(156,60)=1; At(157,58)=1; At(158,46)=1; At(159,62)=1; At(160,52)=1; At(161,49)=1; At(162,47)=1; At(163,69)=1; At(164,65)=1; At(165,55)=1; At(166,64)=1; At(167,54)=1; At(168,51)=1; At(169,63)=1; At(170,53)=1; At(171,50)=1; At(172,48)=1; At(173,26)=1; At(174,52)=1; At(175,32)=1; At(176,29)=1; At(177,27)=1; At(178,65)=1; At(179,55)=1; At(180,35)=1; At(181,54)=1; At(182,34)=1; At(183,31)=1; At(184,53)=1; At(185,33)=1; At(186,30)=1; At(187,28)=1; At(188,40)=1; At(189,59)=1; At(190,49)=1; At(191,43)=1; At(192,41)=1; At(193,68)=1; At(194,64)=1; At(195,54)=1; At(196,61)=1; At(197,51)=1; At(198,45)=1; At(199,60)=1; At(200,50)=1; At(201,44)=1; At(202,42)=1; At(203,20)=1; At(204,49)=1; At(205,29)=1; At(206,23)=1; At(207,21)=1; At(208,64)=1; At(209,54)=1; At(210,34)=1; At(211,51)=1; At(212,31)=1; At(213,25)=1; At(214,50)=1; At(215,30)=1; At(216,24)=1; At(217,22)=1; At(218,10)=1; At(219,43)=1; At(220,23)=1; At(221,13)=1; At(222,11)=1; At(223,61)=1; At(224,51)=1; At(225,31)=1; At(226,45)=1; At(227,25)=1; At(228,15)=1; At(229,44)=1; At(230,24)=1; At(231,14)=1; At(232,12)=1; At(233,37)=1; At(234,57)=1; At(235,47)=1; At(236,41)=1; At(237,38)=1; At(238,67)=1; At(239,63)=1; At(240,53)=1; At(241,60)=1; At(242,50)=1; At(243,44)=1; At(244,58)=1; At(245,48)=1; At(246,42)=1; At(247,39)=1; At(248,17)=1; At(249,47)=1; At(250,27)=1; At(251,21)=1; At(252,18)=1; At(253,63)=1; At(254,53)=1; At(255,33)=1; At(256,50)=1; At(257,30)=1; At(258,24)=1; At(259,48)=1; At(260,28)=1; At(261,22)=1; At(262,19)=1; At(263,7)=1; At(264,41)=1; At(265,21)=1; At(266,11)=1; At(267,8)=1; At(268,60)=1; At(269,50)=1; At(270,30)=1; At(271,44)=1; At(272,24)=1; At(273,14)=1; At(274,42)=1; At(275,22)=1; At(276,12)=1; At(277,9)=1; At(278,3)=1; At(279,38)=1; At(280,18)=1; At(281,8)=1; At(282,4)=1; At(283,58)=1; At(284,48)=1; At(285,28)=1; At(286,42)=1; At(287,22)=1; At(288,12)=1; At(289,39)=1; At(290,19)=1; At(291,9)=1; At(292,5)=1; b=sparse(zeros([70 1])); b(3)=mc9-mc5-mc1; b(5)=m55-2*m59+m11-2*m19+2*m15+m99; b(7)=2*mc8+2*mc6; b(9)=-4*m18+4*m69-4*m58+4*m89-4*m56-4*m16; b(10)=mc5-mc9-mc1; b(12)=2*m11+4*m88+8*m68-2*m55+4*m59-2*m99+4*m66; b(14)=-4*m18-4*m16-4*m89-4*m69+4*m56+4*m58; b(15)=m11+m55+m99+2*m19-2*m59-2*m15; b(17)=2*mc7+2*mc3; b(19)=4*m79-4*m35-4*m13+4*m39-4*m57-4*m17; b(20)=2*mc2+2*mc4; b(22)=4*m49+8*m36+8*m67-4*m14+4*m29-4*m45+8*m78-4*m12+8*m38-4*m25; b(24)=-4*m79+8*m48-4*m13-4*m17+4*m57+8*m46+8*m26+4*m35-4*m39+8*m28; b(25)=4*m45-4*m14+4*m25-4*m12-4*m29-4*m49; b(26)=mc1-mc5-mc9; b(28)=2*m55+4*m19-2*m11+4*m77+8*m37-2*m99+4*m33; b(30)=4*m16+8*m23+8*m34+4*m18-4*m56+8*m27+8*m47-4*m69-4*m58-4*m89; b(31)=-2*m11-2*m55+4*m44+2*m99+8*m24+4*m15+4*m22; b(33)=4*m17+4*m13-4*m39-4*m35-4*m79-4*m57; b(34)=4*m14-4*m45-4*m25-4*m29+4*m12-4*m49; b(35)=2*m59-2*m19+m99+m11-2*m15+m55; b(37)=2*mc2-2*mc4; b(39)=4*m29-4*m25+4*m14-4*m49-4*m12+4*m45; b(40)=2*mc7-2*mc3; b(42)=4*m35-4*m57-8*m46+8*m28+4*m13+4*m79-4*m39-4*m17+8*m26-8*m48; b(44)=-8*m36-4*m12-4*m29-8*m38+4*m14+4*m49+8*m67+4*m25+8*m78-4*m45; b(45)=-4*m17+4*m13-4*m35+4*m57+4*m39-4*m79; b(46)=-2*mc8+2*mc6; b(48)=8*m23+4*m69-8*m47+4*m58-4*m89-8*m34+4*m18+8*m27-4*m16-4*m56; b(50)=-8*m44+8*m66+8*m22-8*m33-8*m88+8*m77; b(51)=-4*m16-8*m34-8*m23+8*m47+8*m27+4*m18+4*m56+4*m89-4*m69-4*m58; b(53)=4*m12+8*m36-4*m29-4*m14+8*m67+4*m45-8*m38+4*m49-8*m78-4*m25; b(54)=8*m46+8*m26-4*m13+4*m35-4*m57-4*m79-8*m28-8*m48+4*m17+4*m39; b(55)=-4*m56+4*m89-4*m18+4*m16+4*m58-4*m69; b(56)=mc1+mc9+mc5; b(58)=-4*m15-2*m55+4*m44+2*m99-2*m11-8*m24+4*m22; b(60)=4*m69+4*m16+8*m27+8*m34-8*m47+4*m58+4*m18+4*m56-8*m23+4*m89; b(61)=2*m55-2*m11-2*m99-8*m37+4*m33-4*m19+4*m77; b(63)=8*m48+4*m35+4*m39+4*m13+4*m79+4*m17+8*m26+4*m57-8*m46-8*m28; b(64)=-8*m36+8*m67+4*m12+8*m38+4*m14+4*m49+4*m25-8*m78+4*m45+4*m29; b(65)=-4*m59-2*m99-8*m68-2*m55+4*m88+2*m11+4*m66; b(67)=4*m29-4*m49+4*m25+4*m12-4*m45-4*m14; b(68)=4*m17+4*m79-4*m39-4*m13+4*m57-4*m35; b(69)=4*m69-4*m58-4*m89-4*m18+4*m16+4*m56; b(70)=m99+m55+m11+2*m15+2*m19+2*m59; c=sparse(zeros([292 1])); c(16)=-1; function [At,b,c,K,pars] = error_to_sedumi_planar(M,Mc,Mcc) % % transfers the function r'*M*r+r'*Mc+Mcc with planar case % -> M([3,6,9],:) approx zero % -> M(:,[3,6,9]) approx zero % % constrains: r1 > 0 , ||r1..4|| = 1 % constrains: R(1,1) > 0 -> to fix the scale of the Rotation % but we use the data in it -> to get a better solution ! % m11 = M(1,1); m12 = M(1,2); m13 = M(1,3); m14 = M(1,4); m15 = M(1,5); m16 = M(1,6); m17 = M(1,7); m18 = M(1,8); m19 = M(1,9); mc1 = Mc(1); m22 = M(2,2); m23 = M(2,3); m24 = M(2,4); m25 = M(2,5); m26 = M(2,6); m27 = M(2,7); m28 = M(2,8); m29 = M(2,9); mc2 = Mc(2); m33 = M(3,3); m34 = M(3,4); m35 = M(3,5); m36 = M(3,6); m37 = M(3,7); m38 = M(3,8); m39 = M(3,9); mc3 = Mc(3); m44 = M(4,4); m45 = M(4,5); m46 = M(4,6); m47 = M(4,7); m48 = M(4,8); m49 = M(4,9); mc4 = Mc(4); m55 = M(5,5); m56 = M(5,6); m57 = M(5,7); m58 = M(5,8); m59 = M(5,9); mc5 = Mc(5); m66 = M(6,6); m67 = M(6,7); m68 = M(6,8); m69 = M(6,9); mc6 = Mc(6); m77 = M(7,7); m78 = M(7,8); m79 = M(7,9); mc7 = Mc(7); m88 = M(8,8); m89 = M(8,9); mc8 = Mc(8); m99 = M(9,9); mc9 = Mc(9); pars.eps = 1e-12; pars.alg = 2; K.s=[5 5 1 15]; K.f=[16]; At=sparse(zeros([292 70])); At(1,1)=-1; At(1,3)=1; At(1,10)=1; At(1,26)=1; At(1,56)=1; At(2,36)=-1; At(2,38)=1; At(2,43)=1; At(2,52)=1; At(2,66)=1; At(3,16)=-1; At(3,18)=1; At(3,23)=1; At(3,32)=1; At(3,62)=1; At(4,6)=-1; At(4,8)=1; At(4,13)=1; At(4,29)=1; At(4,59)=1; At(5,2)=-1; At(5,4)=1; At(5,11)=1; At(5,27)=1; At(5,57)=1; At(6,56)=-1; At(6,58)=1; At(6,61)=1; At(6,65)=1; At(6,70)=1; At(7,46)=-1; At(7,48)=1; At(7,51)=1; At(7,55)=1; At(7,69)=1; At(8,26)=-1; At(8,28)=1; At(8,31)=1; At(8,35)=1; At(8,65)=1; At(9,40)=-1; At(9,42)=1; At(9,45)=1; At(9,54)=1; At(9,68)=1; At(10,20)=-1; At(10,22)=1; At(10,25)=1; At(10,34)=1; At(10,64)=1; At(11,10)=-1; At(11,12)=1; At(11,15)=1; At(11,31)=1; At(11,61)=1; At(12,37)=-1; At(12,39)=1; At(12,44)=1; At(12,53)=1; At(12,67)=1; At(13,17)=-1; At(13,19)=1; At(13,24)=1; At(13,33)=1; At(13,63)=1; At(14,7)=-1; At(14,9)=1; At(14,14)=1; At(14,30)=1; At(14,60)=1; At(15,3)=-1; At(15,5)=1; At(15,12)=1; At(15,28)=1; At(15,58)=1; At(16,1)=1; At(17,3)=-1; At(17,10)=-1; At(17,26)=1; At(17,56)=1; At(18,38)=-1; At(18,43)=-1; At(18,52)=1; At(18,66)=1; At(19,18)=-1; At(19,23)=-1; At(19,32)=1; At(19,62)=1; At(20,8)=-1; At(20,13)=-1; At(20,29)=1; At(20,59)=1; At(21,4)=-1; At(21,11)=-1; At(21,27)=1; At(21,57)=1; At(22,38)=-1; At(22,43)=-1; At(22,52)=1; At(22,66)=1; At(23,58)=-1; At(23,61)=-1; At(23,65)=1; At(23,70)=1; At(24,48)=-1; At(24,51)=-1; At(24,55)=1; At(24,69)=1; At(25,42)=-1; At(25,45)=-1; At(25,54)=1; At(25,68)=1; At(26,39)=-1; At(26,44)=-1; At(26,53)=1; At(26,67)=1; At(27,18)=-1; At(27,23)=-1; At(27,32)=1; At(27,62)=1; At(28,48)=-1; At(28,51)=-1; At(28,55)=1; At(28,69)=1; At(29,28)=-1; At(29,31)=-1; At(29,35)=1; At(29,65)=1; At(30,22)=-1; At(30,25)=-1; At(30,34)=1; At(30,64)=1; At(31,19)=-1; At(31,24)=-1; At(31,33)=1; At(31,63)=1; At(32,8)=-1; At(32,13)=-1; At(32,29)=1; At(32,59)=1; At(33,42)=-1; At(33,45)=-1; At(33,54)=1; At(33,68)=1; At(34,22)=-1; At(34,25)=-1; At(34,34)=1; At(34,64)=1; At(35,12)=-1; At(35,15)=-1; At(35,31)=1; At(35,61)=1; At(36,9)=-1; At(36,14)=-1; At(36,30)=1; At(36,60)=1; At(37,4)=-1; At(37,11)=-1; At(37,27)=1; At(37,57)=1; At(38,39)=-1; At(38,44)=-1; At(38,53)=1; At(38,67)=1; At(39,19)=-1; At(39,24)=-1; At(39,33)=1; At(39,63)=1; At(40,9)=-1; At(40,14)=-1; At(40,30)=1; At(40,60)=1; At(41,5)=-1; At(41,12)=-1; At(41,28)=1; At(41,58)=1; At(42,36)=1; At(43,56)=1; At(44,46)=1; At(45,40)=1; At(46,37)=1; At(47,56)=1; At(48,66)=1; At(49,62)=1; At(50,59)=1; At(51,57)=1; At(52,46)=1; At(53,62)=1; At(54,52)=1; At(55,49)=1; At(56,47)=1; At(57,40)=1; At(58,59)=1; At(59,49)=1; At(60,43)=1; At(61,41)=1; At(62,37)=1; At(63,57)=1; At(64,47)=1; At(65,41)=1; At(66,38)=1; At(67,38)=-1; At(67,43)=-1; At(67,52)=1; At(67,66)=1; At(68,1)=1; At(69,36)=1; At(70,16)=1; At(71,6)=1; At(72,2)=1; At(73,56)=1; At(74,46)=1; At(75,26)=1; At(76,40)=1; At(77,20)=1; At(78,10)=1; At(79,37)=1; At(80,17)=1; At(81,7)=1; At(82,3)=1; At(83,36)=1; At(84,56)=1; At(85,46)=1; At(86,40)=1; At(87,37)=1; At(88,66)=1; At(89,62)=1; At(90,52)=1; At(91,59)=1; At(92,49)=1; At(93,43)=1; At(94,57)=1; At(95,47)=1; At(96,41)=1; At(97,38)=1; At(98,16)=1; At(99,46)=1; At(100,26)=1; At(101,20)=1; At(102,17)=1; At(103,62)=1; At(104,52)=1; At(105,32)=1; At(106,49)=1; At(107,29)=1; At(108,23)=1; At(109,47)=1; At(110,27)=1; At(111,21)=1; At(112,18)=1; At(113,6)=1; At(114,40)=1; At(115,20)=1; At(116,10)=1; At(117,7)=1; At(118,59)=1; At(119,49)=1; At(120,29)=1; At(121,43)=1; At(122,23)=1; At(123,13)=1; At(124,41)=1; At(125,21)=1; At(126,11)=1; At(127,8)=1; At(128,2)=1; At(129,37)=1; At(130,17)=1; At(131,7)=1; At(132,3)=1; At(133,57)=1; At(134,47)=1; At(135,27)=1; At(136,41)=1; At(137,21)=1; At(138,11)=1; At(139,38)=1; At(140,18)=1; At(141,8)=1; At(142,4)=1; At(143,56)=1; At(144,66)=1; At(145,62)=1; At(146,59)=1; At(147,57)=1; At(148,70)=1; At(149,69)=1; At(150,65)=1; At(151,68)=1; At(152,64)=1; At(153,61)=1; At(154,67)=1; At(155,63)=1; At(156,60)=1; At(157,58)=1; At(158,46)=1; At(159,62)=1; At(160,52)=1; At(161,49)=1; At(162,47)=1; At(163,69)=1; At(164,65)=1; At(165,55)=1; At(166,64)=1; At(167,54)=1; At(168,51)=1; At(169,63)=1; At(170,53)=1; At(171,50)=1; At(172,48)=1; At(173,26)=1; At(174,52)=1; At(175,32)=1; At(176,29)=1; At(177,27)=1; At(178,65)=1; At(179,55)=1; At(180,35)=1; At(181,54)=1; At(182,34)=1; At(183,31)=1; At(184,53)=1; At(185,33)=1; At(186,30)=1; At(187,28)=1; At(188,40)=1; At(189,59)=1; At(190,49)=1; At(191,43)=1; At(192,41)=1; At(193,68)=1; At(194,64)=1; At(195,54)=1; At(196,61)=1; At(197,51)=1; At(198,45)=1; At(199,60)=1; At(200,50)=1; At(201,44)=1; At(202,42)=1; At(203,20)=1; At(204,49)=1; At(205,29)=1; At(206,23)=1; At(207,21)=1; At(208,64)=1; At(209,54)=1; At(210,34)=1; At(211,51)=1; At(212,31)=1; At(213,25)=1; At(214,50)=1; At(215,30)=1; At(216,24)=1; At(217,22)=1; At(218,10)=1; At(219,43)=1; At(220,23)=1; At(221,13)=1; At(222,11)=1; At(223,61)=1; At(224,51)=1; At(225,31)=1; At(226,45)=1; At(227,25)=1; At(228,15)=1; At(229,44)=1; At(230,24)=1; At(231,14)=1; At(232,12)=1; At(233,37)=1; At(234,57)=1; At(235,47)=1; At(236,41)=1; At(237,38)=1; At(238,67)=1; At(239,63)=1; At(240,53)=1; At(241,60)=1; At(242,50)=1; At(243,44)=1; At(244,58)=1; At(245,48)=1; At(246,42)=1; At(247,39)=1; At(248,17)=1; At(249,47)=1; At(250,27)=1; At(251,21)=1; At(252,18)=1; At(253,63)=1; At(254,53)=1; At(255,33)=1; At(256,50)=1; At(257,30)=1; At(258,24)=1; At(259,48)=1; At(260,28)=1; At(261,22)=1; At(262,19)=1; At(263,7)=1; At(264,41)=1; At(265,21)=1; At(266,11)=1; At(267,8)=1; At(268,60)=1; At(269,50)=1; At(270,30)=1; At(271,44)=1; At(272,24)=1; At(273,14)=1; At(274,42)=1; At(275,22)=1; At(276,12)=1; At(277,9)=1; At(278,3)=1; At(279,38)=1; At(280,18)=1; At(281,8)=1; At(282,4)=1; At(283,58)=1; At(284,48)=1; At(285,28)=1; At(286,42)=1; At(287,22)=1; At(288,12)=1; At(289,39)=1; At(290,19)=1; At(291,9)=1; At(292,5)=1; b=sparse(zeros([70 1])); b(3)=-mc5-mc1+mc9; b(5)=2*m15-2*m59+m55-2*m19+m99+m11; b(7)=2*mc6+2*mc8; b(9)=-4*m58+4*m89-4*m18-4*m56+4*m69-4*m16; b(10)=-mc1+mc5-mc9; b(12)=-2*m99+4*m88+4*m59+2*m11-2*m55+8*m68+4*m66; b(14)=4*m58+4*m56-4*m16-4*m18-4*m89-4*m69; b(15)=m99+2*m19+m11-2*m59-2*m15+m55; b(17)=2*mc7+2*mc3; b(19)=-4*m13-4*m57+4*m39+4*m79-4*m35-4*m17; b(20)=2*mc4+2*mc2; b(22)=8*m67-4*m45+8*m36-4*m12+4*m29+4*m49+8*m38-4*m25-4*m14+8*m78; b(24)=4*m57-4*m17+8*m48+8*m46-4*m13+8*m28-4*m39+8*m26+4*m35-4*m79; b(25)=4*m45-4*m12-4*m29+4*m25-4*m49-4*m14; b(26)=-mc9+mc1-mc5; b(28)=4*m33-2*m99-2*m11+8*m37+4*m77+4*m19+2*m55; b(30)=-4*m56+8*m23+4*m16+8*m27+4*m18+8*m47+8*m34-4*m89-4*m58-4*m69; b(31)=2*m99+8*m24+4*m22+4*m15+4*m44-2*m55-2*m11; b(33)=4*m13-4*m57-4*m79+4*m17-4*m39-4*m35; b(34)=4*m14-4*m45-4*m29-4*m49-4*m25+4*m12; b(35)=m11-2*m15+2*m59+m55-2*m19+m99; b(37)=2*mc2-2*mc4; b(39)=4*m45+4*m29-4*m12-4*m49+4*m14-4*m25; b(40)=2*mc7-2*mc3; b(42)=4*m79-8*m46-8*m48+8*m26+8*m28-4*m57+4*m13+4*m35-4*m17-4*m39; b(44)=4*m14-8*m38+8*m78-4*m29-4*m45+4*m25-8*m36-4*m12+4*m49+8*m67; b(45)=4*m57-4*m35-4*m79+4*m13-4*m17+4*m39; b(46)=2*mc6-2*mc8; b(48)=-4*m56+4*m18-4*m16+8*m23+4*m69-8*m34+4*m58+8*m27-4*m89-8*m47; b(50)=-8*m88+8*m66+8*m22-8*m33-8*m44+8*m77; b(51)=4*m56-4*m16+8*m27+8*m47-8*m23-4*m58+4*m18+4*m89-8*m34-4*m69; b(53)=8*m36+4*m45-4*m29+8*m67-8*m78-4*m25-8*m38+4*m12+4*m49-4*m14; b(54)=8*m46-8*m28-4*m13-8*m48+4*m35+8*m26-4*m79+4*m39+4*m17-4*m57; b(55)=-4*m18+4*m16+4*m89-4*m56+4*m58-4*m69; b(56)=mc5+mc9+mc1; b(58)=-8*m24-2*m55-2*m11-4*m15+2*m99+4*m44+4*m22; b(60)=4*m16+4*m18+8*m34+4*m69+4*m89+8*m27-8*m47+4*m56-8*m23+4*m58; b(61)=2*m55+4*m33-2*m99-8*m37+4*m77-2*m11-4*m19; b(63)=8*m48+4*m57-8*m28+4*m79+8*m26+4*m39+4*m17+4*m35+4*m13-8*m46; b(64)=-8*m78+4*m25+8*m67-8*m36+4*m12+4*m29+4*m49+8*m38+4*m45+4*m14; b(65)=-2*m99-2*m55+4*m88+2*m11-8*m68+4*m66-4*m59; b(67)=-4*m45+4*m29-4*m14+4*m25+4*m12-4*m49; b(68)=4*m57+4*m17-4*m13+4*m79-4*m35-4*m39; b(69)=-4*m58-4*m89+4*m16+4*m56+4*m69-4*m18; b(70)=2*m15+2*m19+2*m59+m99+m55+m11; c=sparse(zeros([292 1])); c(16)=-1; function [At,b,c,K,pars] = error_to_sedumi(M,Mc,Mcc) % % transfers the function r'*M*r+r'*Mc+Mcc % % into a SDP problem -> which could be solved by sedumi % % constrains: r1 > 0 , ||r1..4|| = 1 pars.eps = 1e-12; pars.alg = 2; K.s = [5 15]; K.f = 16; At=sparse(zeros([266 70])); At(1,1)=-1; At(1,3)=1; At(1,10)=1; At(1,26)=1; At(1,56)=1; At(2,36)=-1; At(2,38)=1; At(2,43)=1; At(2,52)=1; At(2,66)=1; At(3,16)=-1; At(3,18)=1; At(3,23)=1; At(3,32)=1; At(3,62)=1; At(4,6)=-1; At(4,8)=1; At(4,13)=1; At(4,29)=1; At(4,59)=1; At(5,2)=-1; At(5,4)=1; At(5,11)=1; At(5,27)=1; At(5,57)=1; At(6,56)=-1; At(6,58)=1; At(6,61)=1; At(6,65)=1; At(6,70)=1; At(7,46)=-1; At(7,48)=1; At(7,51)=1; At(7,55)=1; At(7,69)=1; At(8,26)=-1; At(8,28)=1; At(8,31)=1; At(8,35)=1; At(8,65)=1; At(9,40)=-1; At(9,42)=1; At(9,45)=1; At(9,54)=1; At(9,68)=1; At(10,20)=-1; At(10,22)=1; At(10,25)=1; At(10,34)=1; At(10,64)=1; At(11,10)=-1; At(11,12)=1; At(11,15)=1; At(11,31)=1; At(11,61)=1; At(12,37)=-1; At(12,39)=1; At(12,44)=1; At(12,53)=1; At(12,67)=1; At(13,17)=-1; At(13,19)=1; At(13,24)=1; At(13,33)=1; At(13,63)=1; At(14,7)=-1; At(14,9)=1; At(14,14)=1; At(14,30)=1; At(14,60)=1; At(15,3)=-1; At(15,5)=1; At(15,12)=1; At(15,28)=1; At(15,58)=1; At(16,1)=1; At(17,36)=1; At(18,56)=1; At(19,46)=1; At(20,40)=1; At(21,37)=1; At(22,56)=1; At(23,66)=1; At(24,62)=1; At(25,59)=1; At(26,57)=1; At(27,46)=1; At(28,62)=1; At(29,52)=1; At(30,49)=1; At(31,47)=1; At(32,40)=1; At(33,59)=1; At(34,49)=1; At(35,43)=1; At(36,41)=1; At(37,37)=1; At(38,57)=1; At(39,47)=1; At(40,41)=1; At(41,38)=1; At(42,1)=1; At(43,36)=1; At(44,16)=1; At(45,6)=1; At(46,2)=1; At(47,56)=1; At(48,46)=1; At(49,26)=1; At(50,40)=1; At(51,20)=1; At(52,10)=1; At(53,37)=1; At(54,17)=1; At(55,7)=1; At(56,3)=1; At(57,36)=1; At(58,56)=1; At(59,46)=1; At(60,40)=1; At(61,37)=1; At(62,66)=1; At(63,62)=1; At(64,52)=1; At(65,59)=1; At(66,49)=1; At(67,43)=1; At(68,57)=1; At(69,47)=1; At(70,41)=1; At(71,38)=1; At(72,16)=1; At(73,46)=1; At(74,26)=1; At(75,20)=1; At(76,17)=1; At(77,62)=1; At(78,52)=1; At(79,32)=1; At(80,49)=1; At(81,29)=1; At(82,23)=1; At(83,47)=1; At(84,27)=1; At(85,21)=1; At(86,18)=1; At(87,6)=1; At(88,40)=1; At(89,20)=1; At(90,10)=1; At(91,7)=1; At(92,59)=1; At(93,49)=1; At(94,29)=1; At(95,43)=1; At(96,23)=1; At(97,13)=1; At(98,41)=1; At(99,21)=1; At(100,11)=1; At(101,8)=1; At(102,2)=1; At(103,37)=1; At(104,17)=1; At(105,7)=1; At(106,3)=1; At(107,57)=1; At(108,47)=1; At(109,27)=1; At(110,41)=1; At(111,21)=1; At(112,11)=1; At(113,38)=1; At(114,18)=1; At(115,8)=1; At(116,4)=1; At(117,56)=1; At(118,66)=1; At(119,62)=1; At(120,59)=1; At(121,57)=1; At(122,70)=1; At(123,69)=1; At(124,65)=1; At(125,68)=1; At(126,64)=1; At(127,61)=1; At(128,67)=1; At(129,63)=1; At(130,60)=1; At(131,58)=1; At(132,46)=1; At(133,62)=1; At(134,52)=1; At(135,49)=1; At(136,47)=1; At(137,69)=1; At(138,65)=1; At(139,55)=1; At(140,64)=1; At(141,54)=1; At(142,51)=1; At(143,63)=1; At(144,53)=1; At(145,50)=1; At(146,48)=1; At(147,26)=1; At(148,52)=1; At(149,32)=1; At(150,29)=1; At(151,27)=1; At(152,65)=1; At(153,55)=1; At(154,35)=1; At(155,54)=1; At(156,34)=1; At(157,31)=1; At(158,53)=1; At(159,33)=1; At(160,30)=1; At(161,28)=1; At(162,40)=1; At(163,59)=1; At(164,49)=1; At(165,43)=1; At(166,41)=1; At(167,68)=1; At(168,64)=1; At(169,54)=1; At(170,61)=1; At(171,51)=1; At(172,45)=1; At(173,60)=1; At(174,50)=1; At(175,44)=1; At(176,42)=1; At(177,20)=1; At(178,49)=1; At(179,29)=1; At(180,23)=1; At(181,21)=1; At(182,64)=1; At(183,54)=1; At(184,34)=1; At(185,51)=1; At(186,31)=1; At(187,25)=1; At(188,50)=1; At(189,30)=1; At(190,24)=1; At(191,22)=1; At(192,10)=1; At(193,43)=1; At(194,23)=1; At(195,13)=1; At(196,11)=1; At(197,61)=1; At(198,51)=1; At(199,31)=1; At(200,45)=1; At(201,25)=1; At(202,15)=1; At(203,44)=1; At(204,24)=1; At(205,14)=1; At(206,12)=1; At(207,37)=1; At(208,57)=1; At(209,47)=1; At(210,41)=1; At(211,38)=1; At(212,67)=1; At(213,63)=1; At(214,53)=1; At(215,60)=1; At(216,50)=1; At(217,44)=1; At(218,58)=1; At(219,48)=1; At(220,42)=1; At(221,39)=1; At(222,17)=1; At(223,47)=1; At(224,27)=1; At(225,21)=1; At(226,18)=1; At(227,63)=1; At(228,53)=1; At(229,33)=1; At(230,50)=1; At(231,30)=1; At(232,24)=1; At(233,48)=1; At(234,28)=1; At(235,22)=1; At(236,19)=1; At(237,7)=1; At(238,41)=1; At(239,21)=1; At(240,11)=1; At(241,8)=1; At(242,60)=1; At(243,50)=1; At(244,30)=1; At(245,44)=1; At(246,24)=1; At(247,14)=1; At(248,42)=1; At(249,22)=1; At(250,12)=1; At(251,9)=1; At(252,3)=1; At(253,38)=1; At(254,18)=1; At(255,8)=1; At(256,4)=1; At(257,58)=1; At(258,48)=1; At(259,28)=1; At(260,42)=1; At(261,22)=1; At(262,12)=1; At(263,39)=1; At(264,19)=1; At(265,9)=1; At(266,5)=1; b=sparse(zeros([70 1])); m11 = M(1,1); m12 = M(1,2); m13 = M(1,3); m14 = M(1,4); m15 = M(1,5); m16 = M(1,6); m17 = M(1,7); m18 = M(1,8); m19 = M(1,9); mc1 = Mc(1); m22 = M(2,2); m23 = M(2,3); m24 = M(2,4); m25 = M(2,5); m26 = M(2,6); m27 = M(2,7); m28 = M(2,8); m29 = M(2,9); mc2 = Mc(2); m33 = M(3,3); m34 = M(3,4); m35 = M(3,5); m36 = M(3,6); m37 = M(3,7); m38 = M(3,8); m39 = M(3,9); mc3 = Mc(3); m44 = M(4,4); m45 = M(4,5); m46 = M(4,6); m47 = M(4,7); m48 = M(4,8); m49 = M(4,9); mc4 = Mc(4); m55 = M(5,5); m56 = M(5,6); m57 = M(5,7); m58 = M(5,8); m59 = M(5,9); mc5 = Mc(5); m66 = M(6,6); m67 = M(6,7); m68 = M(6,8); m69 = M(6,9); mc6 = Mc(6); m77 = M(7,7); m78 = M(7,8); m79 = M(7,9); mc7 = Mc(7); m88 = M(8,8); m89 = M(8,9); mc8 = Mc(8); m99 = M(9,9); mc9 = Mc(9); b(3)=mc9-mc5-mc1; b(5)=-2*m59+m55+m99-2*m19+2*m15+m11; b(7)=2*mc6+2*mc8; b(9)=-4*m18+4*m69-4*m58-4*m56-4*m16+4*m89; b(10)=-mc9+mc5-mc1; b(12)=-2*m55+4*m88+4*m66-2*m99+2*m11+4*m59+8*m68; b(14)=-4*m16+4*m58-4*m69-4*m18+4*m56-4*m89; b(15)=m99+m55-2*m15+2*m19-2*m59+m11; b(17)=2*mc3+2*mc7; b(19)=-4*m35-4*m17-4*m13+4*m79-4*m57+4*m39; b(20)=2*mc4+2*mc2; b(22)=-4*m45+8*m67+8*m78+4*m29+8*m36-4*m25+4*m49-4*m14+8*m38-4*m12; b(24)=-4*m17+8*m26+8*m46-4*m13-4*m79+8*m48-4*m39+8*m28+4*m35+4*m57; b(25)=-4*m49+4*m25+4*m45-4*m14-4*m29-4*m12; b(26)=-mc5+mc1-mc9; b(28)=2*m55+8*m37+4*m77-2*m99+4*m19+4*m33-2*m11; b(30)=4*m16-4*m58+8*m27-4*m56+4*m18+8*m47+8*m23-4*m89+8*m34-4*m69; b(31)=8*m24+4*m15-2*m55+4*m44+2*m99+4*m22-2*m11; b(33)=-4*m35-4*m39+4*m17-4*m79-4*m57+4*m13; b(34)=-4*m49-4*m45+4*m12-4*m29-4*m25+4*m14; b(35)=m99-2*m15+m55-2*m19+2*m59+m11; b(37)=-2*mc4+2*mc2; b(39)=-4*m25+4*m45-4*m49+4*m29-4*m12+4*m14; b(40)=2*mc7-2*mc3; b(42)=8*m26-8*m48-8*m46-4*m17+4*m79-4*m57-4*m39+4*m35+4*m13+8*m28; b(44)=-8*m36-4*m29+8*m67+4*m49+4*m25-4*m12-4*m45+4*m14+8*m78-8*m38; b(45)=4*m13-4*m79+4*m57+4*m39-4*m17-4*m35; b(46)=-2*mc8+2*mc6; b(48)=4*m58-4*m89-8*m34-4*m56+4*m69-8*m47+8*m23-4*m16+4*m18+8*m27; b(50)=8*m77+8*m66+8*m22-8*m44-8*m88-8*m33; b(51)=4*m56+4*m89-4*m58-4*m69+8*m47+4*m18-8*m34-4*m16+8*m27-8*m23; b(53)=4*m49-4*m29-4*m25-8*m38+4*m45+8*m67-4*m14+4*m12+8*m36-8*m78; b(54)=4*m39+4*m17-4*m79+8*m46-8*m28-8*m48-4*m13+8*m26+4*m35-4*m57; b(55)=4*m89+4*m16+4*m58-4*m18-4*m56-4*m69; b(56)=mc9+mc1+mc5; b(58)=4*m22-4*m15-2*m11+4*m44-2*m55-8*m24+2*m99; b(60)=4*m58-8*m47+8*m27+4*m69+4*m16+8*m34+4*m89+4*m56+4*m18-8*m23; b(61)=2*m55-8*m37+4*m77-2*m99+4*m33-4*m19-2*m11; b(63)=-8*m46+4*m79+4*m35+4*m17+8*m26+8*m48+4*m13-8*m28+4*m39+4*m57; b(64)=-8*m78+8*m67+4*m14+4*m49-8*m36+4*m29+8*m38+4*m12+4*m25+4*m45; b(65)=4*m88-8*m68+4*m66-4*m59-2*m99-2*m55+2*m11; b(67)=4*m25-4*m14+4*m12+4*m29-4*m45-4*m49; b(68)=4*m79+4*m17-4*m35+4*m57-4*m39-4*m13; b(69)=-4*m58-4*m18+4*m69+4*m56+4*m16-4*m89; b(70)=m99+2*m19+m55+m11+2*m59+2*m15; c=sparse(zeros([266 1])); c(16)=-1;
github
urbste/MLPnP_matlab_toolbox-master
genrMr_gcm.m
.m
MLPnP_matlab_toolbox-master/gOp/genrMr_gcm.m
3,793
utf_8
b933dbb38c43ba2a895c609c2a97d72f
function [M,Mc,Mcc] = genrMr_gcm(X,v,c,R) % % % returns the parametrisation of the problem % as: r'*M*r + Mc*r + Mcc % if nargin == 2, c=[]; end if prod(size(c)) == 0, c = zeros(3,size(v,2)); end if sum(size(v) ~= size(c) | size(X) ~= size(v)), disp('Sizes must be equal!'); X v c return; end if nargin == 4, t=get_opt_t(R,X,v,c) end clear W clear V for pi_=1:size(v,2), V(pi_).V= (v(:,pi_)*v(:,pi_)')./(v(:,pi_)'*v(:,pi_)); W(pi_).W = (V(pi_).V-eye(3)).'*(V(pi_).V-eye(3)); end G_=zeros(3); for pi_=1:size(X,2), Wi = W(pi_).W ; G_=G_+ Wi+Wi'; end G_=inv(G_/size(X,2))/size(X,2); t_opt_ = zeros(3,9); t_opt_c = zeros(3,1); for pi_=1:size(X,2), Wi = W(pi_).W' + W(pi_).W ; %% t_opt = t_opt + (Wi)*(R*X(:,pi_)) + Wic(:,pi_); %W(pi_). WP = [Wi(:,1) * X(:,pi_).' Wi(:,2) * X(:,pi_).' Wi(:,3) * X(:,pi_).' ]; % t_opt_ = t_opt_ + W(pi_).WP ; % [Wi(:,1) * X(:,pi_).' Wi(:,2) * X(:,pi_).' Wi(:,3) * X(:,pi_).' ]; t_opt_ = t_opt_ + WP ; t_opt_c = t_opt_c + Wi * c(:,pi_); end t_opt_ = -G_*t_opt_; t_opt_c = -G_*t_opt_c; if nargin == 4, %% check if t_opt is equal to t_opt r = R'; r=r(:); t_opt_*r + t_opt_c %% seems to be correct ! end %% assume we have a t_opt = T*[r1..r9] + t , T=3x9 Matrix t=3x1 %% %e= (R*P)'*Wi*(R*P) + (R*P)'*Wi*(t_opt) + (t_opt)'*Wi*(R*P) + (t_opt)'*Wi*(t_opt) %e= (R*P+T*rc+t+ci)'*Wi*(R*P+T*rc+t+ci) %e= (R*P)'*Wi*(R*P) + (R*P)'*Wi*(T*rc+t+ci) + (T*rc+t+ci)'*Wi*(R*P) + (T*rc+t+ci)'*Wi*(T*rc+t+ci) %e= (R*P)'*Wi*(R*P) + (R*P)'*Wi*(T*rc) + (R*P)'*Wi*(t+ci) + rc'*T'*Wi*(R*P) + (t+ci)'*Wi*(R*P) + (T*rc)'*Wi*(T*rc) + ((t+ci))'*Wi*(T*rc) + (T*rc)'*Wi*((t+ci)) + ((t+ci))'*Wi*((t+ci)) %e1= (R*P)'*Wi*(R*P) + (R*P)'*Wi*(T*rc) + rc'*T'*Wi*(R*P) + (T*rc)'*Wi*(T*rc) %e1= (v2V(P)*rc)'*Wi*(v2V(P)*rc) + (v2V(P)*rc)'*Wi*(T*rc) + rc'*T'*Wi*(v2V(P)*rc) + rc'*T'*Wi*T*rc %e2= (R*P)'*Wi*t + t'*Wi*(R*P) + t'*Wi*T*rc + (T*rc)'*Wi*(t) %e2= (v2V(P)*rc)'*Wi*(t+ci) + (t+ci)'*Wi*(v2V(P)*rc) + (t+ci)'*Wi*T*rc + (T*rc)'*Wi*(t+ci) %e3= (t+ci)'*Wi*(t+ci) %e= (v2V(P)*rc)'*W*(v2V(P)*rc) + (v2V(P)*rc)'*W*(T*rc) + rc'*T'*W*(v2V(P)*rc) + rc'*T'*W*T*rc %e= rc*v2V(P)'*W*v2V(P)*rc + rc'*v2V(P)'*W*T*rc + rc'*T'*W*v2V(P)*rc + rc'*T'*W*T*rc %e= rc* ( v2V(P)'*W*v2V(P) + v2V(P)'*W*T + T'*W*v2V(P) + T'*W*T ) *rc M=zeros(9,9); Mc=zeros(9,1); Mcc=0; T = t_opt_; t = t_opt_c; for pi_=1:size(v,2), Wi = W(pi_).W ; P = X(:,pi_); ci = c(:,pi_); v2Vp = v2V(P); PWi = v2Vp.'*Wi; tci = t+ci; v2VpT = v2Vp + T; Witci = Wi*tci; M =M+ PWi*v2VpT + T.'*(PWi.' + Wi*T) ; % e1 Mc =Mc+ v2VpT.'*Witci; %e2 Mcc=Mcc+ tci.'*Witci; % e3 end Mc = 2*Mc; if nargin == 4, r = R'; r=r(:); % M % Mc % Mcc e = r'*M*r + r'*Mc + Mcc; disp(['Error using known R:' num2str(e) ]); %% check the error with the known R end return; %% is MC always zero ?? if 0, %% check if the functions are correct if nargin ~= 4, R= rpyMat(rand(3,1)*2*pi); end %% get the opt t t=get_opt_t(R,X,v,c) e=0; for pi_=1:size(v,2), V= (v(:,pi_)*v(:,pi_)')./(v(:,pi_)'*v(:,pi_)); ei= (V-eye(3))*(R*X(:,pi_)+t+c(:,pi_)); e = e + ei.'*ei; end r = R';r=r(:); r.'*M*r + r.'*Mc + Mcc end function t=get_opt_t(R,X,v,c) %% ei = (I-V)*(R*X+t+c) %% opt_t = G=zeros(3,3); for pi_=1:size(v,2), V= (v(:,pi_)*v(:,pi_)')./(v(:,pi_)'*v(:,pi_)); G=G+ V; end G=inv(eye(3)-G/size(v,2))/size(v,2); t_opt = zeros(3,1) ; for pi_=1:size(v,2), V= (v(:,pi_)*v(:,pi_)')./(v(:,pi_)'*v(:,pi_)); t_opt = t_opt + (V-eye(3))*(R*X(:,pi_)+c(:,pi_)); end t = G*t_opt;
github
urbste/MLPnP_matlab_toolbox-master
rotate.m
.m
MLPnP_matlab_toolbox-master/gOp/util/rotate.m
269
utf_8
a646a7d125703ff9d5d26e5aa6fb449a
function R=rotate(a,b,c) % %function R=rotate(a,b,z) % %returns rotationsmatrix % Rb = [ cos(b) 0 -sin(b); 0 1 0 ; sin(b) 0 cos(b) ]; Rc = [ cos(c) -sin(c) 0 ; sin(c) cos(c) 0; 0 0 1 ]; Ra = [ 1 0 0; 0 cos(a) -sin(a);0 sin(a) cos(a)]; R = Ra*Rb*Rc;
github
urbste/MLPnP_matlab_toolbox-master
rpyMat.m
.m
MLPnP_matlab_toolbox-master/gOp/util/rpyMat.m
1,447
utf_8
70bd943cf357e2649aabcf288cb906e7
% Author: Rodrigo Carceroni % Disclaimer: This code comes with no guarantee at all and its author % is not liable for any damage that its utilization may cause. function [R,dR] = rpyMat (angs) % Return the 3x3 rotation matrix described by a set of Roll, Pitch and Yaw % angles. cosA = cos (angs(3)); sinA = sin (angs(3)); cosB = cos (angs(2)); sinB = sin (angs(2)); cosC = cos (angs(1)); sinC = sin (angs(1)); cosAsinB = cosA * sinB; sinAsinB = sinA * sinB; R = [ cosA*cosB cosAsinB*sinC-sinA*cosC cosAsinB*cosC+sinA*sinC ; sinA*cosB sinAsinB*sinC+cosA*cosC sinAsinB*cosC-cosA*sinC ; -sinB cosB*sinC cosB*cosC ]; if nargout > 1, %% also give the derivative function of R dR_C = [ 0 cosAsinB*cosC+sinA*sinC -cosAsinB*sinC+sinA*cosC ; 0 sinAsinB*cosC-cosA*sinC -sinAsinB*sinC-cosA*cosC ; 0 cosB*cosC -cosB*sinC ]; cosAsinB = cosA * cosB; sinAsinB = sinA * cosB; dR_B = [ -cosA*sinB cosAsinB*sinC cosAsinB*cosC ; -sinA*sinB sinAsinB*sinC sinAsinB*cosC ; -cosB -sinB*sinC -sinB*cosC ]; cosAsinB = -sinA * sinB; sinAsinB = cosA * sinB; dR_A = [ -sinA*cosB cosAsinB*sinC-cosA*cosC cosAsinB*cosC+cosA*sinC ; cosA*cosB sinAsinB*sinC-sinA*cosC sinAsinB*cosC+sinA*sinC ; 0 0 0 ]; dR = [dR_C;dR_B;dR_A]; end
github
urbste/MLPnP_matlab_toolbox-master
plot_stat.m
.m
MLPnP_matlab_toolbox-master/gOp/util/plot_stat.m
2,513
utf_8
bb032648b0de31f298c556a5f95098ed
function plot_stat(y,data,opt) % % % plots statistical stuff ! % % opt.mean : draws the mean % opt.std : draws mean+std , mean-std % opt.median : draws the median % opt.quart : draws 1/4 and 3/4 quartile % opt.minmax : draws min & max % % opt.mean_,opt.median_,opt.number_ : % : conect the types with a line ! % % all of them have fields .c : color style % .s : size % % opt.log : draws logaritmic scales hold on; %erg=[]; if iscell(y), %% we have a cell array DR = y; y=[]; for i=1:length(DR), d = DR{i}; k = plot_mean_and_std1(d(2:end),d(1),opt); if length(k) > 0, erg(i,:) = k; end y(i) = d(1); end else for i=1:size(data,1), k = plot_mean_and_std1(data(i,:),y(i),opt); if length(k) > 0, erg(i,:) = k; end end end if exist('erg'), for i=1:size(erg,2), d = cat(1,erg(:,i).d); plot(y,d,erg(1,i).s.c,'LineWidth',2); end end % plot(y,mean(E,2),c); function [erg] = plot_mean_and_std1(data,y,opt) erg=[]; m=mean(data); s=std(data); md=median(data); mm = [max(data) min(data)]; if isfield(opt,'mean'), [c,dx1,dx2] = get_look(y,opt,opt.mean); plot([dx1 dx2],[m m],c,'LineWidth',2); end if isfield(opt,'std'), [c,dx1,dx2] = get_look(y,opt,opt.std); plot([y y],[m m+s],c,'LineWidth',2); plot([y y],[m m-s],c,'LineWidth',2); plot([dx1 dx2],[m+s m+s],c,'LineWidth',2); plot([dx1 dx2],[m-s m-s],c,'LineWidth',2); end if isfield(opt,'median'), [c,dx1,dx2] = get_look(y,opt,opt.median); plot([dx1 dx2],[md md],c,'LineWidth',2); end if isfield(opt,'quart'), d=sort(data); mi = ceil(length(d)/2); s = length(d); qu = d(round(s*0.25)); qo = d(round(s*0.75)); [c,dx1,dx2] = get_look(y,opt,opt.quart); plot([dx1 dx2 dx2 dx1 dx1],[qu qu qo qo qu],c,'LineWidth',2); end if isfield(opt,'minmax'), qu = min(data); qo = max(data); [c,dx1,dx2] = get_look(y,opt,opt.minmax); plot([dx1 dx2 dx2 dx1 dx1],[qu qu qo qo qu],c,'LineWidth',2); end if isfield(opt,'mean_'), erg(end+1).d = m; erg(end).s = opt.mean_; end if isfield(opt,'median_'), erg(end+1).d = md; erg(end).s = opt.median_; end if isfield(opt,'number_'), erg(end+1).d = length(data); erg(end).s = opt.number_; end function [c,dx1,dx2] = get_look(y,opt,opti) % % % c = opti.c; if isfield(opt,'log'), dx1 = y*opti.s; dx2 = y/opti.s; else dx1 = y-opti.s; dx2 = y+opti.s; end
github
urbste/MLPnP_matlab_toolbox-master
getRotation.m
.m
MLPnP_matlab_toolbox-master/gOp/util/getRotation.m
1,525
utf_8
fcc521bd9aacdedcc9bbbc71ee96a72e
function R=getRotation(u,v) %function R=getRotation(u,v) % % Returns the rotation Matrix M % % so that u = M*v; % %Author: Gerald Schweighofer u = u/norm(u); v = v/norm(v); [ Rv,p_v,th_v ] = getR(v); [ Ru,p_u,th_u ] = getR(u); R = inv(Ru)*Rv; if sum(abs(R*v' - u')) > 1e-6, disp('Error in getRotation '); end %------------------------- function [R,phi,theta]=getR(v) % funktionsweise aus BARTSCH Seite :219 if sqrt(v(1)^2+v(2)^2) > 1e-8, phi = acos(v(1)/sqrt(v(1)^2+v(2)^2)); R1a = rotate(0,0,-phi); R1b = rotate(0,0,+phi); v1a = R1a*v'; v1b = R1b*v'; if abs(v1a(2)) < abs(v1b(2)), R1 = R1a; phi = -phi; else R1 = R1b; end else R1 = diag([ 1 1 1 ]); end v2 = R1*v'; r = sqrt(sum(v.^2)); theta = acos(v2(3)/r); R2a=rotate(0,-theta,0); R2b=rotate(0,+theta,0); v3a = R2a*v2; v3b = R2b*v2; if v3a(3) > v3b(3), R2 = R2a; theta = -theta; else R2 = R2b; end R = R2*R1; function [R,phi,theta]=getRyx(v) % funktionsweise aus BARTSCH Seite :219 if sqrt(v(2)^2+v(3)^2) > 1e-8, phi = acos(v(3)/sqrt(v(2)^2+v(3)^2)); R1a = rotate(-phi,0,0); R1b = rotate(+phi,0,0); v1a = R1a*v'; v1b = R1b*v'; if abs(v1a(2)) < abs(v1b(2)), R1 = R1a; phi = -phi; else R1 = R1b; end else R1 = diag([ 1 1 1 ]); end v2 = R1*v'; r = sqrt(sum(v.^2)); theta = atan(v2(3)/v2(1)); R2a=rotate(0,-theta,0); R2b=rotate(0,+theta,0); v3a = R2a*v2; v3b = R2b*v2; if v3a(1) > v3b(1), R2 = R2a; theta = -theta; else R2 = R2b; end R = R2*R1;
github
urbste/MLPnP_matlab_toolbox-master
fitplane.m
.m
MLPnP_matlab_toolbox-master/gOp/util/fitplane.m
1,259
utf_8
505fe35ceea6b30a97d8ca6fda5797d7
% FITPLANE - solves coefficients of plane fitted to 3 or more points % % Usage: B = fitplane(XYZ) % % Where: XYZ - 3xNpts array of xyz coordinates to fit plane to. % If Npts is greater than 3 a least squares solution % is generated. % % Returns: B - 4x1 array of plane coefficients in the form % b(1)*X + b(2)*Y +b(3)*Z + b(4) = 0 % The magnitude of B is 1. % % See also: RANSACFITPLANE % Peter Kovesi % School of Computer Science & Software Engineering % The University of Western Australia % pk at csse uwa edu au % http://www.csse.uwa.edu.au/~pk % % June 2003 function B = fitplane(XYZ) [rows,npts] = size(XYZ); if rows ~=3 error('data is not 3D'); end if npts < 3 error('too few points to fit plane'); end % Set up constraint equations of the form AB = 0, % where B is a column vector of the plane coefficients % in the form b(1)*X + b(2)*Y +b(3)*Z + b(4) = 0. A = [XYZ' ones(npts,1)]; % Build constraint matrix if npts == 3 % Pad A with zeros A = [A; zeros(1,4)]; end [u d v] = svd(A); % Singular value decomposition. B = v(:,4); % Solution is last column of v.
github
urbste/MLPnP_matlab_toolbox-master
addError.m
.m
MLPnP_matlab_toolbox-master/gOp/util/addError.m
443
utf_8
0a0c27e672aa1e82706f2b59a85c5095
function Inew=addError(Iorig,error) % % error -> sigma von Guass-Verteilung % Pixel Error % E=normrnd(0,error,length(Iorig(:,1)),1); %K=[]; for i=1:length(Iorig(:,1)), point = Iorig(i,1:2); winkel = rand*180; wrad = winkel*pi/180; dx = sin(wrad)*E(i); dy = cos(wrad)*E(i); % K = [K ; [dx dy]]; de(i,:)=[dx dy]; Inew(i,:) = [ Iorig(i,1)+dx Iorig(i,2)+dy Iorig(i,3:size(Iorig,2)) ]; end %plot(K(:,1),K(:,2),'x');
github
urbste/MLPnP_matlab_toolbox-master
rotlorentz.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/rotlorentz.m
1,689
utf_8
a62c3fb740f53474f5ddec5c0b427e4a
% c = rotlorentz(c,K) % Rotates vectors from Qcone to Rcone or from Rcone into Qcone. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function c = rotlorentz(c,K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % firstk = K.l + sum(K.q) + 1; M = [1 1; 1 -1]; for k = 1:length(K.r) c(firstk:firstk+1,:) = M*c(firstk:firstk+1,:)/ sqrt(2); firstk = firstk + K.r(k); end
github
urbste/MLPnP_matlab_toolbox-master
PopK.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/PopK.m
2,004
utf_8
d538cca0b063c319f06b081fb630b693
% [y, ddotx, Dx, xTy] = PopK(d,x,K,lpq) % POPK Implements the quadratic operator for symmetric cones K. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function [y, ddotx, Dx, xTy] = PopK(d,x,K,lpq) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % if nargin < 4 lpq = 0; end % LP / Lorentz i1 = K.mainblks(1); i2 = K.mainblks(2); y = [d.l .* x(1:i1-1); -d.det .* x(i1:i2-1); qblkmul(d.det,x,K.qblkstart)]; ddotx = (d.q1).*x(i1:i2-1) + ddot(d.q2,x,K.qblkstart); % PSD: Dx = psdscale(d,x,K); if lpq == 0 y = [y; psdscale(d,Dx,K,1)]; % Include PSD-part end % xTy: if nargout >= 4 xTy = x(1:K.lq)'*y(1:K.lq) + sum(ddotx.^2) + sum(Dx.^2); end
github
urbste/MLPnP_matlab_toolbox-master
updtransfo.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/updtransfo.m
4,623
utf_8
84c1ed1fe1ae2fc009c6c9eacdff15b3
% [d,vfrm] = updtransfo(x,z,w, dIN,K) % UPDTRANSFO Updated the Nesterov-Todd transformation using a % numerically stable method. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function [d,vfrm] = updtransfo(x,z,w, dIN,K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % % ------------------------------------------------------------ % PSD: % Given w = D(Xscl)Zscl, compute spec-factor Q*WLAB*Q' = W % ------------------------------------------------------------ if ~isempty(K.s) [wlab,q] = psdeig(w.s,K); w.lab(K.l+2*length(K.q) + 1:end) = wlab; else q=[]; end % ------------------------------------------------------------ % lambda(v) = sqrt(lambda(w)) % ------------------------------------------------------------ vfrm.lab = sqrt(w.lab); % ------------------------------------------------------------ % LP : d.l = dIN.l .* (x ./ z) % ------------------------------------------------------------ d.l = dIN.l .* (x(1:K.l) ./ z(1:K.l)); % ------------------------------------------------------------ % Lorentz: % Auxiliary: s := sqrt(det(x)./det(z)) % chi = (x[k] + s(k)*Jz[k]) / (lab1(v)+lab2(v)) % psi = (x[k] - s(k)*Jz[k]) / (lab2(v)-lab1(v)) % Scale: detd = detdIN .* s and d = D(dIN)*chi % ------------------------------------------------------------ if isempty(K.q) d.det = zeros(0,1); d.q1 = zeros(0,1); d.q2 = zeros(0,1); d.auxdet = zeros(0,1); d.auxtr = zeros(0,1); vfrm.q = zeros(0,1); else i1 = K.mainblks(1); i2 = K.mainblks(2); nq = i2 - i1; j3 = i2+nq-1; s = sqrt(w.tdetx ./ w.tdetz); d.det = dIN.det .* s; psi1 = s.*z(i1:i2-1); psi2 = qblkmul(s,z,K.qblkstart); %s * z tmp = vfrm.lab(i1:i2-1) + vfrm.lab(i2:j3); chi1 = (x(i1:i2-1)+psi1)./tmp; chi2 = qblkmul(1./tmp, x(i2:K.lq)-psi2,K.qblkstart); psi1 = x(i1:i2-1)-psi1; psi2 = x(i2:K.lq)+psi2; dq = asmDxq(dIN,[chi1;chi2],K); % d = D(dIN)*chi d.q1 = dq(1:nq); d.q2 = dq(nq+1:end); d.auxdet = sqrt(2*d.det); d.auxtr = sqrt(2)*(d.q1 + d.auxdet); alpha = (dIN.q1 .* psi1 + ddot(dIN.q2,psi2,K.qblkstart)) ./ d.auxtr; tmp = 2*sqrt(s); psi1 = (psi1 - alpha .* chi1)./tmp; psi2 = psi2 - qblkmul(alpha,chi2,K.qblkstart); psi2 = qblkmul(1./tmp, psi2,K.qblkstart); gamma = (sqrt(2)*psi1+alpha) ./ dIN.auxtr; tmp = vfrm.lab(i2:j3) - vfrm.lab(i1:i2-1); tmp(tmp == 0) = 1; %avoid division by zero psi2 = psi2 + qblkmul(gamma,dIN.q2,K.qblkstart); vfrm.q = qblkmul(1./tmp, psi2, K.qblkstart); end % ------------------------------------------------------------ % D= QUD'*QUD, where QUD(:,udIN.perm) = diag(1./sqrt(vlab))*Q'*ux*ud. % Let vinv = diag(1./sqrt(vlab))*Q'. % ------------------------------------------------------------' d.u = triumtriu(w.ux, dIN.u, K); % ux * ud [d.u,d.perm,gjc,g] = urotorder(d.u,K, 1.1, dIN.perm); % stable reordering q = givensrot(gjc,g,q,K); % ROTATE Q accordingly: (G*Q)'*(G*ux*ud).' vinv = sqrtinv(q,vfrm.lab,K); % ------------------------------------------------------------ % QR-FACTORIZE: Qv * VINV = R % Then the new ud is simply R*ux*ud, which is upper triangular. % ------------------------------------------------------------ [vfrm.s, r] = qrK(vinv,K); d.u = triumtriu(r, d.u, K);
github
urbste/MLPnP_matlab_toolbox-master
symbcholden.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/symbcholden.m
2,500
utf_8
cc5a9a455c0e83c00738b400bc5da871
% Lden = symbcholden(L,dense,DAt) % SYMBCHOLDEN Creates Lden.{LAD, perm,dz, sign, first} % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi, dpr1fact function Lden = symbcholden(L,dense,DAt) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % % ------------------------------------------------------------ % Symbolic forward Cholesky of dense columns, in order % [LP, Q-blk, Q-norm, Q-tr] % ------------------------------------------------------------ i1 = dense.l + 1; i2 = i1 + length(dense.q); LAD = [symbfwblk(L,dense.A(:,1:i1-1)), symbfwblk(L,DAt.denq),... symbfwblk(L,dense.A(:,i2:end)),symbfwblk(L,dense.A(:,i1:i2-1))]; % ------------------------------------------------------------ % Incremental ordering heuristic, excluding the Lorentz-trace cols % ------------------------------------------------------------ [perm, dz] = incorder(LAD(:,1:length(dense.cols))); % ------------------------------------------------------------ % Insert the trace cols with a "-1"-factor just after corresponding % Lorentz-block columns % ------------------------------------------------------------ Lden = finsymbden(LAD,perm,dz,i1);
github
urbste/MLPnP_matlab_toolbox-master
psdinvscale.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/psdinvscale.m
2,358
utf_8
f5c2690e44cb5af9d89862992d41f6fe
% y = psdinvscale(ud,x,K ,transp) % PSDINVSCALE Computes length lenud (=sum(K.s.^2)) vector y. % Computes y = D(d^{-1}) x with d in K. % Y = Ud' \ X / Ud % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also scaleK, factorK. function y = psdinvscale(ud,x,K) % This file is part of SeDuMi 1.3 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA Ks=K.s; if ~isempty(Ks) N=sum(Ks.^2); y(N,1)=0; startindices=K.sblkstart-K.mainblks(end)+1; %Sometimes x containts only the PSD part, sometimes the whole thing xstartindices=startindices+(length(x)-N); for i=1:K.rsdpN Ksi=Ks(i); Ksi2=Ksi^2; temp=triu(reshape(ud(startindices(i):startindices(i+1)-1),Ksi,Ksi)); if nnz(temp)<0.05*Ksi2; temp=sparse(temp); end X=reshape(x(xstartindices(i):xstartindices(i+1)-1),Ksi,Ksi); if nnz(X)<0.05*Ksi2; X=sparse(X); end y(startindices(i):startindices(i+1)-1)=... temp'... \(X... /temp); end else y=[]; end
github
urbste/MLPnP_matlab_toolbox-master
eyeK.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/eyeK.m
1,792
utf_8
dcbd5215709d972b04aaf25ed58bd8b0
% eyeK Identity w.r.t. symmetric cone. % x = eyeK(K) produces the identity solution w.r.t. the symmetric cone, % that is described by the structure K. This is the vector for which % eigK(x) is the all-1 vector. % % See also eigK. function x = eyeK(K) % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
sparfwslv.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/sparfwslv.m
2,219
utf_8
06e89169ef2854a6853160556843a207
% SPARFWSLV Solves block sparse upper-triangular system. % y = sparfwslv(L,b) yields the same result as % y = L.L\b(L.perm,:) % However, SPARFWSLV is faster than the built-in operator "\", % because it uses dense linear algebra and loop-unrolling on % supernodes. % % For sparse b, one should use % y = sparfwslv(L,b,symbfwblk(L.L,L.xsuper, b)); % % Typical use, with X sparse m x m positive definite and b is m x n: % L = sparchol(symbchol(X),X); % L.d(L.dep) = inf; % y = sparbwslv(L,sparfwslv(L,b) ./ L.d); % Then y solves X*y=b. % % See also symbchol, sparchol, sparbwslv, mrdivide, mldivide. function y = sparfwslv(L,b, ysymb) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % % ---------------------------------------- % Solve L.L * y = b % ---------------------------------------- if nargin > 2 y = fwblkslv(L,b,ysymb); else y = fwblkslv(L,b); end
github
urbste/MLPnP_matlab_toolbox-master
fwdpr1.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/fwdpr1.m
1,836
utf_8
3d80b72e6bb438da84de6717e27bf024
% y = fwdpr1(Lden, b) % FWDPR1 Solves "PROD_k L(pk,betak) * y = b", where % where L(p,beta) = eye(n) + tril(p*beta',-1). % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi, dpr1fact, bwdpr1 function y = fwdpr1(Lden, b) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
sortnnz.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/sortnnz.m
1,958
utf_8
5480524af510b77a03081bd71bf14627
% perm = sortnnz(At,Ajc1,Ajc2) % SORTNNZ Sorts columns in At % in increasing order of nnzs; only the nnzs between Ajc1 and Ajc2 % are considered for each column. If Ajc1 or Ajc2 is empty, we use % the start or end of the columns in At. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also partitA. function perm = sortnnz(At,Ajc1,Ajc2) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
loopPcg.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/loopPcg.m
6,098
utf_8
9ace09d37bb5be74ffa5c03914a6ff6d
% [y,k, DAy] = loopPcg(L,Lden,At,dense,d, DAt,K, b,p,ssqrNew,cgpars, restol) % % LOOPPCG Solve y from AP(d)A' * y = b % using PCG-method and Cholesky L as conditioner. % If L is sufficiently accurate, then only 1 CG-step is needed. % It assumes that the previous step was p, with % ssqrNew = bOld'*inv(L*THETA*L')*bOld, and bOld the residual before % the step p was taken. If p = [], then the PCG is started from scratch. % % k = #(CG-iterations). % DAy = D*A'*y with D'*D = P(d). % % Warning: if the scaling operation P(d) gets ill-conditioned, the % precision in y may be insufficient to compute DAy satisfactory. % In this case, one should allow refinement, see wrapPcg. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi, wrapPcg function [y,k, DAy] = loopPcg(L,Lden,At,dense,d, DAt,K, b,p,ssqrNew,... cgpars, restol) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % % -------------------------------------------------- % INITIALIZE: % y=0 with r = b. % -------------------------------------------------- k = 0; STOP = 0; r = b; finew = 0; y = []; % means all-0 normrmin = norm(r,inf); ymin = []; % -------------------------------------------------- % Conjugate Gradient until convergence % -------------------------------------------------- while STOP == 0 % -------------------------------------------------- % P r e - C o n d i t i o n i n g: % Solve L*Lr = r, L*THETA*tmp = r. % p=[] ==> initialize p to solve L*THETA*L'*p = r. % -------------------------------------------------- Lr = fwdpr1(Lden,sparfwslv(L, r)); tmp = Lr ./ L.d; if isempty(p) ssqrNew = Lr'*tmp; p = sparbwslv(L, bwdpr1(Lden,tmp)); else % -------------------------------------------------- % General iterate: make p conjugate to previous iterate(s): % -------------------------------------------------- ssqrOld = ssqrNew; ssqrNew = Lr'*tmp; p = (ssqrNew/ssqrOld) * p; p = p + sparbwslv(L, bwdpr1(Lden,tmp)); end % -------------------------------------------------- % SCALING OPERATION AND MATRIX*VECTOR. % Let DDAp = P(d)*A'*p and ssqrDAp = ||P(d)^{1/2}*A'*p||^2. % Set alpha = ssqrNew / ssqrDAp % -------------------------------------------------- Ap = vecsym(Amul(At,dense,p,1), K); [DDAp, DApq, DAps, ssqrDAp] = PopK(d,Ap,K); if ssqrDAp > 0.0 k = k + 1; % -------------------------------------------------- % Take step: y := y + alpha*p %-------------------------------------------------- alpha = ssqrNew / ssqrDAp; if ~isempty(y) if isstruct(y) [y.hi,y.lo] = quadadd(y.hi,y.lo,alpha*p); else y = y + alpha * p; end elseif cgpars.qprec > 0 y.hi = alpha * p; y.lo = zeros(length(p),1); else y = alpha * p; end % -------------------------------------------------- % Update residual r := r - alpha * A*[P(d)*Ap]. MATRIX*VECTOR. % -------------------------------------------------- tmp = Amul(At,dense,DDAp)+ DAt.q'*DApq(:,1) +... DAt.denq*DApq(dense.q,1); r = r - alpha * tmp; % -------------------------------------------------- % Convergence check (HEURISTIC) % -------------------------------------------------- fiprev = finew; if isstruct(y) finew = (b+r)'*y.hi + (b+r)'*y.lo; else finew = (b+r)'*y; end normr = norm(r,inf); if normr < normrmin ymin = y; normrmin = normr; end if normr < restol STOP = 1; elseif (finew-fiprev < cgpars.stagtol * fiprev) STOP = 2; elseif k >= cgpars.maxiter STOP = 2; end else % my_fprintf('Warning: DAp = 0 in PCG\n'); STOP = 1; % If DAp == 0 then can't go on. end end % -------------------------------------------------- % OUTPUT: return projection D * At*y on request. % -------------------------------------------------- if STOP == 2 y = ymin; % Take best so far end if isempty(y) DAy = []; return end if nargout >= 3 if k == 1 DAy = alpha*[sqrt(d.l).*Ap(1:K.l); asmDxq(d,Ap,K,DApq); DAps]; else if isstruct(y) Ap = vecsym(Amul(At,dense,y.hi,1), K); else Ap = vecsym(Amul(At,dense,y,1), K); end DAy = [sqrt(d.l).*Ap(1:K.l); asmDxq(d,Ap,K); psdscale(d,Ap,K)]; if isstruct(y) Ap = vecsym(Amul(At,dense,y.lo,1), K); DAy = DAy + [sqrt(d.l).*Ap(1:K.l); asmDxq(d,Ap,K); psdscale(d,Ap,K)]; end end end if isstruct(y) y = y.hi; end
github
urbste/MLPnP_matlab_toolbox-master
finsymbden.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/finsymbden.m
2,087
utf_8
657a8e2087629e311adebd57a5f08b71
% Lden = finsymbden(LAD,perm,dz,firstq) % FINSYMBDEN Updates perm and dz by inserting the % last Lorentz trace columns (last columns of LAD). It creates the fields % Lden.sign - +1 for "normal" columns, -1 for Lorentz trace columns % Lden.first - First pivot column that will affect this one % NOTE: sign and first correspond to columns in LAD (without perm-reordering). % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also incorder function Lden = finsymbden(LAD,perm,dz,firstq) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
minpsdeig.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/minpsdeig.m
2,336
utf_8
29f75bd3729b72e27c480ad96a8dfecb
% mineig = minpsdeig(x,K) % MINPSDEIG Computes the smallest spectral coefficients of x w.r.t. K % Uses an iterative method if the matrix is large, takes the minimum of all % the eigenvalues if the matrix is small. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function mineig = minpsdeig(x,K) % % This file is part of SeDuMi 1.3 by Imre Polik % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % % disp('The SeDuMi binaries are not installed.') % disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') % disp('For more information see the file Install.txt.') % error(' ') % [labold,qold]=psdeig(x,K); Ks=K.s; if isempty(Ks) mineig=[]; return end startindices=K.sblkstart-K.mainblks(end)+1; ncones=length(Ks); OPTS.disp=0; mineigvector=zeros(ncones,1); for k = 1:ncones Xk = reshape(x(startindices(k):startindices(k+1)-1),Ks(k),Ks(k)); if Ks(k)>500 mineigvector(k) = eigs(Xk + Xk',1,'SA',OPTS); else mineigvector(k) = min(eig(Xk + Xk')); end end mineig = min(mineigvector) / 2;
github
urbste/MLPnP_matlab_toolbox-master
getDAtm.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/getDAtm.m
1,959
utf_8
f378e638faeb4f3d673dca3c0cc6faa4
% DAt = getDAtm(A,Ablkjc,dense,DAtdenq,d,K) % GETDATM Computes d[k]'*Aj[k] for each lorentz block k and constraint j. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi, getada2. function DAt = getDAtm(A,Ablkjc,dense,DAtdenq,d,K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % nq = length(K.q); DAt.q = extractA(A,Ablkjc,1,2,K.mainblks(1),K.mainblks(2)); if nq > 0 DAt.q = spdiags(d.q1,0,nq,nq) * DAt.q; DAt.q = DAt.q + ddot(d.q2, A, K.qblkstart, Ablkjc); end DAt.denq = adendotd(dense,d,DAt.q(dense.q,:)',DAtdenq,K.qblkstart); if ~isempty(dense.q) DAt.q(dense.q,:) = 0.0; end
github
urbste/MLPnP_matlab_toolbox-master
findblks.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/findblks.m
1,995
utf_8
28b6d82caaac8cc4f537aba20c2cdcb0
% Ablk = findblks(At,Ablkjc,blk0,blk1,blkstart) % FINDBLKS Find nonzero blocks % in A, with subscripts per column bounded bij Ablkjc([blk0,blk1]), % block partitioned by blkstart. % If blk0 < 1 (blk1 > size(Ablkjc,2)) then start (stop) searching at column % start (end) of A. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also partitA. function Ablk = findblks(At,Ablkjc,blk0,blk1,blkstart) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
invcholfac.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/invcholfac.m
1,817
utf_8
d632d6aaf456d5f49b5d98c2d3f643e7
% y = invcholfac(u,K, perm) % INVCHOLFAC Computes y(perm,perm) = u' * u, with u upper triangular. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi, getada3 function y = invcholfac(u,K, perm) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
qframeit.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/qframeit.m
1,731
utf_8
5fa5e8c33ccbf6235d2065a5da6e9cb1
% x = qframeit(lab,frmq,K) % % *********************** INTERNAL FUNCTION OF SEDUMI ******************* % % See also sedumi % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA function x = qframeit(lab,frmq,K) lorN = length(K.q); if length(lab) > 2*lorN lab = lab(K.l+1:K.l+2*lorN); % Take out Lorentz spectral values end x = [(lab(1:lorN) + lab(lorN+1:end))/sqrt(2);... qblkmul(lab(lorN+1:end) - lab(1:lorN),frmq,K.qblkstart)];
github
urbste/MLPnP_matlab_toolbox-master
incorder.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/incorder.m
2,143
utf_8
2b2774a13bee87f13835654c0d328cf3
% [perm, dz] = incorder(At [,Ajc1,ifirst]) % INCORDER % perm sorts the columns of At greedily, by iteratively picking % the 1st unprocessed column with the least number of nonzero % subscripts THAT ARE NOT YET COVERED (hence incremental) by % the previously processed columns. % dz has the corresponding incremental sparsity structure, i.e. % each column lists only the ADDITIONAL subscripts w.r.t. the % previous ones. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also getada3, dpr1fact function [perm, dz] = incorder(At,Ajc1,ifirst) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
qreshape.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/qreshape.m
1,959
utf_8
c2c6b1ac9973c681f73cab640d9822aa
% y = qreshape(x,flag, K) % QRESHAPE Reshuffles entries associated with Lorentz blocks. % If flag = 0 then y = [x1 for each block; x2 for each block] % If flag = 1 then y = [x block 1; x block 2; etc], etc % Thus, x = qreshape(qreshape(x,0,K),1,K). % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi function y = qreshape(x,flag, K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
dpr1fact.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/dpr1fact.m
2,082
utf_8
629891569a29d67b959f97061acd5cea
% [Lden,L.d] = dpr1fact(x, d, Lsym, smult, maxu) % DPR1FACT Factor d[iag] p[lus] r[ank] 1: % [Lden,L.d] = dpr1fact(x, d, Lsym, smult, maxu) % Computes fi and d such that % diag(d_IN) + x*diag(smult)*x' = %(PI_{i=1}^n L(p_OUT^i,beta_i)) * diag(d_OUT) * (PI_{i=1}^n L(p_OUT^i,beta_i))' % where L(p,beta) = eye(n) + tril(p*beta',-1). % % Lden.dopiv(k) = 1 if p(:,k) has been reordered, with permutation in % Lden.pivperm. % We reorder if otherwise |p(i,k)*beta(j,k)| > maxu. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also fwdpr1,bwdpr1,sedumi function [Lden,Ld] = dpr1fact(x, d, Lsym, smult, maxu) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % error('At OS prompt, type "make" to create cholTool mex-files.')
github
urbste/MLPnP_matlab_toolbox-master
iswnbr.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/iswnbr.m
4,332
utf_8
29ebd64b43e94bc8f880edf8af6dcb90
% [delta,h,alpha] = iswnbr(vSQR,thetaSQR) % ISWNBR Checks feasibility w.r.t. wide region/neighborhood of Sturm-Zhang. % vTAR:= (1-alpha)*max(h,v) projection v onto theta-central region % delta = (sqrt(n)/theta) * norm(vTAR - v) / norm(v) % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function [delta,h,alpha] = iswnbr(w,thetaSQR) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ') % ---------------------------------------- % r = n/thetaSQR % hSQR = sumwNT/(r-|T|), hubSQR = sumwNT/(r-|T| - |Q|) % sumdifv = h*|T| - sumvT (sumvT = sum(v_T), growing ) % sumdifw = hSQR*|T| - sumwT % alpha = sumdifv / (r*h) % deltaSQR = r * ( 2*alpha-alpha^2 - (1-alpha)^2 * sumdifw/gap ) % WE UPDATE sumdifv AND sumdifw IN A STABLE WAY % ---------------------------------------- n = length(w); gap = sum(w); sumwNT = gap; r = n / thetaSQR; cardT = 0; wQ = []; sumdifv = 0; sumdifw = 0; cardQ = n; hSQR = sumwNT / (r - cardT); hubSQR = sumwNT / (r-(n-1)); for j = 1:n wj = w(j); if wj >= hubSQR % wj >= hubSQR ==> not in T cardQ = cardQ - 1; hubSQR = sumwNT / (r-cardT-cardQ); elseif wj < hSQR % wj < hSQR ==> in T cardT = cardT + 1; cardQ = cardQ - 1; hubSQR = (1-wj/sumwNT) * hubSQR; sumwNT = sumwNT - wj; oldhSQR = hSQR; hSQR = sumwNT / (r - cardT); sumdifw = sumdifw + (oldhSQR-wj) + cardT * (hSQR-oldhSQR); sumdifv = sumdifv + (sqrt(oldhSQR)-sqrt(wj)) + ... cardT * (sqrt(hSQR)-sqrt(oldhSQR)); else % Inconclusive: j in Q wQ = [wQ;wj]; end % if end % for % ---------------------------------------- % The same treatment for the Q set, but we % sort the (presumably short) wQ first. % ---------------------------------------- if ~isempty(wQ) sort(wQ); STOP = 0; j = 1; while ~STOP wj = wQ(j); if wj >= hSQR STOP = 1; else cardT = cardT + 1; sumwNT = sumwNT - wj; oldhSQR = hSQR; hSQR = sumwNT / (r - cardT); sumdifw = sumdifw + (oldhSQR-wj) + cardT * (hSQR-oldhSQR); sumdifv = sumdifv + (sqrt(oldhSQR)-sqrt(wj)) + ... cardT * (sqrt(hSQR)-sqrt(oldhSQR)); j = j+1; if j > length(wQ) STOP = 1; end end end end % treatment Q % ---------------------------------------- % alpha = sumdifv/(r*h) % deltaSQR = r * ( 2*alpha-alpha^2 - (1-alpha)^2 * sumdifw/gap ) % (THE ABOVE DIFFERENCE SHOULD NOT BE NUMERICALLY DANGEROUS, % SINCE alpha IS *SIGNIF* BIGGER THAN sumdifw/gap ) % ---------------------------------------- h = sqrt(hSQR); alpha = sumdifv/ (r*h); deltaSQR = alpha*(2-alpha) - (1-alpha)^2 * sumdifw/gap; delta = sqrt(r*deltaSQR);
github
urbste/MLPnP_matlab_toolbox-master
fwblkslv.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/fwblkslv.m
1,959
utf_8
afaeb9493d21b9aba30ef5c9ca9b42e7
% FWBLKSLV Solves block sparse upper-triangular system. % y = fwblkslv(L,b) yields the same result as % y = L.L\b(L.perm,:) % However, FWBLKSLV is faster than the built-in operator "\", % because it uses dense linear algebra and loop-unrolling on % supernodes. % % Typical use, with X sparse m x m positive definite and b is m x n: % L = sparchol(symbchol(X),X); % y = bwblkslv(L,fwblkslv(L,b)); % Then y solves X*y=b. % % See also symbchol, sparchol, bwblkslv, mldivide, mrdivide function y = fwblkslv(L,b) % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA error('At OS prompt, type "make" to create cholTool mex-files.')
github
urbste/MLPnP_matlab_toolbox-master
trydif.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/trydif.m
2,489
utf_8
11997f7d1de309ae4f154ae656362f9d
% [t,wr,w] = trydif(t,wrIN,wIN, x,z, pars,K) % TRYDIF Tries feasibility of differentiated step length w.r.t. % wide region and its neighborhood. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi, stepdif function [t,wr,w] = trydif(t,wrIN,wIN, x,z, pars,K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % thetaSQR = pars.theta^2; ix = K.mainblks; % -------------------------------------------------- % Let w = D(xM)*zM, compute lambda(w). % -------------------------------------------------- % LORENTZ w.tdetx = tdet(x,K); w.tdetz = tdet(z,K); detxz = w.tdetx .* w.tdetz / 4; if isempty(K.q) lab2q = zeros(0,1); else halfxz = (x(ix(1):ix(2)-1).*z(ix(1):ix(2)-1)... + ddot(x(ix(2):ix(3)-1),z,K.qblkstart)) / 2; tmp = halfxz.^2 - detxz; if tmp > 0 lab2q = halfxz + sqrt(tmp); else lab2q = halfxz; end end % PSD w.ux = psdfactor(x,K); w.s = psdscale(w.ux,z,K); % ALL: w.lab = [x(1:K.l).*z(1:K.l); detxz ./ lab2q; lab2q; psdeig(w.s,K)]; [wr.delta,wr.h,wr.alpha] = iswnbr(w.lab, thetaSQR); wr.desc = wrIN.desc; % always descent direction. if wr.delta > pars.beta t = 0; w = wIN; wr = wrIN; end
github
urbste/MLPnP_matlab_toolbox-master
asmDxq.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/asmDxq.m
2,735
utf_8
4021e5a1dc8a445ad7e30c2170dbf01a
% y = asmDxq(d, x, K [, ddotx]) % ASMDXQ Assemble y = D(d)x for x in Lorentz part of K. % [y,t] = AasmDxq(d, x, K [, ddotx]) then y[k]+t(k)*d[k] = D(dk)xk. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function [y,t] = asmDxq(d, x, K, ddotx) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % if isempty(K.q) y = zeros(0,1); t = zeros(0,1); else % ------------------------------------------------------------ % Let i1, i2 such that x(i1:i2-1) = "x1", i.e. Lorentz trace part. % ------------------------------------------------------------ if length(x) >= K.lq i1 = K.mainblks(1); i2 = K.mainblks(2); else i1 = 1; i2 = length(K.q)+1; end t = x(i1:i2-1); if nargin < 4 ddotx = d.q1.*t + ddot(d.q2,x,K.qblkstart); end % -------------------------------------------------- % Since d^{1/2} = (d+sqrt(det d)*iota) / trace(d^{1/2}), % and d.auxtr = trace(d^{1/2})^2, d.auxdet = sqrt(2*det d), % We have P(d)^{1/2}x = t*d + t*auxdet*e_1 - sqrt(det d)*Jx, % where t = (d'*x + x(1)*auxdet)/auxtr. % -------------------------------------------------- t = (ddotx + t.* d.auxdet) ./ d.auxtr; % old t = x1 sdet = sqrt(d.det); y = [t.*(d.auxdet) - sdet .* x(i1:i2-1); qblkmul(sdet,x,K.qblkstart)]; if nargout < 2 y = y + [t.*d.q1; qblkmul(t,d.q2,K.qblkstart)]; end end
github
urbste/MLPnP_matlab_toolbox-master
symfctmex.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/symfctmex.m
1,990
utf_8
13ca2c91fee7af502a14c702297c724b
% [L,perm,xsuper,split,tmpsiz] = symfctmex(X, perm, cachsz) % Computes sparse symbolic factor L, updated permutation PERM, % super-node partition XSUPER, and a splitting of supernodes % (SPLIT) to optimize use of the computer cache (assuming % CACHSZ*1024 byte available). TMPSIZ is the amount of floating % point working storage that has to be allocated within blkfctmex. % % Invokes ORNL block Cholesky library (Fortran). % % ********** INTERNAL FUNCTION OF CHOLTOOL ********** % % See also sedumi function [L,perm,xsuper,split,tmpsiz] = symfctmex(adjncy, perm, cachsz) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % error('At OS prompt, type "make" to create cholTool mex-files.')
github
urbste/MLPnP_matlab_toolbox-master
symbchol.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/symbchol.m
3,197
utf_8
40b95638fa00d31c904c92f5108cef30
% L = symbchol(X) % SYMBCHOL Symbolic block sparse Cholesky factorization. % L = symbchol(X) returns a structure L that can be used % by the efficient block sparse Cholesky solver SPARCHOL. % The fields in L have the following meaning: % % L.perm - Multiple minimum degree ordering. % % L.L - Sparse lower triangular matrix, has sparsity structure % of Cholesky factor of X(L.perm,L.perm). % % L.xsuper - Supernode partition. Supernode jsup consists of % the nodes L.xsuper(jsup) : L.xsuper(jsup)-1. % % L.split - Splitting of supernodes. Recommends to split supernode % in blocks of sizes L.split(xsuper(jsup):L.xsuper(jsup)-1). % % L.tmpsiz - Quantity used by SPARCHOL, to allocated enough working % storage. % % L = symbchol(X,cachsz) optimizes L.split for a computer cache % of size CACHSZ * 1024 byte. Default cachsz = 512. % % See also sparchol, sparfwslv, sparbwslv, symbfact, symmmd, chol. function L = symbchol() % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % % ---------------------------------------- % Enter here the cache-size in KB, for shaping % optimal dense blocks of floats. % ---------------------------------------- global ADA if ~issparse(ADA) error('X should be a sparse symmetric matrix') end cachsz = 512; % ---------------------------------------- % Compute multiple minimum degree ordering. % If the matrix is actually dense we don't bother. % ---------------------------------------- if spars(ADA)<1 perm = ordmmdmex(ADA); L = symfctmex(ADA,perm); else L.perm=(1:size(ADA,1))'; L.L=sparse(tril(ones(size(ADA)))); L.xsuper=[1;size(ADA,1)+1]; end % ---------------------------------------- % Symbolic Cholesky factorization structures, stored in L. % ---------------------------------------- L.tmpsiz = choltmpsiz(L); L.split = cholsplit(L,cachsz);
github
urbste/MLPnP_matlab_toolbox-master
getsymbada.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/getsymbada.m
2,291
utf_8
4f114f34a066f4164a180e45d55e1346
% SYMBADA = getsymbada(At,Ajc,DAt,psdblkstart) % GETSYMBADA % Ajc points to start of PSD-nonzeros per column % DAt.q has the nz-structure of ddotA. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi, partitA, getada1, getada2. function SYMBADA = getsymbada(At,Ablkjc,DAt,psdblkstart) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % Alpq = spones(extractA(At,Ablkjc,0,3,1,psdblkstart(1))); Ablks = findblks(At,Ablkjc,3,[],psdblkstart); if spars(Ablks)==1 | spars(Alpq)==1 | (~isempty(DAt.q) & spars(DAt.q)==1) SYMBADA=sparse(ones(size(At,2),size(At,2))); else SYMBADA=DAt.q'*DAt.q; if spars(SYMBADA)>0.9 SYMBADA=sparse(ones(size(At,2),size(At,2))); return else SYMBADA = SYMBADA + Alpq' * Alpq; if spars(SYMBADA)>0.9 SYMBADA=sparse(ones(size(At,2),size(At,2))); return else SYMBADA = SYMBADA + Ablks'*Ablks; end end end
github
urbste/MLPnP_matlab_toolbox-master
statsK.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/statsK.m
1,781
utf_8
12ff626206549b4741bb0281466db66f
% K = statsK(K) % STATSK Collects statistics (max and sum of dimensions) of cone K % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi function K = statsK(K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
qinvjmul.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/qinvjmul.m
2,412
utf_8
dec5fb2062e903290a8620345bfea739
% y = qinvjmul(labx,frmx,b,K) % QINVJMUL Inverse of Jordan multiply for Lorentz blocks % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function y = qinvjmul(labx,frmx,b,K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % lorN = length(K.q); if lorN == 0 y = zeros(0,1); return end if length(labx) > 2*lorN labx = labx(K.l+1:K.l+2*lorN); end detx = labx(1:lorN) .* labx(lorN+1:end); x = qframeit(labx,frmx,K); ix = K.mainblks; if length(b) == ix(3)-ix(1); % lorentz only ? ix = (1-ix(1)) + ix; end % ------------------------------------------------------------ % Let y1(k) = xk'Jbk/(sqrt2*detxk) % ------------------------------------------------------------ y1 = x(1:lorN).*b(ix(1):ix(2)-1) - ddot(x(lorN+1:end),b,K.qblkstart); y1 = y1./(sqrt(2)*detx); % ------------------------------------------------------------ % Let y2[k] = (sqrt2/x1)*b2[k] - (y1/x1) * x2[k] % ------------------------------------------------------------ y = [y1; qblkmul(sqrt(2)./x(1:lorN),b,K.qblkstart)... - qblkmul(y1./x(1:lorN),x(lorN+1:end),K.qblkstart)];
github
urbste/MLPnP_matlab_toolbox-master
whichcpx.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/whichcpx.m
1,768
utf_8
5f028bd9c4ab83a5b133fd819123428b
% cpx = whichcpx(K) % WHICHCPX yields structure cpx.{f,q,r,x} % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi function cpx = whichcpx(K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
triumtriu.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/triumtriu.m
1,970
utf_8
00fc269408152bf90c80ab0ec660247e
% y = triumtriu(r,u,K) % TRIUMTRIU Computes y = r * u % Both r and u should be upper triangular. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function y = triumtriu(r,u,K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA Ks=K.s; startindices=K.sblkstart-K.mainblks(end)+1; y=zeros(K.blkstart(end)-K.mainblks(end),1); for k = 1:length(Ks) %This works, but I don't like the lot of 0 matrices. temp=triu(reshape(r(startindices(k):startindices(k+1)-1),Ks(k),Ks(k)),0)*triu(reshape(u(startindices(k):startindices(k+1)-1),Ks(k),Ks(k)),0); y(startindices(k):startindices(k+1)-1)=temp+triu(temp,1)'; end
github
urbste/MLPnP_matlab_toolbox-master
getada2.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/getada2.m
1,909
utf_8
a8fc0f8faec3032542bec1ff776fc6a3
% ADA = getada2(ADA, DAt,Aord, K) % GETADA2 Compute ADA += DAt.q'*DAt.q % IMPORTANT: Updated ADA only on triu(ADA(Aord.qperm,Aord.qperm)). % Remaining entries are not affected. % % ******************** INTERNAL FUNCTION OF SEDUMI ******************** % % See also sedumi, getada1, getada3 function ADA = getada2(ADA, DAt,Aord, K) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')
github
urbste/MLPnP_matlab_toolbox-master
urotorder.m
.m
MLPnP_matlab_toolbox-master/gOp/SeDuMi_1_3 2/urotorder.m
1,801
utf_8
4be6f57ee235f79abb8a2db74d4b9948
% [u,perm,gjc,g] = urotorder(u,K, maxu,permIN) % UROTORDER Stable reORDERing of triu U-factor by Givens ROTations. % % ********** INTERNAL FUNCTION OF SEDUMI ********** % % See also sedumi function [u,perm,gjc,g] = urotorder(u,K, maxu,permIN) % % This file is part of SeDuMi 1.1 by Imre Polik and Oleksandr Romanko % Copyright (C) 2005 McMaster University, Hamilton, CANADA (since 1.1) % % Copyright (C) 2001 Jos F. Sturm (up to 1.05R5) % Dept. Econometrics & O.R., Tilburg University, the Netherlands. % Supported by the Netherlands Organization for Scientific Research (NWO). % % Affiliation SeDuMi 1.03 and 1.04Beta (2000): % Dept. Quantitative Economics, Maastricht University, the Netherlands. % % Affiliations up to SeDuMi 1.02 (AUG1998): % CRL, McMaster University, Canada. % Supported by the Netherlands Organization for Scientific Research (NWO). % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % 02110-1301, USA % disp('The SeDuMi binaries are not installed.') disp('In Matlab, launch "install_sedumi" in the folder you put the SeDuMi files.') disp('For more information see the file Install.txt.') error(' ')