relabel matrix accroding to another label mapping

2 visualizaciones (últimos 30 días)
em
em el 18 de Nov. de 2014
Respondida: Image Analyst el 18 de Nov. de 2014
I have a label matrix for an image, for example:
map = [1 1 2 5 6; 1 2 2 5 6; 1 2 3 4 5; 2 3 4 4 5]
I have another label mapping vector, to map a label in map to another label. For example, in map, there are 6 labels, so the label mapping vector is [6x1]:
label = [0 3 0 9 10 3]
meaning, label 1 and 3 in map is remapped to 0; label 2 and 6 is remapped to 3; label 4 and 5 in map is remapped to 9 and 10 respectively.
How can I replace labels in map with new labels?

Respuestas (1)

Image Analyst
Image Analyst el 18 de Nov. de 2014
Use intlut():
% Create sample data.
map = [1 1 2 5 6; 1 2 2 5 6; 1 2 3 4 5; 2 3 4 4 5]
label = [0 3 0 9 10 3]
% Create 256 element look up table.
lut = uint8([label, zeros(1, 256-length(label))]);
% Use intlut to transform the image.
output = intlut(uint8(map), lut)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by