|
Chan-Vese Segmentation
|
Convert a truecolor RGB image to an indexed image. More...
Go to the source code of this file.
Functions | |
| int | Rgb2Ind (unsigned char *Dest, unsigned char *Palette, int NumColors, const unsigned char *RgbImage, long NumPixels) |
| Convert a truecolor RGB image to an indexed image. More... | |
Convert a truecolor RGB image to an indexed image.
Copyright (c) 2011, Pascal Getreuer All rights reserved.
This program is free software: you can redistribute it and/or modify it under, at your option, the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, or the terms of the simplified BSD license.
You should have received a copy of these licenses along with this program. If not, see http://www.gnu.org/licenses/ and http://www.opensource.org/licenses/bsd-license.html.
Definition in file rgb2ind.h.
| int Rgb2Ind | ( | unsigned char * | Dest, |
| unsigned char * | Palette, | ||
| int | NumColors, | ||
| const unsigned char * | RgbImage, | ||
| long | NumPixels | ||
| ) |
Convert a truecolor RGB image to an indexed image.
| Dest | where to store the indexed image |
| Palette | where to store the palette |
| NumColors | maximum number of colors to use |
| RgbImage | the input RGB image |
| NumPixels | number of pixels in RgbImage |
This routine quantizes the colors of the input RgbImage to an indexed image Dest using at most NumColors distinct colors. RgbImage should be a contiguous array of RGB triples,
ImageRgb[3*i + 0] = Red component of the ith pixel, ImageRgb[3*i + 1] = Green component of the ith pixel, ImageRgb[3*i + 2] = Blue component of the ith pixel.
Dest should be an array with space for at least NumPixels elements, and Palette should have space for at least 3*NumColors elements. Dest and Palette are filled such that the quantized image is
Palette[3*Dest[i] + 0] = Red component of the ith pixel, Palette[3*Dest[i] + 1] = Green component of the ith pixel, Palette[3*Dest[i] + 2] = Blue component of the ith pixel.
The quantized image should approximate RgbImage.
The quantization is performed using the median cut algorithm. No dithering is performed.
1.8.3.1