Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a80e871f authored by DIB Elian's avatar DIB Elian
Browse files

Added functions to tighten super-ray to its bounding box

parent 151eb443
Branches
No related tags found
No related merge requests found
tight.m 0 → 100644
function [Val,Pos] = tight(Val,varargin)
%TIGHT Summary of this function goes here
% Detailed explanation goes here
defSize = size(Val);
defPos = zeros(size(defSize));
p = inputParser; p.KeepUnmatched = true; p.StructExpand = true;
p.addOptional('Pos', defPos);
p.addOptional('Size', defSize);
p.parse(varargin{:});
Pos = p.Results.Pos;
M = isnan(Val);
M1 = all(M,1);
M12 = all(M1,2);
M123 = all(M12,3);
M124 = all(M12,4);
M3 = all(M,3);
M34 = all(M3,4);
M134 = all(M34,1);
M234 = all(M34,2);
gv = {find(~M234,1,'first'):find(~M234,1,'last'),...
find(~M134,1,'first'):find(~M134,1,'last'),...
find(~M124,1,'first'):find(~M124,1,'last'),...
find(~M123,1,'first'):find(~M123,1,'last')};
Val = Val(gv{:});
InnerPos = cellfun(@(x) x(1),gv)-1;
Pos = Pos+InnerPos;
end
\ No newline at end of file
function [Val,Pos,varargout] = tightSet(Val,Pos,varargin)
%TIGHTSET Summary of this function goes here
% Detailed explanation goes here
varargout = varargin;
for it = 1:numel(Val)
[Val{it},Pos{it}] = SR.tight(Val{it},Pos{it});
for k = 1:numel(varargin)
varargout{k}{it} = SR.tight(varargin{k}{it},Pos{it});
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment