File Coverage

lib/PDL/Image2D.xs
Criterion Covered Total %
statement 38 54 70.3
branch 99 278 35.6
condition n/a
subroutine n/a
pod n/a
total 137 332 41.2


line stmt bran cond sub pod time code
1              
2             #line 453 "lib/PDL/PP.pm"
3             /*
4             * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Image2D.pd! Do not modify!
5             */
6              
7             #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8             if (destroy) { \
9             comp_free_code \
10             } \
11             if ((trans)->dims_redone) { \
12             ntpriv_free_code \
13             }
14              
15             #include "EXTERN.h"
16             #include "perl.h"
17             #include "XSUB.h"
18             #include "pdl.h"
19             #include "pdlcore.h"
20             #define PDL PDL_Image2D
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "lib/PDL/Image2D.xs"
23             pdl_error pdl_run_polyfill_pp(pdl *im,pdl *ps,pdl *col);
24             pdl_error pdl_run_pnpoly_pp(pdl *a,pdl *ps,pdl *msk);
25             pdl_error pdl_run_pnpolyfill_pp(pdl *a,pdl *ps,pdl *col);
26              
27              
28             /* Fast Modulus with proper negative behaviour */
29              
30             #define REALMOD(a,b) {while ((a)>=(b)) (a) -= (b); while ((a)<0) (a) += (b);}
31              
32             #define X(symbol, ctype, ppsym, ...) \
33             ctype quick_select_ ## ppsym(ctype arr[], int n);
34             PDL_TYPELIST_REAL(X)
35             #undef X
36             pdl_error pdl_run_conv2d(pdl *a,pdl *kern,pdl *b,int opt);
37             pdl_error pdl_run_med2d(pdl *a,pdl *kern,pdl *b,int opt);
38             pdl_error pdl_run_med2df(pdl *a,pdl *b,IV p_size,IV q_size,int opt);
39             #define EZ(x) ez ? 0 : (x)
40             pdl_error pdl_run_box2d(pdl *a,pdl *b,int wx,int wy,int edgezero);
41             pdl_error pdl_run_patch2d(pdl *a,pdl *bad,pdl *b);
42             pdl_error pdl_run_patchbad2d(pdl *a,pdl *b);
43             pdl_error pdl_run_max2d_ind(pdl *a,pdl *val,pdl *x,pdl *y);
44             pdl_error pdl_run_centroid2d(pdl *im,pdl *x,pdl *y,pdl *box,pdl *xcen,pdl *ycen);
45             pdl_error pdl_run_ccNcompt(pdl *a,pdl *b,int con);
46             int getnewsize(PDL_Indx cols, PDL_Indx rows, float fangle, PDL_Indx *newcols, PDL_Indx *newrows);
47             typedef unsigned char imT; /* image type */
48             int rotate(imT *im, imT *out, int cols, int rows, int nc, int nr,
49             float fangle, imT bgval, int antialias);
50             pdl_error pdl_run_rot2d(pdl *im,pdl *angle,pdl *bg,pdl *aa,pdl *om);
51             pdl_error pdl_run_bilin2d(pdl *Int,pdl *O);
52             pdl_error pdl_run_rescale2d(pdl *Int,pdl *O);
53             #include "resample.h"
54             pdl_error pdl_run_warp2d(pdl *img,pdl *px,pdl *py,pdl *warp,char *kernel_type,double noval,IV nsamples);
55             pdl_error pdl_run_warp2d_kernel(pdl *x,pdl *k,char *name,PDL_Indx nsize);
56              
57             #line 449 "lib/PDL/PP.pm"
58             #include "pdlperl.h"
59             #line 60 "lib/PDL/Image2D.xs"
60              
61             Core* PDL = NULL; /* Structure hold core C functions */
62              
63             MODULE = PDL::Image2D PACKAGE = PDL PREFIX=pdl_run_
64              
65             PROTOTYPES: DISABLE
66              
67              
68             void
69             pdl_run_polyfill_pp(im, ps, col)
70             pdl *im
71             pdl *ps
72             pdl *col
73             PPCODE:
74 2           PDL->barf_if_error(pdl_run_polyfill_pp(im,ps,col));
75              
76             void
77             pdl_run_pnpoly_pp(a, ps, msk=PDL_XS_PERLINIT_initsv(msk_SV))
78             SV *msk_SV = items > 2 ? ST(2) : NULL;
79             PREINIT:
80 2 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
81             INPUT:
82             pdl *a
83             pdl *ps
84             pdl *msk
85             PPCODE:
86 2           PDL->barf_if_error(pdl_run_pnpoly_pp(a,ps,msk));
87 2 50         PDL_XS_RETURN(ST(0) = msk_SV)
    50          
    50          
    50          
    0          
