Is it possible to change numLabels manually when using labelvolshow?
Show older comments
Hi,
I adopted labelvolshow into custom function to show 3D time series data, but encountered a problem about colormap.
My data are these size
V = 483x496x5 double;
multiple same size and class Ln = 483x496x5 uint16;
the values in a L are given according to appearance time,
this makes my total numLabels is more than 2000 but only some of them in the same L.
(e.g: L346 is 483x496x5 uint16, the values for (x= 163:224, y= 120:189, z= 2:3) is 1966 )

The documentation said LabelColor accept numLabels-by-3, where numLabels represents the number of labels in the labeled volume
but I still give it a try
cmap = colormap(jet(numLabels));
hImage=labelvolshow(L, V,'Parent',P1, ...
'BackgroundColor',backgroundcolor, 'ScaleFactors', scalefact,...
'VolumeOpacity', volopacity, 'VolumeThreshold', volthreshold, 'LabelColor',cmap);
as expected, I got error message:
Error using labelvolshow
Expected LabelColor to be of size 8x3, but it is of size 2806x3.
So I want to know is there any suggestion/solution for my purpose?
1 Comment
Answers (1)
Walter Roberson
on 22 Aug 2021
Edited: Walter Roberson
on 22 Aug 2021
background_label = 0;
cmap = colormap(jet(numLabels));
%then for any particular L, V:
usedL = setdiff(unique(L), background_label);
hImage=labelvolshow(L, V,'Parent',P1, ...
'BackgroundColor',backgroundcolor, 'ScaleFactors', scalefact,...
'VolumeOpacity', volopacity, 'VolumeThreshold', volthreshold, 'LabelColor',cmap(usedL,:));
This assumes that there is a background label 0 that is to be ignored.
4 Comments
Walter Roberson
on 6 Sep 2021
Okay, it appears that the background is handled as-if it is a "label" with its own color, but marked as transparent. So
usedL = unique(L);
colormap(jet(numel(usedL)))
hImage=labelvolshow(L, V,'Parent',P1, ...
'BackgroundColor',backgroundcolor, 'ScaleFactors', scalefact,...
'VolumeOpacity', volopacity, 'VolumeThreshold', volthreshold, 'LabelColor',cmap);
Wu Yu-Wei
on 7 Sep 2021
Wu Yu-Wei
on 7 Sep 2021
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



