added complex convolution
This commit is contained in:
parent
4915fb0a83
commit
3145b7aed5
@ -30,6 +30,7 @@
|
|||||||
- added im_draw_point(), moved im_plotpoint() to deprecated
|
- added im_draw_point(), moved im_plotpoint() to deprecated
|
||||||
- added im_read_point(), now partial, moved im_readpoint() to deprecated
|
- added im_read_point(), now partial, moved im_readpoint() to deprecated
|
||||||
- added im_draw_smudge(), moved im_smudge() / im_smear() to deprecated
|
- added im_draw_smudge(), moved im_smudge() / im_smear() to deprecated
|
||||||
|
- convolution functions support complex images
|
||||||
|
|
||||||
12/5/10 started 7.22.2
|
12/5/10 started 7.22.2
|
||||||
- the conditional image of ifthenelse can be any format, a (!=0) is added if
|
- the conditional image of ifthenelse can be any format, a (!=0) is added if
|
||||||
|
4
TODO
4
TODO
@ -1,9 +1,5 @@
|
|||||||
- check gtk-doc output
|
- check gtk-doc output
|
||||||
|
|
||||||
- convsep / conv need to be able to do COMPLEX
|
|
||||||
|
|
||||||
just double the bands
|
|
||||||
|
|
||||||
- maybe im_draw_smudge() is too slow :-( also, we had a sanity failure with
|
- maybe im_draw_smudge() is too slow :-( also, we had a sanity failure with
|
||||||
it, argh
|
it, argh
|
||||||
|
|
||||||
|
@ -40,11 +40,6 @@
|
|||||||
#endif /*HAVE_CONFIG_H*/
|
#endif /*HAVE_CONFIG_H*/
|
||||||
#include <vips/intl.h>
|
#include <vips/intl.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
#ifdef WITH_DMALLOC
|
#ifdef WITH_DMALLOC
|
||||||
|
@ -53,6 +53,8 @@
|
|||||||
* - more cleanups
|
* - more cleanups
|
||||||
* 23/08/10
|
* 23/08/10
|
||||||
* - add a special case for 3x3 masks, about 20% faster
|
* - add a special case for 3x3 masks, about 20% faster
|
||||||
|
* 1/10/10
|
||||||
|
* - support complex (just double the bands)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -331,7 +333,8 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
int le = r->left;
|
int le = r->left;
|
||||||
int to = r->top;
|
int to = r->top;
|
||||||
int bo = IM_RECT_BOTTOM( r );
|
int bo = IM_RECT_BOTTOM( r );
|
||||||
int sz = IM_REGION_N_ELEMENTS( or );
|
int sz = IM_REGION_N_ELEMENTS( or ) *
|
||||||
|
(vips_bandfmt_iscomplex( in->BandFmt ) ? 2 : 1);
|
||||||
|
|
||||||
int x, y, z, i;
|
int x, y, z, i;
|
||||||
|
|
||||||
@ -394,10 +397,12 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IM_BANDFMT_FLOAT:
|
case IM_BANDFMT_FLOAT:
|
||||||
|
case IM_BANDFMT_COMPLEX:
|
||||||
CONV_FLOAT( float );
|
CONV_FLOAT( float );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IM_BANDFMT_DOUBLE:
|
case IM_BANDFMT_DOUBLE:
|
||||||
|
case IM_BANDFMT_DPCOMPLEX:
|
||||||
CONV_FLOAT( double );
|
CONV_FLOAT( double );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -497,7 +502,8 @@ conv3x3_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
int le = r->left;
|
int le = r->left;
|
||||||
int to = r->top;
|
int to = r->top;
|
||||||
int bo = IM_RECT_BOTTOM( r );
|
int bo = IM_RECT_BOTTOM( r );
|
||||||
int sz = IM_REGION_N_ELEMENTS( or );
|
int sz = IM_REGION_N_ELEMENTS( or ) *
|
||||||
|
(vips_bandfmt_iscomplex( in->BandFmt ) ? 2 : 1);
|
||||||
int bands = in->Bands;
|
int bands = in->Bands;
|
||||||
|
|
||||||
Rect s;
|
Rect s;
|
||||||
@ -545,10 +551,12 @@ conv3x3_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IM_BANDFMT_FLOAT:
|
case IM_BANDFMT_FLOAT:
|
||||||
|
case IM_BANDFMT_COMPLEX:
|
||||||
CONV3x3_FLOAT( float );
|
CONV3x3_FLOAT( float );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IM_BANDFMT_DOUBLE:
|
case IM_BANDFMT_DOUBLE:
|
||||||
|
case IM_BANDFMT_DPCOMPLEX:
|
||||||
CONV3x3_FLOAT( double );
|
CONV3x3_FLOAT( double );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -570,7 +578,6 @@ im_conv_raw( IMAGE *in, IMAGE *out, INTMASK *mask )
|
|||||||
*/
|
*/
|
||||||
if( im_piocheck( in, out ) ||
|
if( im_piocheck( in, out ) ||
|
||||||
im_check_uncoded( "im_conv", in ) ||
|
im_check_uncoded( "im_conv", in ) ||
|
||||||
im_check_noncomplex( "im_conv", in ) ||
|
|
||||||
im_check_imask( "im_conv", mask ) )
|
im_check_imask( "im_conv", mask ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( mask->scale == 0 ) {
|
if( mask->scale == 0 ) {
|
||||||
@ -617,8 +624,7 @@ im_conv_raw( IMAGE *in, IMAGE *out, INTMASK *mask )
|
|||||||
* @mask: convolution mask
|
* @mask: convolution mask
|
||||||
*
|
*
|
||||||
* Convolve @in with @mask using integer arithmetic. The output image
|
* Convolve @in with @mask using integer arithmetic. The output image
|
||||||
* always has the same #VipsBandFmt as the input image. Non-complex images
|
* always has the same #VipsBandFmt as the input image.
|
||||||
* only.
|
|
||||||
*
|
*
|
||||||
* Each output pixel is
|
* Each output pixel is
|
||||||
* calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
|
* calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
|
||||||
|
@ -31,11 +31,13 @@
|
|||||||
* - add restrict, though it doesn't seem to help gcc
|
* - add restrict, though it doesn't seem to help gcc
|
||||||
* - add mask-all-zero check
|
* - add mask-all-zero check
|
||||||
* 13/11/09
|
* 13/11/09
|
||||||
* - rename as im_conv_f() to make it easier to vips.c to make the
|
* - rename as im_conv_f() to make it easier for vips.c to make the
|
||||||
* overloaded version
|
* overloaded version
|
||||||
* 3/2/10
|
* 3/2/10
|
||||||
* - gtkdoc
|
* - gtkdoc
|
||||||
* - more cleanups
|
* - more cleanups
|
||||||
|
* 1/10/10
|
||||||
|
* - support complex (just double the bands)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -72,7 +74,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
@ -241,7 +242,8 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
int le = r->left;
|
int le = r->left;
|
||||||
int to = r->top;
|
int to = r->top;
|
||||||
int bo = IM_RECT_BOTTOM(r);
|
int bo = IM_RECT_BOTTOM(r);
|
||||||
int sz = IM_REGION_N_ELEMENTS( or );
|
int sz = IM_REGION_N_ELEMENTS( or ) *
|
||||||
|
(vips_bandfmt_iscomplex( in->BandFmt ) ? 2 : 1);
|
||||||
|
|
||||||
int x, y, z, i;
|
int x, y, z, i;
|
||||||
|
|
||||||
@ -292,12 +294,14 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
case IM_BANDFMT_INT:
|
case IM_BANDFMT_INT:
|
||||||
CONV_FLOAT( signed int, float ); break;
|
CONV_FLOAT( signed int, float ); break;
|
||||||
case IM_BANDFMT_FLOAT:
|
case IM_BANDFMT_FLOAT:
|
||||||
|
case IM_BANDFMT_COMPLEX:
|
||||||
CONV_FLOAT( float, float ); break;
|
CONV_FLOAT( float, float ); break;
|
||||||
case IM_BANDFMT_DOUBLE:
|
case IM_BANDFMT_DOUBLE:
|
||||||
|
case IM_BANDFMT_DPCOMPLEX:
|
||||||
CONV_FLOAT( double, double ); break;
|
CONV_FLOAT( double, double ); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert( 0 );
|
g_assert( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +317,6 @@ im_conv_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
|
|||||||
*/
|
*/
|
||||||
if( im_piocheck( in, out ) ||
|
if( im_piocheck( in, out ) ||
|
||||||
im_check_uncoded( "im_conv", in ) ||
|
im_check_uncoded( "im_conv", in ) ||
|
||||||
im_check_noncomplex( "im_conv", in ) ||
|
|
||||||
im_check_dmask( "im_conv", mask ) )
|
im_check_dmask( "im_conv", mask ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( mask->scale == 0 ) {
|
if( mask->scale == 0 ) {
|
||||||
@ -360,8 +363,7 @@ im_conv_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
|
|||||||
*
|
*
|
||||||
* Convolve @in with @mask using floating-point arithmetic. The output image
|
* Convolve @in with @mask using floating-point arithmetic. The output image
|
||||||
* is always %IM_BANDFMT_FLOAT unless @in is %IM_BANDFMT_DOUBLE, in which case
|
* is always %IM_BANDFMT_FLOAT unless @in is %IM_BANDFMT_DOUBLE, in which case
|
||||||
* @out is also %IM_BANDFMT_DOUBLE. Non-complex images
|
* @out is also %IM_BANDFMT_DOUBLE.
|
||||||
* only.
|
|
||||||
*
|
*
|
||||||
* Each output pixel is
|
* Each output pixel is
|
||||||
* calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
|
* calculated as sigma[i]{pixel[i] * mask[i]} / scale + offset, where scale
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
* 3/2/10
|
* 3/2/10
|
||||||
* - gtkdoc
|
* - gtkdoc
|
||||||
* - more cleanups
|
* - more cleanups
|
||||||
|
* 1/10/10
|
||||||
|
* - support complex (just double the bands)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -57,7 +59,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
@ -311,7 +312,8 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
int le = r->left;
|
int le = r->left;
|
||||||
int to = r->top;
|
int to = r->top;
|
||||||
int bo = IM_RECT_BOTTOM(r);
|
int bo = IM_RECT_BOTTOM(r);
|
||||||
int osz = IM_REGION_N_ELEMENTS( or );
|
int osz = IM_REGION_N_ELEMENTS( or ) *
|
||||||
|
(vips_bandfmt_iscomplex( in->BandFmt ) ? 2 : 1);
|
||||||
|
|
||||||
Rect s;
|
Rect s;
|
||||||
int lskip;
|
int lskip;
|
||||||
@ -350,14 +352,16 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
CONV_INT( signed int, IM_CLIP_NONE( sum, seq ) );
|
CONV_INT( signed int, IM_CLIP_NONE( sum, seq ) );
|
||||||
break;
|
break;
|
||||||
case IM_BANDFMT_FLOAT:
|
case IM_BANDFMT_FLOAT:
|
||||||
|
case IM_BANDFMT_COMPLEX:
|
||||||
CONV_FLOAT( float );
|
CONV_FLOAT( float );
|
||||||
break;
|
break;
|
||||||
case IM_BANDFMT_DOUBLE:
|
case IM_BANDFMT_DOUBLE:
|
||||||
|
case IM_BANDFMT_DPCOMPLEX:
|
||||||
CONV_FLOAT( double );
|
CONV_FLOAT( double );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert( 0 );
|
g_assert( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +377,6 @@ im_convsep_raw( IMAGE *in, IMAGE *out, INTMASK *mask )
|
|||||||
*/
|
*/
|
||||||
if( im_piocheck( in, out ) ||
|
if( im_piocheck( in, out ) ||
|
||||||
im_check_uncoded( "im_convsep", in ) ||
|
im_check_uncoded( "im_convsep", in ) ||
|
||||||
im_check_noncomplex( "im_convsep", in ) ||
|
|
||||||
im_check_imask( "im_convsep", mask ) )
|
im_check_imask( "im_convsep", mask ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( mask->xsize != 1 && mask->ysize != 1 ) {
|
if( mask->xsize != 1 && mask->ysize != 1 ) {
|
||||||
@ -423,8 +426,7 @@ im_convsep_raw( IMAGE *in, IMAGE *out, INTMASK *mask )
|
|||||||
*
|
*
|
||||||
* The mask must be 1xn or nx1 elements.
|
* The mask must be 1xn or nx1 elements.
|
||||||
* The output image
|
* The output image
|
||||||
* always has the same #VipsBandFmt as the input image. Non-complex images
|
* always has the same #VipsBandFmt as the input image.
|
||||||
* only.
|
|
||||||
*
|
*
|
||||||
* The image is convolved twice: once with @mask and then again with @mask
|
* The image is convolved twice: once with @mask and then again with @mask
|
||||||
* rotated by 90 degrees. This is much faster for certain types of mask
|
* rotated by 90 degrees. This is much faster for certain types of mask
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
* 3/2/10
|
* 3/2/10
|
||||||
* - gtkdoc
|
* - gtkdoc
|
||||||
* - more cleanups
|
* - more cleanups
|
||||||
|
* 1/10/10
|
||||||
|
* - support complex (just double the bands)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -50,7 +52,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
@ -223,7 +224,8 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
int le = r->left;
|
int le = r->left;
|
||||||
int to = r->top;
|
int to = r->top;
|
||||||
int bo = IM_RECT_BOTTOM(r);
|
int bo = IM_RECT_BOTTOM(r);
|
||||||
int osz = IM_REGION_N_ELEMENTS( or );
|
int osz = IM_REGION_N_ELEMENTS( or ) *
|
||||||
|
(vips_bandfmt_iscomplex( in->BandFmt ) ? 2 : 1);
|
||||||
|
|
||||||
Rect s;
|
Rect s;
|
||||||
int lskip;
|
int lskip;
|
||||||
@ -256,12 +258,14 @@ conv_gen( REGION *or, void *vseq, void *a, void *b )
|
|||||||
case IM_BANDFMT_INT:
|
case IM_BANDFMT_INT:
|
||||||
CONV_FLOAT( signed int, float ); break;
|
CONV_FLOAT( signed int, float ); break;
|
||||||
case IM_BANDFMT_FLOAT:
|
case IM_BANDFMT_FLOAT:
|
||||||
|
case IM_BANDFMT_COMPLEX:
|
||||||
CONV_FLOAT( float, float ); break;
|
CONV_FLOAT( float, float ); break;
|
||||||
case IM_BANDFMT_DOUBLE:
|
case IM_BANDFMT_DOUBLE:
|
||||||
|
case IM_BANDFMT_DPCOMPLEX:
|
||||||
CONV_FLOAT( double, double ); break;
|
CONV_FLOAT( double, double ); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert( 0 );
|
g_assert( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +281,6 @@ im_convsep_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
|
|||||||
*/
|
*/
|
||||||
if( im_piocheck( in, out ) ||
|
if( im_piocheck( in, out ) ||
|
||||||
im_check_uncoded( "im_convsep_f", in ) ||
|
im_check_uncoded( "im_convsep_f", in ) ||
|
||||||
im_check_noncomplex( "im_convsep_f", in ) ||
|
|
||||||
im_check_dmask( "im_convsep_f", mask ) )
|
im_check_dmask( "im_convsep_f", mask ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( mask->xsize != 1 && mask->ysize != 1 ) {
|
if( mask->xsize != 1 && mask->ysize != 1 ) {
|
||||||
@ -331,8 +334,7 @@ im_convsep_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
|
|||||||
* The mask must be 1xn or nx1 elements.
|
* The mask must be 1xn or nx1 elements.
|
||||||
* The output image
|
* The output image
|
||||||
* is always %IM_BANDFMT_FLOAT unless @in is %IM_BANDFMT_DOUBLE, in which case
|
* is always %IM_BANDFMT_FLOAT unless @in is %IM_BANDFMT_DOUBLE, in which case
|
||||||
* @out is also %IM_BANDFMT_DOUBLE. Non-complex images
|
* @out is also %IM_BANDFMT_DOUBLE.
|
||||||
* only.
|
|
||||||
*
|
*
|
||||||
* The image is convolved twice: once with @mask and then again with @mask
|
* The image is convolved twice: once with @mask and then again with @mask
|
||||||
* rotated by 90 degrees. This is much faster for certain types of mask
|
* rotated by 90 degrees. This is much faster for certain types of mask
|
||||||
|
Loading…
Reference in New Issue
Block a user