Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
LightFieldCodingLibrary
SR
Commits
333874aa
Commit
333874aa
authored
5 years ago
by
DIB Elian
Browse files
Options
Downloads
Patches
Plain Diff
Fixed incorrect label size when using color
parent
38bd7fdc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
factorize.m
+17
-12
17 additions, 12 deletions
factorize.m
with
17 additions
and
12 deletions
factorize.m
+
17
−
12
View file @
333874aa
...
...
@@ -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
);
Col
Size
=
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
}(
row
Dims
);
Col
ImgSize
{
lab
}
=
Col
Size
{
lab
}(
colDims
);
LabImgSize
{
lab
}
=
Lab
Size
{
lab
}(
col
Dims
);
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
},
Col
ImgSize
,
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
},[
Col
ImgSize
{
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment