BRL-CAD
ops.h
Go to the documentation of this file.
1/* I C V . 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_ops
21 *
22 * Various routines to perform operations on images.
23 *
24 */
25
26#ifndef ICV_OPS_H
27#define ICV_OPS_H
28
29#include "common.h"
30#include <stddef.h> /* for size_t */
31#include "icv/defines.h"
32
33__BEGIN_DECLS
34
35/** @{ */
36/** @file icv/ops.h */
37
38/**
39 * This function sanitizes the image.
40 *
41 * It forces the image pixels to be in the prescribed range.
42 *
43 * All the pixels higher than the max range are set to MAX (1.0).
44 * All the pixels lower than the min range are set to MIN (0.0).
45 *
46 * Note if an image(bif) is sanitized then,
47 * (bif->flags&&ICV_SANITIZED) is true.
48 *
49 */
50ICV_EXPORT int icv_sanitize(icv_image_t* img);
51
52/**
53 * This adds a constant value to all the pixels of the image. Also if
54 * the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the
55 * image.
56 *
57 * Note to set the flag for a bif (icv_image struct);
58 * bif->flags |= ICV_OPERATIONS_MODE;
59 *
60 */
61ICV_EXPORT int icv_add_val(icv_image_t* img, double val);
62
63/**
64 * This multiplies all the pixels of the image with a constant Value.
65 * Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize
66 * the image.
67 */
68ICV_EXPORT int icv_multiply_val(icv_image_t* img, double val);
69
70/**
71 * This divides all the pixels of the image with a constant Value.
72 * Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize
73 * the image.
74 */
75ICV_EXPORT int icv_divide_val(icv_image_t* img, double val);
76
77/**
78 * This raises all the pixels of the image to a constant exponential
79 * power. Also if the flag ICV_OPERATIONS_MODE is set this doesn't
80 * sanitize the image.
81 */
82ICV_EXPORT int icv_pow_val(icv_image_t* img, double val);
83
84/**
85 * This routine adds pixel value of one image to pixel value of other
86 * pixel and inserts in the same index of the output image.
87 *
88 * Also it sanitizes the image.
89 */
90ICV_EXPORT icv_image_t *icv_add(icv_image_t *img1, icv_image_t *img2);
91
92/**
93 * This routine subtracts pixel value of one image from pixel value of
94 * other pixel and inserts the result at the same index of the output
95 * image.
96 *
97 * Also it sanitizes the image.
98 *
99 * @param img1 First Image.
100 * @param img2 Second Image.
101 * @return New icv_image (img1 - img2)
102 *
103 */
104ICV_EXPORT icv_image_t *icv_sub(icv_image_t *img1, icv_image_t *img2);
105
106/**
107 * This routine multiplies pixel value of one image to pixel value of
108 * other pixel and inserts the result at the same index of the output
109 * image.
110 *
111 * Also it sanitizes the image.
112 *
113 * @param img1 First Image.
114 * @param img2 Second Image.
115 * @return New icv_image (img1 * img2)
116 *
117 */
119
120/**
121 * This routine divides pixel value of one image from pixel value of
122 * other pixel and inserts the result at the same index of the output
123 * image.
124 *
125 * Also it sanitizes the image.
126 *
127 * @param img1 First Image.
128 * @param img2 Second Image.
129 * @return New icv_image (img1 / img2)
130 *
131 */
133
134/**
135 * Change the saturation of image pixels. If sat is set to 0.0 the
136 * result will be monochromatic; if sat is made 1.0, the color will
137 * not change; if sat is made greater than 1.0, the amount of color is
138 * increased.
139 *
140 * @param img RGB Image to be saturated.
141 * @param sat Saturation value.
142 */
143ICV_EXPORT int icv_saturate(icv_image_t* img, double sat);
144
145typedef enum {
151
152/**
153 * This function resizes the given input image.
154 * Mode of usage:
155 * a) ICV_RESIZE_UNDERSAMPLE : This method undersamples the said image
156 * e.g. icv_resize(bif, ICV_RESIZE_UNDERSAMPLE, 0, 0, 2);
157 * undersamples the image with a factor of 2.
158 *
159 * b) ICV_RESIZE_SHRINK : This Shrinks the image, keeping the light
160 * energy per square area as constant.
161 * e.g. icv_resize(bif, ICV_RESIZE_SHRINK,0,0,2);
162 * shrinks the image with a factor of 2.
163 *
164 * c) ICV_RESIZE_NINTERP : This interpolates using nearest neighbor
165 * method.
166 * e.g. icv_resize(bif, ICV_RESIZE_NINTERP,1024,1024,0);
167 * interpolates the output image to have the size of 1024X1024.
168 *
169 * d) ICV_RESIZE_BINTERP : This interpolates using bilinear
170 * Interpolation Method.
171 * e.g. icv_resize(bif, ICV_RESIZE_BINTERP,1024,1024,0);
172 * interpolates the output image to have the size of 1024X1024.
173 *
174 * resizes the image inplace.
175 *
176 * @param bif Image (packed in icv_image struct)
177 * @param method One of the modes.
178 * @param out_width Out Width.
179 * @param out_height Out Height.
180 * @param factor Integer type data representing the factor to be
181 * shrunken
182 * @return 0 on success and -1 on failure.
183 */
184ICV_EXPORT int icv_resize(icv_image_t *bif, ICV_RESIZE_METHOD method, size_t out_width, size_t out_height, size_t factor);
185
186/**
187 * Rotate an image.
188 * %s [-rifb | -a angle] [-# bytes] [-s squaresize] [-w width] [-n height] [-o outputfile] inputfile [> outputfile]
189 *
190 */
191ICV_EXPORT extern int icv_rot(size_t argc, const char *argv[]);
192
193/** @} */
194
195__END_DECLS
196
197#endif /* ICV_OPS_H */
198
199/*
200 * Local Variables:
201 * tab-width: 8
202 * mode: C
203 * indent-tabs-mode: t
204 * c-file-style: "stroustrup"
205 * End:
206 * ex: shiftwidth=4 tabstop=8
207 */
Header file for the BRL-CAD common definitions.
icv_image_t * icv_multiply(icv_image_t *img1, icv_image_t *img2)
int icv_multiply_val(icv_image_t *img, double val)
int icv_add_val(icv_image_t *img, double val)
int icv_rot(size_t argc, const char *argv[])
int icv_pow_val(icv_image_t *img, double val)
int icv_sanitize(icv_image_t *img)
icv_image_t * icv_divide(icv_image_t *img1, icv_image_t *img2)
icv_image_t * icv_add(icv_image_t *img1, icv_image_t *img2)
int icv_saturate(icv_image_t *img, double sat)
int icv_resize(icv_image_t *bif, ICV_RESIZE_METHOD method, size_t out_width, size_t out_height, size_t factor)
icv_image_t * icv_sub(icv_image_t *img1, icv_image_t *img2)
int icv_divide_val(icv_image_t *img, double val)
ICV_RESIZE_METHOD
Definition: ops.h:145
@ ICV_RESIZE_UNDERSAMPLE
Definition: ops.h:146
@ ICV_RESIZE_SHRINK
Definition: ops.h:147
@ ICV_RESIZE_BINTERP
Definition: ops.h:149
@ ICV_RESIZE_NINTERP
Definition: ops.h:148