88              
89             void
90             pdl_run_pnpolyfill_pp(a, ps, col)
91             pdl *a
92             pdl *ps
93             pdl *col
94             PPCODE:
95 1           PDL->barf_if_error(pdl_run_pnpolyfill_pp(a,ps,col));
96              
97             void
98             _conv2d_int(a,kern,b,opt)
99             pdl *a
100             pdl *kern
101             pdl *b
102             int opt
103             CODE:
104 12           PDL->barf_if_error(pdl_run_conv2d(a,kern,b,opt));
105              
106             void
107             _med2d_int(a,kern,b,opt)
108             pdl *a
109             pdl *kern
110             pdl *b
111             int opt
112             CODE:
113 2           PDL->barf_if_error(pdl_run_med2d(a,kern,b,opt));
114              
115             void
116             _med2df_int(a,b,p_size,q_size,opt)
117             pdl *a
118             pdl *b
119             IV p_size
120             IV q_size
121             int opt
122             CODE:
123 1           PDL->barf_if_error(pdl_run_med2df(a,b,p_size,q_size,opt));
124              
125             void
126             pdl_run_box2d(a, b=b, wx=wx, wy=wy, edgezero=edgezero)
127             SV *b_SV = (items == 5) ? ST(1) : NULL;
128             SV *wx_SV = (items == 5) ? ST(2) : ST(1);
129             SV *wy_SV = (items == 5) ? ST(3) : ST(2);
130             SV *edgezero_SV = (items == 5) ? ST(4) : ST(3);
131             PREINIT:
132 2 50         PDL_XS_PREAMBLE((items == 5) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
133 2 50         if (!((items == 4) || (items == 5)))
    0          
134 0           croak("Usage: PDL::box2d(a,[b],wx,wy,edgezero) (you may leave [outputs] and values with =defaults out of list)");
135             INPUT:
136             pdl *a
137             pdl *b=NO_INIT
138             int wx; { wx = (int)SvIV(wx_SV); }
139             int wy; { wy = (int)SvIV(wy_SV); }
140             int edgezero; { edgezero = (int)SvIV(edgezero_SV); }
141             PPCODE:
142 2 50         if (b_SV) { b = PDL_CORE_(SvPDLV)(b_SV); } else b = PDL_XS_PERLINIT_initsv(b_SV);
    50          
143 2           PDL->barf_if_error(pdl_run_box2d(a,b,wx,wy,edgezero));
144 2 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
145              
146             void
147             pdl_run_patch2d(a, bad, b=PDL_XS_PERLINIT_initsv(b_SV))
148             SV *b_SV = items > 2 ? ST(2) : NULL;
149             PREINIT:
150 3 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
151             INPUT:
152             pdl *a
153             pdl *bad
154             pdl *b
155             PPCODE:
156 3           PDL->barf_if_error(pdl_run_patch2d(a,bad,b));
157 3 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
158              
159             void
160             pdl_run_patchbad2d(a, b=PDL_XS_PERLINIT_initsv(b_SV))
161             SV *b_SV = items > 1 ? ST(1) : NULL;
162             PREINIT:
163 2 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
164             INPUT:
165             pdl *a
166             pdl *b
167             PPCODE:
168 2           PDL->barf_if_error(pdl_run_patchbad2d(a,b));
169 2 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
170              
171             void
172             pdl_run_max2d_ind(a, val=PDL_XS_PERLINIT_initsv(val_SV), x=PDL_XS_PERLINIT_initsv(x_SV), y=PDL_XS_PERLINIT_initsv(y_SV))
173             SV *val_SV = items > 1 ? ST(1) : NULL;
174             SV *x_SV = items > 2 ? ST(2) : NULL;
175             SV *y_SV = items > 3 ? ST(3) : NULL;
176             PREINIT:
177 2 50         PDL_XS_PREAMBLE((items == 4) ? 0 : 3);
    50          
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
178             INPUT:
179             pdl *a
180             pdl *val
181             pdl *x
182             pdl *y
183             PPCODE:
184 2           PDL->barf_if_error(pdl_run_max2d_ind(a,val,x,y));
185 2 50         PDL_XS_RETURN(ST(0) = val_SV;ST(1) = x_SV;ST(2) = y_SV)
    50          
    50          
    50          
    0          
186              
187             void
188             pdl_run_centroid2d(im, x, y, box, xcen=PDL_XS_PERLINIT_initsv(xcen_SV), ycen=PDL_XS_PERLINIT_initsv(ycen_SV))
189             SV *xcen_SV = items > 4 ? ST(4) : NULL;
190             SV *ycen_SV = items > 5 ? ST(5) : NULL;
191             PREINIT:
192 2 50         PDL_XS_PREAMBLE((items == 6) ? 0 : 2);
    50          
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
193             INPUT:
194             pdl *im
195             pdl *x
196             pdl *y
197             pdl *box
198             pdl *xcen
199             pdl *ycen
200             PPCODE:
201 2           PDL->barf_if_error(pdl_run_centroid2d(im,x,y,box,xcen,ycen));
202 2 50         PDL_XS_RETURN(ST(0) = xcen_SV;ST(1) = ycen_SV)
    50          
    50          
    50          
    0          
203              
204             void
205             pdl_run_ccNcompt(a, b=b, con=con)
206             SV *b_SV = (items == 3) ? ST(1) : NULL;
207             SV *con_SV = (items == 3) ? ST(2) : ST(1);
208             PREINIT:
209 6 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
210 6 50         if (!((items == 2) || (items == 3)))
    0          
211 0           croak("Usage: PDL::ccNcompt(a,[b],con) (you may leave [outputs] and values with =defaults out of list)");
212             INPUT:
213             pdl *a
214             pdl *b=NO_INIT
215             int con; { con = (int)SvIV(con_SV); }
216             PPCODE:
217 6 50         if (b_SV) { b = PDL_CORE_(SvPDLV)(b_SV); } else b = PDL_XS_PERLINIT_initsv(b_SV);
    50          
218 6           PDL->barf_if_error(pdl_run_ccNcompt(a,b,con));
219 5 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
220              
221             MODULE = PDL::Image2D PACKAGE = PDL::Image2D
222              
223              
224              
225             void
226             rotnewsz(m,n,angle)
227             int m
228             int n
229             float angle
230             PPCODE:
231             PDL_Indx newcols, newrows;
232              
233 0 0         if (getnewsize(m,n,angle,&newcols,&newrows) != 0)
234 0           croak("wrong angle (should be between -90 and +90)");
235 0 0         EXTEND(sp,2);
236 0           PUSHs(sv_2mortal(newSVnv(newcols)));
237 0           PUSHs(sv_2mortal(newSVnv(newrows)));
238              
239             MODULE = PDL::Image2D PACKAGE = PDL PREFIX=pdl_run_
240              
241              
242             void
243             pdl_run_rot2d(im, angle, bg, aa, om=PDL_XS_PERLINIT_initsv(om_SV))
244             SV *om_SV = items > 4 ? ST(4) : NULL;
245             PREINIT:
246 0 0         PDL_XS_PREAMBLE((items == 5) ? 0 : 1);
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
247             INPUT:
248             pdl *im
249             pdl *angle
250             pdl *bg
251             pdl *aa
252             pdl *om
253             PPCODE:
254 0           PDL->barf_if_error(pdl_run_rot2d(im,angle,bg,aa,om));
255 0 0         PDL_XS_RETURN(ST(0) = om_SV)
    0          
    0          
    0          
    0          
256              
257             void
258             pdl_run_bilin2d(Int, O)
259             pdl *Int
260             pdl *O
261             PPCODE:
262 0           PDL->barf_if_error(pdl_run_bilin2d(Int,O));
263              
264             void
265             pdl_run_rescale2d(Int, O)
266             pdl *Int
267             pdl *O
268             PPCODE:
269 0           PDL->barf_if_error(pdl_run_rescale2d(Int,O));
270              
271             void
272             _warp2d_int(img,px,py,warp,kernel_type,noval,nsamples)
273             pdl *img
274             pdl *px
275             pdl *py
276             pdl *warp
277             char *kernel_type
278             double noval
279             IV nsamples
280             CODE:
281 6           PDL->barf_if_error(pdl_run_warp2d(img,px,py,warp,kernel_type,noval,nsamples));
282              
283             MODULE = PDL::Image2D PACKAGE = PDL::Image2D
284              
285              
286              
287             int
288             _get_kernel_size()
289             PROTOTYPE:
290             CODE:
291 6 100         RETVAL = KERNEL_SAMPLES;
292             OUTPUT:
293             RETVAL
294              
295              
296             MODULE = PDL::Image2D PACKAGE = PDL PREFIX=pdl_run_
297              
298              
299             void
300             _warp2d_kernel_int(x,k,name,nsize)
301             pdl *x
302             pdl *k
303             char *name
304             PDL_Indx nsize
305             CODE:
306 0           PDL->barf_if_error(pdl_run_warp2d_kernel(x,k,name,nsize));
307              
308              
309             #line 483 "lib/PDL/PP.pm"
310             BOOT:
311             /* Get pointer to structure of core shared C routines */
312             /* make sure PDL::Core is loaded */
313             #line 314 "lib/PDL/Image2D.xs"
314 1           perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */
315             #ifndef aTHX_
316             #define aTHX_
317             #endif
318 1 50         if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV));
    50          
    0          
319 1           SV* CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* var with core structure */
320 1 50         if (!CoreSV)
321 0           Perl_croak(aTHX_ "We require the PDL::Core module, which was not found");
322 1 50         if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */
323 0           Perl_croak(aTHX_ "Got NULL pointer for PDL");
324 1 50         if (PDL->Version != PDL_CORE_VERSION)
325 0           Perl_croak(aTHX_ "[PDL->Version: %ld PDL_CORE_VERSION: %ld XS_VERSION: %s] PDL::Image2D needs to be recompiled against the newly installed PDL", (long int)PDL->Version, (long int)PDL_CORE_VERSION, XS_VERSION);