fix docs, don't wrap varargs in python
This commit is contained in:
parent
d9e9153300
commit
f250ebdded
4
TODO
4
TODO
@ -1,3 +1,7 @@
|
|||||||
|
- note new VMask constructor in docs
|
||||||
|
|
||||||
|
test new VMask constructor from python
|
||||||
|
|
||||||
- wrap meta() stuff in C++, we need it in py as well
|
- wrap meta() stuff in C++, we need it in py as well
|
||||||
|
|
||||||
need fred.get_int ("poop"); I think
|
need fred.get_int ("poop"); I think
|
||||||
|
@ -9,25 +9,41 @@ represent matricies of integers and doubles respectively.
|
|||||||
|
|
||||||
\subsection{Constructors}
|
\subsection{Constructors}
|
||||||
|
|
||||||
There are three constructors for \verb+VIMask+ and \verb+VDMask+:
|
There are four constructors for \verb+VIMask+ and \verb+VDMask+:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
VIMask( int xsize, int ysize );
|
VIMask( int xsize, int ysize );
|
||||||
VIMask( int xsize, int ysize,
|
VIMask( int xsize, int ysize,
|
||||||
int scale, int offset, ... );
|
int scale, int offset, ... );
|
||||||
|
VIMask( int xsize, int ysize,
|
||||||
|
int scale, int offset,
|
||||||
|
std::vector<int> coeff );
|
||||||
VIMask( const char *name );
|
VIMask( const char *name );
|
||||||
VIMask();
|
VIMask();
|
||||||
VDMask( int xsize, int ysize );
|
VDMask( int xsize, int ysize );
|
||||||
VDMask( int xsize, int ysize,
|
VDMask( int xsize, int ysize,
|
||||||
double scale, double offset, ... );
|
double scale, double offset, ... );
|
||||||
|
VDMask( int xsize, int ysize,
|
||||||
|
double scale, double offset,
|
||||||
|
std::vector<double> coeff );
|
||||||
VDMask( const char *name );
|
VDMask( const char *name );
|
||||||
VDMask();
|
VDMask();
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The first form creates an empty matrix, with the specified dimensions;
|
The first form creates an empty matrix, with the specified dimensions;
|
||||||
the second form initialises a matrix from a varargs list; the third form
|
the second form initialises a matrix from a varargs list; the third form
|
||||||
reads the matrix from the named file. The final form makes a mask object
|
sets the matrix from a vector of coefficients; the fourth from the named file.
|
||||||
with no contents yet.
|
The final form makes a mask object with no contents yet.
|
||||||
|
|
||||||
|
The varargs constructors are not wrapped in Python --- use the vector
|
||||||
|
constructor instead. For example:
|
||||||
|
|
||||||
|
\begin{verbatim}
|
||||||
|
m = VMask.VIMask (3, 3, 1, 0,
|
||||||
|
[-1, -1, -1,
|
||||||
|
-1, 8, -1,
|
||||||
|
-1, -1, -1])
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
\subsection{Projection functions}
|
\subsection{Projection functions}
|
||||||
|
|
||||||
|
@ -233,6 +233,9 @@ public:
|
|||||||
ref->pmask = new _private_detail::VPIMask( xsize, ysize );
|
ref->pmask = new _private_detail::VPIMask( xsize, ysize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Don't wrap the varargs constructor. We want Python to use the vector one.
|
||||||
|
*/
|
||||||
|
#ifndef SWIG
|
||||||
VIMask( int xsize, int ysize, int scale, int offset, ... )
|
VIMask( int xsize, int ysize, int scale, int offset, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -247,6 +250,7 @@ public:
|
|||||||
ref->pmask = new _private_detail::VPIMask( xsize, ysize,
|
ref->pmask = new _private_detail::VPIMask( xsize, ysize,
|
||||||
scale, offset, coeff );
|
scale, offset, coeff );
|
||||||
}
|
}
|
||||||
|
#endif /*!SWIG*/
|
||||||
|
|
||||||
VIMask( int xsize, int ysize, int scale, int offset,
|
VIMask( int xsize, int ysize, int scale, int offset,
|
||||||
std::vector<int> coeff )
|
std::vector<int> coeff )
|
||||||
@ -318,6 +322,9 @@ public:
|
|||||||
ref->pmask = new _private_detail::VPDMask( xsize, ysize );
|
ref->pmask = new _private_detail::VPDMask( xsize, ysize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Don't wrap the varargs constructor. We want Python to use the vector one.
|
||||||
|
*/
|
||||||
|
#ifndef SWIG
|
||||||
VDMask( int xsize, int ysize, double scale, double offset, ... )
|
VDMask( int xsize, int ysize, double scale, double offset, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -332,6 +339,7 @@ public:
|
|||||||
ref->pmask = new _private_detail::VPDMask( xsize, ysize,
|
ref->pmask = new _private_detail::VPDMask( xsize, ysize,
|
||||||
scale, offset, coeff );
|
scale, offset, coeff );
|
||||||
}
|
}
|
||||||
|
#endif /*!SWIG*/
|
||||||
|
|
||||||
VDMask( int xsize, int ysize, double scale, double offset,
|
VDMask( int xsize, int ysize, double scale, double offset,
|
||||||
std::vector<double> coeff )
|
std::vector<double> coeff )
|
||||||
|
@ -169,13 +169,15 @@ _private_detail::VPIMask::VPIMask( int xsize, int ysize,
|
|||||||
int scale, int offset, std::vector<int> coeff )
|
int scale, int offset, std::vector<int> coeff )
|
||||||
throw( VError )
|
throw( VError )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if( !(data.iptr = im_create_imask( "VPIMask::VPIMask", xsize, ysize )) )
|
if( !(data.iptr = im_create_imask( "VPIMask::VPIMask", xsize, ysize )) )
|
||||||
verror();
|
verror();
|
||||||
type = _private_detail::VPMask::INT;
|
type = _private_detail::VPMask::INT;
|
||||||
|
|
||||||
data.iptr->scale = scale;
|
data.iptr->scale = scale;
|
||||||
data.iptr->offset = offset;
|
data.iptr->offset = offset;
|
||||||
for( int i = 0; i < xsize * ysize; i++ )
|
for( i = 0; i < xsize * ysize; i++ )
|
||||||
data.iptr->coeff[i] = coeff[i];
|
data.iptr->coeff[i] = coeff[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,13 +316,15 @@ _private_detail::VPDMask::VPDMask( int xsize, int ysize ) throw( VError )
|
|||||||
_private_detail::VPDMask::VPDMask( int xsize, int ysize,
|
_private_detail::VPDMask::VPDMask( int xsize, int ysize,
|
||||||
double scale, double offset, std::vector<double> coeff ) throw( VError )
|
double scale, double offset, std::vector<double> coeff ) throw( VError )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if( !(data.dptr = im_create_dmask( "VPDMask::VPDMask", xsize, ysize )) )
|
if( !(data.dptr = im_create_dmask( "VPDMask::VPDMask", xsize, ysize )) )
|
||||||
verror();
|
verror();
|
||||||
type = _private_detail::VPMask::DOUBLE;
|
type = _private_detail::VPMask::DOUBLE;
|
||||||
|
|
||||||
data.dptr->scale = scale;
|
data.dptr->scale = scale;
|
||||||
data.dptr->offset = offset;
|
data.dptr->offset = offset;
|
||||||
for( int i = 0; i < xsize * ysize; i++ )
|
for( i = 0; i < xsize * ysize; i++ )
|
||||||
data.dptr->coeff[i] = coeff[i];
|
data.dptr->coeff[i] = coeff[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,12 @@ try:
|
|||||||
a = VImage.VImage (sys.argv[1])
|
a = VImage.VImage (sys.argv[1])
|
||||||
b = a.invert ()
|
b = a.invert ()
|
||||||
c = b.lin ([1,2,3],[4,5,6])
|
c = b.lin ([1,2,3],[4,5,6])
|
||||||
c.write (sys.argv[2])
|
m = VMask.VIMask (3, 3, 1, 0,
|
||||||
|
[-1, -1, -1,
|
||||||
|
-1, 8, -1,
|
||||||
|
-1, -1, -1])
|
||||||
|
d = a.conv (m)
|
||||||
|
d.write (sys.argv[2])
|
||||||
except VError.VError, e:
|
except VError.VError, e:
|
||||||
e.perror (sys.argv[0])
|
e.perror (sys.argv[0])
|
||||||
|
|
||||||
@ -27,6 +32,8 @@ print 'starting shutdown ...'
|
|||||||
del b
|
del b
|
||||||
del a
|
del a
|
||||||
del c
|
del c
|
||||||
|
del d
|
||||||
|
del m
|
||||||
# sometimes have to do several GCs to get them all, not sure why
|
# sometimes have to do several GCs to get them all, not sure why
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
gc.collect ()
|
gc.collect ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user