I'm attempting to generate a RGB label slice using label2rgb and use it to update a RGB volume, like this:
labelRGB_slice=label2rgb(handles.label(:,:,handles.current_slice_z), 'jet', [0 0 0]);
handles.labelRGB(:,:,handles.current_slice_z) = labelRGB_slice;
I'm getting the following error:
**Assignment has more non-singleton rhs dimensions than non-singleton subscripts**
Error in Tesis_GUI>drawSeedButton_Callback (line 468)
handles.labelRGB(:,:,handles.current_slice_z) = labelRGB_slice;
When debugging I get this:
size(labelRGB_slice)
ans =
160 216 3
K>> size(handles.labelRGB(:,:,handles.current_slice_z) )
ans =
160 216
I declared handles.labelRGB like this:
handles.labelRGB = zeros(dim(1), dim(2), dim(3), 3);
So I don't understand the index disparity.
How can I make the slice assignment work?
Based on the way you have declared handles.labelRGB
it is a 4D array of size [160 216 3 3]
however you are indexing it as a 3D array using handles.labelRGB(:,:,handles.current_slice_z)
that means matlab will use linear indexing for the last two dimensions. So if, say handles.current_slice_z = 5
, it returns handles.labelRGB(:,:,2,2)
which is a matrix of size [160 216]
. So depending on the meaning of handles.current_slice_z
you either need to use
handles.labelRGB(:,:,:,handles.current_slice_z) = labelRGB_slice;
or
handles.labelRGB(:,:,handles.current_slice_z,:) = labelRGB_slice;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With