image - How to match the resulting "map" with the given "color_map"? -
i have rgb image called imrgb, size of 320*512*3 double.and have color_map = 64*3 double. use following code:
[x, map] = rgb2ind(imrgb, 256)
the resulting x= 320*512 uint8, , resulting map = 65*3 double. resulting "map" totally different given "color_map". how fix problem?
the first few rows of "map" looks this:
0 0 0 0 0.125 1 0.56 1 0.439 1 0.125 0 0.188 1 0.812 1 0.749 0 0 0.7490 1 0.5019 0 0 0.7490 1 0.25098
the first few rows of given "color_map" looks this:
0 0 0.5625 0 0 0.6250 0 0 0.6875 0 0 0.7500 0 0 0.8125 0 0 0.8750 0 0 0.9375 0 0 1 0 0.0625 1
using rgb2ind
performs colour quantization (the default uniform quantization directly in rgb space , apply dithering image) of image number of colours (in case, 256) if don't specify input colour map. map
output provides colour map best segments colours using quantization image imrgb
. variable x
gives indices of each pixel maps in colour map map
variable. lookup table of colours.
this map
variable tells colour lookup table pixel should visualized as. example, above call in post produce indexed image x
has indices 1 256 , map
contain 256 rows each column proportion of red (first column), green (second column) , blue (third column). proportions between [0-1]
. also, each row unique colour. therefore, if index found in image 5, we'd fifth row of colour map , colour representative of pixel.
therefore, calling rgb2ind
in current way does not correspond custom colour map provided unless provide colour map input rgb2ind
. such, if want obtain indexed image using custom colour map provided you, use colour map input rgb2ind
indexed image respect new colour map.
in case, need do:
[x, map] = rgb2ind(imrgb, colour_map);
Comments
Post a Comment