1 /* Copyright 2009-2014 NVIDIA Corporation. All rights reserved.
5 * The source code and/or documentation ("Licensed Deliverables") are
6 * subject to NVIDIA intellectual property rights under U.S. and
7 * international Copyright laws.
9 * The Licensed Deliverables contained herein are PROPRIETARY and
10 * CONFIDENTIAL to NVIDIA and are being provided under the terms and
11 * conditions of a form of NVIDIA software license agreement by and
12 * between NVIDIA and Licensee ("License Agreement") or electronically
13 * accepted by Licensee. Notwithstanding any terms or conditions to
14 * the contrary in the License Agreement, reproduction or disclosure
15 * of the Licensed Deliverables to any third party without the express
16 * written consent of NVIDIA is prohibited.
18 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
19 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
20 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. THEY ARE
21 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
22 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
23 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
24 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
25 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
26 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
27 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
28 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
30 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31 * OF THESE LICENSED DELIVERABLES.
33 * U.S. Government End Users. These Licensed Deliverables are a
34 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
35 * 1995), consisting of "commercial computer software" and "commercial
36 * computer software documentation" as such terms are used in 48
37 * C.F.R. 12.212 (SEPT 1995) and are provided to the U.S. Government
38 * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
39 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
40 * U.S. Government End Users acquire the Licensed Deliverables with
41 * only those rights set forth herein.
43 * Any use of the Licensed Deliverables in individual and commercial
44 * software must include, in the user documentation and internal
45 * comments to the code, the above Disclaimer and U.S. Government End
48 #ifndef NV_NPPI_COMPUTER_VISION_H
49 #define NV_NPPI_COMPUTER_VISION_H
52 * \file nppi_computer_vision.h
53 * NPP Image Processing Functionality.
63 /** @defgroup image_labeling_and_segmentation Labeling and Segmentation
66 * Pixel labeling and image segementation operations.
72 #if defined (__cplusplus)
73 struct NppiGraphcutState;
75 typedef struct NppiGraphcutState NppiGraphcutState;
78 /** @defgroup image_graphcut GraphCut
91 * Calculates the size of the temporary buffer for graph-cut with 4 neighborhood labeling.
93 * \see nppiGraphcutInitAlloc(), nppiGraphcut_32s8u().
95 * \param oSize Graph size.
96 * \param pBufSize Pointer to variable that returns the size of the
99 * \return NPP_SUCCESS Indicates no error. Any other value indicates an error
101 * \return NPP_SIZE_ERROR Indicates an error condition if any image dimension
102 * has zero or negative value
103 * \return NPP_NULL_POINTER_ERROR Indicates an error condition if pBufSize
106 NppStatus nppiGraphcutGetSize(NppiSize oSize, int * pBufSize);
109 * Calculates the size of the temporary buffer for graph-cut with 8 neighborhood labeling.
111 * \see nppiGraphcut8InitAlloc(), nppiGraphcut8_32s8u().
113 * \param oSize Graph size.
114 * \param pBufSize Pointer to variable that returns the size of the
117 * \return NPP_SUCCESS Indicates no error. Any other value indicates an error
119 * \return NPP_SIZE_ERROR Indicates an error condition if any image dimension
120 * has zero or negative value
121 * \return NPP_NULL_POINTER_ERROR Indicates an error condition if pBufSize
124 NppStatus nppiGraphcut8GetSize(NppiSize oSize, int * pBufSize);
127 * Initializes graph-cut state structure and allocates additional resources for graph-cut with 8 neighborhood labeling.
129 * \see nppiGraphcut_32s8u(), nppiGraphcutGetSize().
131 * \param oSize Graph size
132 * \param ppState Pointer to pointer to graph-cut state structure.
133 * \param pDeviceMem pDeviceMem to the sufficient amount of device memory. The CUDA runtime or NPP memory allocators
134 * must be used to allocate this memory. The minimum amount of device memory required
135 * to run graph-cut on a for a specific image size is computed by nppiGraphcutGetSize().
137 * \return NPP_SUCCESS Indicates no error. Any other value indicates an error
139 * \return NPP_SIZE_ERROR Indicates an error condition if any image dimension
140 * has zero or negative value
141 * \return NPP_NULL_POINTER_ERROR Indicates an error condition if pBufSize
144 NppStatus nppiGraphcutInitAlloc(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);
147 * Allocates and initializes the graph-cut state structure and additional resources for graph-cut with 8 neighborhood labeling.
149 * \see nppiGraphcut8_32s8u(), nppiGraphcut8GetSize().
151 * \param oSize Graph size
152 * \param ppState Pointer to pointer to graph-cut state structure.
153 * \param pDeviceMem to the sufficient amount of device memory. The CUDA runtime or NPP memory allocators
154 * must be used to allocate this memory. The minimum amount of device memory required
155 * to run graph-cut on a for a specific image size is computed by nppiGraphcut8GetSize().
157 * \return NPP_SUCCESS Indicates no error. Any other value indicates an error
159 * \return NPP_SIZE_ERROR Indicates an error condition if any image dimension
160 * has zero or negative value
161 * \return NPP_NULL_POINTER_ERROR Indicates an error condition if pBufSize
164 NppStatus nppiGraphcut8InitAlloc(NppiSize oSize, NppiGraphcutState ** ppState, Npp8u * pDeviceMem);
167 * Frees the additional resources of the graph-cut state structure.
169 * \see nppiGraphcutInitAlloc
170 * \see nppiGraphcut8InitAlloc
172 * \param pState Pointer to graph-cut state structure.
174 * \return NPP_SUCCESS Indicates no error. Any other value indicates an error
176 * \return NPP_SIZE_ERROR Indicates an error condition if any image dimension
177 * has zero or negative value
178 * \return NPP_NULL_POINTER_ERROR Indicates an error condition if pState
181 NppStatus nppiGraphcutFree(NppiGraphcutState * pState);
184 * Graphcut of a flow network (32bit signed integer edge capacities). The
185 * function computes the minimal cut (graphcut) of a 2D regular 4-connected
187 * The inputs are the capacities of the horizontal (in transposed form),
188 * vertical and terminal (source and sink) edges. The capacities to source and
190 * are stored as capacity differences in the terminals array
191 * ( terminals(x) = source(x) - sink(x) ). The implementation assumes that the
193 * for boundary edges that would connect to nodes outside the specified domain
194 * are set to 0 (for example left(0,*) == 0). If this is not fulfilled the
195 * computed labeling may be wrong!
196 * The computed binary labeling is encoded as unsigned 8bit values (0 and >0).
198 * \see nppiGraphcutInitAlloc(), nppiGraphcutFree(), nppiGraphcutGetSize().
200 * \param pTerminals Pointer to differences of terminal edge capacities
201 * (terminal(x) = source(x) - sink(x))
202 * \param pLeftTransposed Pointer to transposed left edge capacities
203 * (left(0,*) must be 0)
204 * \param pRightTransposed Pointer to transposed right edge capacities
205 * (right(width-1,*) must be 0)
206 * \param pTop Pointer to top edge capacities (top(*,0) must be 0)
207 * \param pBottom Pointer to bottom edge capacities (bottom(*,height-1)
209 * \param nStep Step in bytes between any pair of sequential rows of edge
211 * \param nTransposedStep Step in bytes between any pair of sequential
212 * rows of tranposed edge capacities
213 * \param size Graph size
214 * \param pLabel Pointer to destination label image
215 * \param nLabelStep Step in bytes between any pair of sequential rows of
217 * \param pState Pointer to graph-cut state structure. This structure must be
218 * initialized allocated and initialized using nppiGraphcutInitAlloc().
219 * \return \ref image_data_error_codes, \ref roi_error_codes
221 NppStatus nppiGraphcut_32s8u(Npp32s * pTerminals, Npp32s * pLeftTransposed, Npp32s * pRightTransposed, Npp32s * pTop, Npp32s * pBottom, int nStep, int nTransposedStep, NppiSize size, Npp8u * pLabel, int nLabelStep, NppiGraphcutState *pState);
225 * Graphcut of a flow network (32bit signed integer edge capacities). The
226 * function computes the minimal cut (graphcut) of a 2D regular 8-connected
228 * The inputs are the capacities of the horizontal (in transposed form),
229 * vertical and terminal (source and sink) edges. The capacities to source and
231 * are stored as capacity differences in the terminals array
232 * ( terminals(x) = source(x) - sink(x) ). The implementation assumes that the
234 * for boundary edges that would connect to nodes outside the specified domain
235 * are set to 0 (for example left(0,*) == 0). If this is not fulfilled the
236 * computed labeling may be wrong!
237 * The computed binary labeling is encoded as unsigned 8bit values (0 and >0).
239 * \see nppiGraphcut8InitAlloc(), nppiGraphcutFree(), nppiGraphcut8GetSize().
241 * \param pTerminals Pointer to differences of terminal edge capacities
242 * (terminal(x) = source(x) - sink(x))
243 * \param pLeftTransposed Pointer to transposed left edge capacities
244 * (left(0,*) must be 0)
245 * \param pRightTransposed Pointer to transposed right edge capacities
246 * (right(width-1,*) must be 0)
247 * \param pTop Pointer to top edge capacities (top(*,0) must be 0)
248 * \param pTopLeft Pointer to top left edge capacities (topleft(*,0)
249 * & topleft(0,*) must be 0)
250 * \param pTopRight Pointer to top right edge capacities (topright(*,0)
251 * & topright(width-1,*) must be 0)
252 * \param pBottom Pointer to bottom edge capacities (bottom(*,height-1)
254 * \param pBottomLeft Pointer to bottom left edge capacities
255 * (bottomleft(*,height-1) && bottomleft(0,*) must be 0)
256 * \param pBottomRight Pointer to bottom right edge capacities
257 * (bottomright(*,height-1) && bottomright(width-1,*) must be 0)
258 * \param nStep Step in bytes between any pair of sequential rows of edge
260 * \param nTransposedStep Step in bytes between any pair of sequential
261 * rows of tranposed edge capacities
262 * \param size Graph size
263 * \param pLabel Pointer to destination label image
264 * \param nLabelStep Step in bytes between any pair of sequential rows of
266 * \param pState Pointer to graph-cut state structure. This structure must be
267 * initialized allocated and initialized using nppiGraphcut8InitAlloc().
268 * \return \ref image_data_error_codes, \ref roi_error_codes
270 NppStatus nppiGraphcut8_32s8u(Npp32s * pTerminals, Npp32s * pLeftTransposed, Npp32s * pRightTransposed, Npp32s * pTop, Npp32s * pTopLeft, Npp32s * pTopRight, Npp32s * pBottom, Npp32s * pBottomLeft, Npp32s * pBottomRight, int nStep, int nTransposedStep, NppiSize size, Npp8u * pLabel, int nLabelStep, NppiGraphcutState *pState);
273 * Graphcut of a flow network (32bit float edge capacities). The
274 * function computes the minimal cut (graphcut) of a 2D regular 4-connected
276 * The inputs are the capacities of the horizontal (in transposed form),
277 * vertical and terminal (source and sink) edges. The capacities to source and
279 * are stored as capacity differences in the terminals array
280 * ( terminals(x) = source(x) - sink(x) ). The implementation assumes that the
282 * for boundary edges that would connect to nodes outside the specified domain
283 * are set to 0 (for example left(0,*) == 0). If this is not fulfilled the
284 * computed labeling may be wrong!
285 * The computed binary labeling is encoded as unsigned 8bit values (0 and >0).
287 * \see nppiGraphcutInitAlloc(), nppiGraphcutFree(), nppiGraphcutGetSize().
289 * \param pTerminals Pointer to differences of terminal edge capacities
290 * (terminal(x) = source(x) - sink(x))
291 * \param pLeftTransposed Pointer to transposed left edge capacities
292 * (left(0,*) must be 0)
293 * \param pRightTransposed Pointer to transposed right edge capacities
294 * (right(width-1,*) must be 0)
295 * \param pTop Pointer to top edge capacities (top(*,0) must be 0)
296 * \param pBottom Pointer to bottom edge capacities (bottom(*,height-1)
298 * \param nStep Step in bytes between any pair of sequential rows of edge
300 * \param nTransposedStep Step in bytes between any pair of sequential
301 * rows of tranposed edge capacities
302 * \param size Graph size
303 * \param pLabel Pointer to destination label image
304 * \param nLabelStep Step in bytes between any pair of sequential rows of
306 * \param pState Pointer to graph-cut state structure. This structure must be
307 * initialized allocated and initialized using nppiGraphcutInitAlloc().
308 * \return \ref image_data_error_codes, \ref roi_error_codes
310 NppStatus nppiGraphcut_32f8u(Npp32f * pTerminals, Npp32f * pLeftTransposed, Npp32f * pRightTransposed, Npp32f * pTop, Npp32f * pBottom, int nStep, int nTransposedStep, NppiSize size, Npp8u * pLabel, int nLabelStep, NppiGraphcutState *pState);
314 * Graphcut of a flow network (32bit float edge capacities). The
315 * function computes the minimal cut (graphcut) of a 2D regular 8-connected
317 * The inputs are the capacities of the horizontal (in transposed form),
318 * vertical and terminal (source and sink) edges. The capacities to source and
320 * are stored as capacity differences in the terminals array
321 * ( terminals(x) = source(x) - sink(x) ). The implementation assumes that the
323 * for boundary edges that would connect to nodes outside the specified domain
324 * are set to 0 (for example left(0,*) == 0). If this is not fulfilled the
325 * computed labeling may be wrong!
326 * The computed binary labeling is encoded as unsigned 8bit values (0 and >0).
328 * \see nppiGraphcut8InitAlloc(), nppiGraphcutFree(), nppiGraphcut8GetSize().
330 * \param pTerminals Pointer to differences of terminal edge capacities
331 * (terminal(x) = source(x) - sink(x))
332 * \param pLeftTransposed Pointer to transposed left edge capacities
333 * (left(0,*) must be 0)
334 * \param pRightTransposed Pointer to transposed right edge capacities
335 * (right(width-1,*) must be 0)
336 * \param pTop Pointer to top edge capacities (top(*,0) must be 0)
337 * \param pTopLeft Pointer to top left edge capacities (topleft(*,0)
338 * & topleft(0,*) must be 0)
339 * \param pTopRight Pointer to top right edge capacities (topright(*,0)
340 * & topright(width-1,*) must be 0)
341 * \param pBottom Pointer to bottom edge capacities (bottom(*,height-1)
343 * \param pBottomLeft Pointer to bottom left edge capacities
344 * (bottomleft(*,height-1) && bottomleft(0,*) must be 0)
345 * \param pBottomRight Pointer to bottom right edge capacities
346 * (bottomright(*,height-1) && bottomright(width-1,*) must be 0)
347 * \param nStep Step in bytes between any pair of sequential rows of edge
349 * \param nTransposedStep Step in bytes between any pair of sequential
350 * rows of tranposed edge capacities
351 * \param size Graph size
352 * \param pLabel Pointer to destination label image
353 * \param nLabelStep Step in bytes between any pair of sequential rows of
355 * \param pState Pointer to graph-cut state structure. This structure must be
356 * initialized allocated and initialized using nppiGraphcut8InitAlloc().
357 * \return \ref image_data_error_codes, \ref roi_error_codes
359 NppStatus nppiGraphcut8_32f8u(Npp32f * pTerminals, Npp32f * pLeftTransposed, Npp32f * pRightTransposed, Npp32f * pTop, Npp32f * pTopLeft, Npp32f * pTopRight, Npp32f * pBottom, Npp32f * pBottomLeft, Npp32f * pBottomRight, int nStep, int nTransposedStep, NppiSize size, Npp8u * pLabel, int nLabelStep, NppiGraphcutState *pState);
362 /** @} end of Graphcut */
364 /** @} image_graphcut */
366 /** @} image_labeling_and_segmentation */
372 #endif /* NV_NPPI_COMPUTER_VISION_H */