BRL-CAD
colorspace.h
Go to the documentation of this file.
1/* C O L O R S P A C E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2011-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup icv_colorspace
21 *
22 * @brief
23 * Functions to change an image from one color space to another.
24 *
25 */
26
27#ifndef ICV_COLORSPACE_H
28#define ICV_COLORSPACE_H
29
30#include "common.h"
31#include "icv/defines.h"
32
33__BEGIN_DECLS
34
35/** @{ */
36/** @file icv/colorspace.h */
37
38
39typedef enum {
48
49
50/**
51 * Converts a single channel image to three channel image. Replicates
52 * the pixel as done by bw-pix utility returns a three channel image.
53 * If a three channel image is passed, this function returns the same
54 * image.
55 */
56ICV_EXPORT int icv_gray2rgb(icv_image_t *img);
57
58/**
59 * converts image to single channel image by combining three weights
60 * based on NTSC primaries and 6500 white.
61 */
62#define icv_rgb2gray_ntsc(_a) icv_rgb2gray(_a, ICV_COLOR_RGB, 0.30, 0.59, 0.11)
63
64/**
65 * converts image to single channel image by combining three weights
66 * based on CRT phosphor and D6500 white.
67 */
68#define icv_rgb2gray_crt(_a) icv_rgb2gray(_a, ICV_COLOR_RGB, 0.26, 0.66, 0.08)
69
70/**
71 * converts a three channel rgb image to single channel gray-image.
72 * This function will combine or select planes of the image based on
73 * the input arguments.
74 *
75 * A normal calling of this functions is as follows:
76 * icv_image_rgb2gray(bif, 0, 0, 0, 0); where bif is the rgb image
77 * to be converted.
78 *
79 * @param[in,out] img - image
80 * @param[in] color Chooses color planes to be selected for combination.
81 * This function will need color to be specified from
82 * ICV_COLOR_R
83 * ICV_COLOR_G
84 * ICV_COLOR_B
85 * ICV_COLOR_RG
86 * ICV_COLOR_RB
87 * ICV_COLOR_BG
88 * ICV_COLOR_RGB
89 * @param[in] rweight Weight for r-plane
90 * @param[in] gweight Weight for g-plane
91 * @param[in] bweight Weight for b-plane
92 * @return 0 on success; on failure return 1
93 *
94 * User can specify weights in the arguments, for the selected color
95 * planes. If 0 weight is chosen this utility assigns equal weights.
96 *
97 */
98ICV_EXPORT int icv_rgb2gray(icv_image_t *img,
99 ICV_COLOR color,
100 double rweight,
101 double gweight,
102 double bweight);
103
104/** @} */
105
106__END_DECLS
107
108#endif /* ICV_COLORSPACE_H */
109
110/*
111 * Local Variables:
112 * tab-width: 8
113 * mode: C
114 * indent-tabs-mode: t
115 * c-file-style: "stroustrup"
116 * End:
117 * ex: shiftwidth=4 tabstop=8
118 */
Header file for the BRL-CAD common definitions.
int icv_gray2rgb(icv_image_t *img)
ICV_COLOR
Definition: colorspace.h:39
int icv_rgb2gray(icv_image_t *img, ICV_COLOR color, double rweight, double gweight, double bweight)
@ ICV_COLOR_G
Definition: colorspace.h:42
@ ICV_COLOR_BG
Definition: colorspace.h:46
@ ICV_COLOR_RB
Definition: colorspace.h:45
@ ICV_COLOR_B
Definition: colorspace.h:43
@ ICV_COLOR_RG
Definition: colorspace.h:44
@ ICV_COLOR_R
Definition: colorspace.h:41
@ ICV_COLOR_RGB
Definition: colorspace.h:40