Mentions légales du service

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

Fixed incorrect label size when using color

parent 38bd7fdc
Branches
No related tags found
No related merge requests found
......@@ -3,8 +3,8 @@ function [Ref,C,Value,U,S,V] = factorize(Ref,method,k,varargin)
% Detailed explanation goes here
[Offset,Color,Label] = SR.SetToFields(Ref);
Size = cellfun(@size,Color,'UniformOutput',false);
[ImgSize,ImgRes] = cellfun(@(x) deal(x(1:3),x(4:end)),Size,'UniformOutput',false);
ColSize = cellfun(@size,Color,'UniformOutput',false);
LabSize = cellfun(@size,Label,'UniformOutput',false);
RefSize = size(Ref);
numLab = numel(Label);
numDims = ndims(Color{1});
......@@ -23,16 +23,22 @@ if (isempty(colDims)&&isempty(rowDims)); colDims = 1:min(3,numDims); end
if isempty(colDims); colDims = setdiff(1:numDims,rowDims); end
if isempty(rowDims); rowDims = setdiff(1:numDims,colDims); end
[ColImgSize,LabImgSize] = deal(cell(1,numLab));
[ColImgSize(:),LabImgSize(:)] = deal({nan(1,numel(colDims))});
for lab = 1:numLab
ImgSize{lab} = Size{lab}(colDims);
ImgRes {lab} = Size{lab}(rowDims);
ColImgSize{lab} = ColSize{lab}(colDims);
LabImgSize{lab} = LabSize{lab}(colDims);
Label{lab} = Label{lab}.*ones(Size{lab});
LabelMask = repmat(Label{lab},size(Color{lab})./size(Label{lab}));
LabelMask = permute(LabelMask ,[colDims,rowDims]);
Label{lab} = permute(Label{lab},[colDims,rowDims]);
Label{lab} = reshape(Label{lab},prod(ImgSize{lab}),prod(ImgRes{lab}));
Color{lab} = permute(Color{lab},[colDims,rowDims]);
Color{lab} = reshape(Color{lab},prod(ImgSize{lab}),prod(ImgRes{lab}));
Color{lab}(Label{lab}==0) = nan;
LabelMask = reshape(LabelMask ,prod(ColImgSize{lab}),[]);
Label{lab} = reshape(Label{lab},prod(LabImgSize{lab}),[]);
Color{lab} = reshape(Color{lab},prod(ColImgSize{lab}),[]);
LabelMask = any(LabelMask==0,2);
Color{lab}(LabelMask,:) = nan;
end
switch method
......@@ -52,17 +58,16 @@ ImgRes(:) = deal({[k,1]});
switch method
case 'global'
Color = Matrix2Set(Value{1},ImgSize,ImgRes);
Color = Matrix2Set(Value{1},ColImgSize,ImgRes);
C = C{1};
case 'local'
Color = Value;
end
for lab = 1:numLab
Color{lab} = reshape(Color{lab},[ImgSize{lab},ImgRes{lab}]);
Color{lab} = reshape(Color{lab},[ColImgSize{lab},k]);
Label{lab} = repmat(Label{lab}(:,1),1,k);
ImgRes{lab} = [k,1];
Label{lab} = reshape(Label{lab},[ImgSize{lab},ImgRes{lab}]);
Label{lab} = reshape(Label{lab},[LabImgSize{lab},k]);
Color{lab} = ipermute(Color{lab},[colDims,rowDims]);
Label{lab} = ipermute(Label{lab},[colDims,rowDims]);
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment