Is it possible to change numLabels manually when using labelvolshow?

조회 수: 2 (최근 30일)
Wu Yu-Wei
Wu Yu-Wei 2021년 8월 22일
댓글: Wu Yu-Wei 2021년 9월 7일
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
Wu Yu-Wei
Wu Yu-Wei 2021년 9월 6일
편집: Wu Yu-Wei 2021년 9월 6일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 8월 22일
편집: Walter Roberson 2021년 8월 22일
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
Wu Yu-Wei
Wu Yu-Wei 2021년 9월 7일
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 2021년 9월 7일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Purple에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by