project.m 1.18 KiB
function C = project(Set,BSet,method)
%COMPLETESET Summary of this function goes here
% Detailed explanation goes here
[Set,BSet] = SR.align(Set,BSet);
[ ImgSize, ImgRes, ~, Color, Label] = SR.SetToFields( Set);
[ BImgSize, BImgRes, ~, BColor, BLabel] = SR.SetToFields(BSet);
SetSize = size(Set);
numLab = numel(Label);
for lab = 1:numLab
Color{lab} = reshape( Color{lab},prod( ImgSize{lab}),prod( ImgRes{lab}));
Label{lab} = reshape( Label{lab},prod( ImgSize{lab}),prod( ImgRes{lab}));
Color{lab}(~( Label{lab}==lab)) = 0;
BColor{lab} = reshape(BColor{lab},prod(BImgSize{lab}),prod(BImgRes{lab}));
BLabel{lab} = reshape(BLabel{lab},prod(BImgSize{lab}),prod(BImgRes{lab}));
BColor{lab}(~(BLabel{lab}==lab)) = 0;
end
switch method
case 'global'
Value = {Set2Matrix( Color)};
BValue = {Set2Matrix(BColor)};
case 'local'
Value = Color;
BValue = BColor;
end
C = cell(SetSize);
for it = 1:numel(BValue)
C{it} = pinv(BValue{it})*Value{it};
end
switch method
case 'global'
C = C{1};
end
%% Auxiliary functions
function Matrix = Set2Matrix(Set)
Matrix = cell2mat(reshape(Set,[],1));
end
end