iceWing
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
image.h
Go to the documentation of this file.
1 /* -*- mode: C; tab-width: 4; c-basic-offset: 4; -*- */
2 
3 /*
4  * Author: Frank Loemker
5  *
6  * Copyright (C) 1999-2009
7  * Frank Loemker, Applied Computer Science, Faculty of Technology,
8  * Bielefeld University, Germany
9  *
10  * This file is part of iceWing, a graphical plugin shell.
11  *
12  * iceWing is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * iceWing is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25  */
26 
27 #ifndef iw_image_H
28 #define iw_image_H
29 
30 #include "gui/Gimage.h"
31 #include "gui/Grender.h"
32 #include "tools/tools.h"
33 
34 typedef void (*imgLineFunc) (iwImage *img, uchar *y, uchar *u, uchar *v,
35  int cnt, void *data);
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*********************************************************************
42  Return a pointer to an internal intermediate buffer. If the buffer
43  is smaller than size bytes, the buffer is reallocated.
44  Calls to iw_img_get_buffer() can be nested. iw_img_release_buffer()
45  must be called if the buffer is not needed any more.
46 *********************************************************************/
47 void* iw_img_get_buffer (int size);
48 
49 /*********************************************************************
50  Release the buffer requested with iw_img_get_buffer().
51 *********************************************************************/
52 void iw_img_release_buffer (void);
53 
54 /*********************************************************************
55  Output color of image s at position (x,y) to stderr. If s has 3
56  planes result of prev_yuvToRgbVis() is given additionally.
57 *********************************************************************/
58 void iw_img_col_debug (const char *str, const iwImage *s, int x, int y);
59 
60 /*********************************************************************
61  Downsample source by factor (downw,downh) and put it to dest.
62  dest->data is freed and newly allocated if the size or the type
63  of source has changed. Supports IW_8U - IW_DOUBLE.
64 *********************************************************************/
65 void iw_img_downsample (const iwImage *source, iwImage *dest,
66  int downw, int downh);
67 
68 /*********************************************************************
69  Resize image srcPR to size of image dstPR and save it in dstPR.
70  interpolate==TRUE: Use linear interpolation.
71 *********************************************************************/
72 void iw_img_resize (const iwImage *srcPR, iwImage *destPR, BOOL interpolate);
73 
74 /*********************************************************************
75  Resize image src (size: src_w x src_h with 'planes' planes)
76  to size dst_w x dst_h and save it in dst.
77  interpolate==TRUE: Use linear interpolation.
78 *********************************************************************/
79 void iw_img_resize_raw (const uchar** src, uchar** dst,
80  int src_w, int src_h, int dst_w, int dst_h,
81  int planes, BOOL interpolate);
82 
83 /*********************************************************************
84  Set border of size border in image src to 0.
85 *********************************************************************/
86 void iw_img_border (uchar *src, int width, int height, int border);
87 
88 /*********************************************************************
89  Copy border of width border from src to dest.
90 *********************************************************************/
91 void iw_img_copy_border (const uchar *src, uchar *dest,
92  int width, int height, int border);
93 
94 /*********************************************************************
95  Put median smoothed image (mask size: size*2+1) from s to d.
96 *********************************************************************/
97 void iw_img_median (const uchar *s, uchar *d,
98  int width, int height, int size);
99 
100 /*********************************************************************
101  Put median smoothed image (mask size: size*2+1) from s to d.
102  s is only tested on >0 (-> BLACK/WHITE).
103 *********************************************************************/
104 void iw_img_medianBW (const uchar *s, uchar *d,
105  int width, int height, int size);
106 
107 /*********************************************************************
108  Put smoothed image (mask size: size*2+1, center of mask gets color
109  which occurs most frequently) from s to d.
110 *********************************************************************/
111 void iw_img_max (const uchar *s, uchar *d,
112  int width, int height, int size);
113 
114 /*********************************************************************
115  Histogram equalize src and put it to dest.
116 *********************************************************************/
117 void iw_img_histeq (const uchar *src, uchar *dest, int width, int height);
118 
119 /*********************************************************************
120  Contrast autostretch src and put it to dest.
121  Ignore the first min_limit % and the last max_limit % pixels.
122 *********************************************************************/
123 void iw_img_cstretch (const uchar *src, uchar *dest, int width, int height,
124  int min_limit, int max_limit);
125 
126 /*********************************************************************
127  Apply a sobel filter in x and y direction to src and save |dx|+|dy|
128  to dest. If thresh>0 threshold dest.
129  A border of one pixel is copied unchanged.
130 *********************************************************************/
131 void iw_img_sobel (const uchar *src, uchar *dest,
132  int width, int height, int thresh);
133 
134 /*********************************************************************
135  Perform RGB to YUV conversion with intervall reduction.
136  Supports IW_8U - IW_DOUBLE.
137 *********************************************************************/
138 void iw_img_rgbToYuvVis (iwImage *img);
139 
140 /*********************************************************************
141  Perform YUV to RGB conversion with intervall expansion.
142  Supports IW_8U - IW_DOUBLE.
143 *********************************************************************/
144 void iw_img_yuvToRgbVis (iwImage *img);
145 
146 /*********************************************************************
147  Convert an interleaved image 'src' to a planed one and vice versa.
148  Save the result in the newly allocated image 'dst'. If dst is NULL,
149  additionally allocate a new image structure. Returns dst.
150  Supports IW_8U - IW_DOUBLE.
151 *********************************************************************/
152 iwImage *iw_img_convert_layout (const iwImage *src, iwImage *dst);
153 
154 /*********************************************************************
155  count: number of points , ptsIn: the points
156  invers==FALSE: Fill the polygon defined by the points ptsIn.
157  invers==TRUE: Fill everything except the polygon.
158  fkt!=NULL: fkt() is called (instead of changing the image directly.
159  fkt==NULL: The polygon (or the inverse) is filled,
160  data!=NULL: data defines the color to use.
161 *********************************************************************/
162 BOOL iw_img_fillPoly (iwImage *img, int count, const prevDataPoint *ptsIn,
163  BOOL invers, imgLineFunc fkt, void *data);
164 BOOL iw_img_fillPoly_raw (uchar **s, int width, int height, int planes,
165  const Polygon_t *p, BOOL invers,
166  imgLineFunc fkt, void *data);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif /* iw_image_H */