BRL-CAD
Loading...
Searching...
No Matches
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-2025 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
39
typedef
enum
{
40
ICV_COLOR_RGB
,
41
ICV_COLOR_R
,
42
ICV_COLOR_G
,
43
ICV_COLOR_B
,
44
ICV_COLOR_RG
,
45
ICV_COLOR_RB
,
46
ICV_COLOR_BG
47
}
ICV_COLOR
;
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
*/
56
ICV_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
*
77
* icv_rgb2gray(bif, ICV_COLOR_RGB, 0, 0, 0);
78
*
79
* where bif is the rgb image to be converted.
80
*
81
* @param[in,out] img - image
82
* @param[in] color Chooses color planes to be selected for combination.
83
* This function will need color to be specified from
84
* ICV_COLOR_R
85
* ICV_COLOR_G
86
* ICV_COLOR_B
87
* ICV_COLOR_RG
88
* ICV_COLOR_RB
89
* ICV_COLOR_BG
90
* ICV_COLOR_RGB
91
* @param[in] rweight Weight for r-plane
92
* @param[in] gweight Weight for g-plane
93
* @param[in] bweight Weight for b-plane
94
* @return 0 on success; on failure return 1
95
*
96
* User can specify weights in the arguments, for the selected color
97
* planes. If 0 weight is chosen this utility assigns equal weights.
98
*
99
*/
100
ICV_EXPORT
int
icv_rgb2gray
(
icv_image_t
*
img
,
101
ICV_COLOR
color,
102
double
rweight
,
103
double
gweight
,
104
double
bweight
);
105
106
/** @} */
107
108
__END_DECLS
109
110
#endif
/* ICV_COLORSPACE_H */
111
112
/*
113
* Local Variables:
114
* tab-width: 8
115
* mode: C
116
* indent-tabs-mode: t
117
* c-file-style: "stroustrup"
118
* End:
119
* ex: shiftwidth=4 tabstop=8
120
*/
dvec
Definition
dvec.h:74
common.h
Header file for the BRL-CAD common definitions.
icv_gray2rgb
int icv_gray2rgb(icv_image_t *img)
ICV_COLOR
ICV_COLOR
Definition
colorspace.h:39
icv_rgb2gray
int icv_rgb2gray(icv_image_t *img, ICV_COLOR color, double rweight, double gweight, double bweight)
ICV_COLOR_G
@ ICV_COLOR_G
Definition
colorspace.h:42
ICV_COLOR_BG
@ ICV_COLOR_BG
Definition
colorspace.h:46
ICV_COLOR_RB
@ ICV_COLOR_RB
Definition
colorspace.h:45
ICV_COLOR_B
@ ICV_COLOR_B
Definition
colorspace.h:43
ICV_COLOR_RG
@ ICV_COLOR_RG
Definition
colorspace.h:44
ICV_COLOR_R
@ ICV_COLOR_R
Definition
colorspace.h:41
ICV_COLOR_RGB
@ ICV_COLOR_RGB
Definition
colorspace.h:40
defines.h
icv_image
Definition
defines.h:67
include
icv
colorspace.h
Generated on Sun Jul 6 2025 01:43:26 for BRL-CAD by
1.9.8