Is it possible to change numLabels manually when using labelvolshow?

2 views (last 30 days)
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
Wu Yu-Wei
Wu Yu-Wei on 6 Sep 2021
Edited: Wu Yu-Wei on 6 Sep 2021
I found myself not so clear in the original post that
I forgot to mention the shape of one label might change but the ID remains the same before disappearing.
So I don't want the colour for same labels change and I want different IDs with different colours in a short time period.
e.g: the orange, red and purple labels exist around t18 -> t19 -> tn
The biggest problem is the ID easily exceed the limit of colours for labelvolshow (recently I found it is 128) after t30.
All the labels become same colour.
I guess reusing colours is ok as long as these different labels can be distinguished by time
But I'm not sure how to do it.
Thanks

Sign in to comment.

Answers (1)

Walter Roberson
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
Wu Yu-Wei
Wu Yu-Wei on 7 Sep 2021
Dear Walter,
Thanks for your answer,
It seems the labelvolshow uses the real value in the L array.
e.g, 36th L array (which is also t36), there are 10 labels and their IDs are in the pic.
Although the cmap is set for 10 elements.
cmap = colormap(jet(numel(usedL)))
But the real value in L array exceed the limit of colours for labelvolshow (recently I found it is 128) and all labels become same colour.
Wu Yu-Wei
Wu Yu-Wei on 7 Sep 2021
By the way,
The volumeViewer cannot set different colours.
Even when I want to manually set colour for individual label, they change together.
I'll suggest MATHWORKS to improve 3D view

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!