BRL-CAD
crop.h
Go to the documentation of this file.
1/* C R O P . 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_crop
21 *
22 * @brief
23 * Functions for cropping images.
24 *
25 * There are currently two types of cropping: rectangular and skewed.
26 *
27 */
28
29#ifndef ICV_CROP_H
30#define ICV_CROP_H
31
32#include "common.h"
33#include <stddef.h> /* for size_t */
34#include "icv/defines.h"
35
36__BEGIN_DECLS
37
38/** @{ */
39/** @file icv/crop.h */
40
41/**
42 * This function crops an input image.
43 * Note : (0,0) corresponds to the Bottom Left of an Image.
44 *
45 * @param img Input image struct to be cropped.
46 * @param xorig X-Coordinate of offset of image to be extracted from.
47 * @param yorig Y-Coordinate of offset of image to be extracted from.
48 * @param xnum Length of the output image to be extracted from input
49 * data in horizontal direction.
50 * @param ynum Length of the output image to be extracted from input
51 * data in vertical direction.
52 * @return 0 on success.
53 */
54ICV_EXPORT extern int icv_rect(icv_image_t *img, size_t xorig, size_t yorig, size_t xnum, size_t ynum);
55
56/**
57 * This function crops an input image.
58 *
59 * This can do a skewed cropping, i.e. given any four points of
60 * quadrilateral in an image, map it to a rectangle of xnumXynum
61 * dimension.
62 *
63 * @verbatim
64 * (ulx,uly) (urx,ury)
65 * __________________
66 * / |
67 * / |
68 * / |
69 * / |
70 * / |
71 * /______________________|
72 * (llx,lly) (lrx,lry)
73 * @endverbatim
74 *
75 * @return 0 on success; on failure -1; and logs the error message.
76 */
77ICV_EXPORT extern int icv_crop(icv_image_t *img,
78 size_t ulx, size_t uly,
79 size_t urx, size_t ury,
80 size_t lrx, size_t lry,
81 size_t llx, size_t lly,
82 size_t ynum,
83 size_t xnum);
84/** @} */
85
86__END_DECLS
87
88#endif /* ICV_CROP_H */
89
90/*
91 * Local Variables:
92 * tab-width: 8
93 * mode: C
94 * indent-tabs-mode: t
95 * c-file-style: "stroustrup"
96 * End:
97 * ex: shiftwidth=4 tabstop=8
98 */
Header file for the BRL-CAD common definitions.
int icv_rect(icv_image_t *img, size_t xorig, size_t yorig, size_t xnum, size_t ynum)
int icv_crop(icv_image_t *img, size_t ulx, size_t uly, size_t urx, size_t ury, size_t lrx, size_t lry, size_t llx, size_t lly, size_t ynum, size_t xnum)