开元周游
德国频道
楼主: loveless
打印 上一主题 下一主题

做实习遇到的问题

[复制链接]
11#
 楼主| 发表于 17.6.2006 16:19:24 | 只看该作者
Mex-Setup是在命令行里输入吗?<br />
回复 支持 反对

使用道具 举报

12#
 楼主| 发表于 17.6.2006 16:19:51 | 只看该作者
&gt;&gt; Mex-Setup<br />Warning: Could not find an exact (case-sensitive) match for &#39;Mex&#39;. C:\rogram Files\MATLAB704\toolbox\matlab\general\mex.m is a case-insensitive match and will be used instead.  You can improve the performance of your code by using exact name matches and we therefore recommend that you update your usage accordingly.  Alternatively, you can disable this warning using warning(&#39;off&#39;,&#39;MATLAB:dispatcher:InexactMatch&#39;).<br /> <br />Select a compiler: <br />[1] Lcc C version 2.4 in C:\ROGRAM FILES\MATLAB704\sys\lcc <br /> <br />[0] None <br /> <br />Compiler: 1<br /> <br />Try to update options file: C:\Documents and Settings\JuliusWoo\Application Data\MathWorks\MATLAB\R14\mexopts.bat <br />From template:              C:\ROGRAM FILES\MATLAB704\BIN\WIN32\mexopts\lccopts.bat <br /> <br />Done . . . <br /> <br />    Usage: <br />        MEX [option1 ... optionN] sourcefile1 [... sourcefileN] <br />            [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN] <br /> <br />      or (to build an Ada S-function): <br />        MEX [-v] [-g] -ada &lt;sfcn&gt;.ads <br /> <br />    Use the -help option for more information, or consult the MATLAB API Guide. <br /> <br /> <br />  C:\ROGRAM FILES\MATLAB704\BIN\WIN32\MEX.PL: Error: No file names given. <br /> <br />??? Undefined function or variable &#39;Setup&#39;.<br />
回复 支持 反对

使用道具 举报

13#
 楼主| 发表于 17.6.2006 16:23:48 | 只看该作者
<!--QuoteBegin-eisenstange+17.06.2006, 16:21 --><div class='quotetop'>QUOTE(eisenstange @ 17.06.2006, 16:21 )</div><div class='quotemain'><!--QuoteEBegin-->可能是你的C编译器没有装好,你的机器上用的是什么编译器? VC还是GCC?<br />[right][snapback]1008958[/snapback][/right]<br /><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br />我也不清楚,这个是怎么看?
回复 支持 反对

使用道具 举报

14#
 楼主| 发表于 17.6.2006 16:25:13 | 只看该作者
是不是直接把C代码,粘贴在下面。就是运行了Mex-Setup后的命令行下面?
回复 支持 反对

使用道具 举报

15#
 楼主| 发表于 17.6.2006 16:31:20 | 只看该作者
// Onur G. Guleryuz 1995, 1996, 1997,<br />// University of Illinois at Urbana-Champaign,<br />// Princeton University,<br />// Polytechnic University.<br /><br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &quot;wav_filters_extern.h&quot;<br />#include &quot;wav_gen.h&quot;<br />#include &quot;alloc.h&quot;<br /><br />// Extend data by ofs pixels on both ends using periodic <br />// symmetry. data should be &quot;pointing in&quot; to allow up to data[-ofs]<br />// and data[N-1+ofs]. <br />// ofs&gt;=N is handled.<br /><br />void extend_periodic(float *data,int N,int ofs)<br /><br />{<br />        int i,k;<br /><br />        k=N-1;<br />        for(i=1;i&lt;=ofs;i++) {<br /><br />                data[-i]=data[N-i];<br />                data[k+i]=data[i-1];<br />        }<br />}<br /><br />// Extend data by ofs pixels on both ends using mirror <br />// symmetry. data should be &quot;pointing in&quot; to allow up to data[-ofs]<br />// and data[N-1+ofs]. <br />//<br />// There are two possible &quot;mirrors&quot;, i.e., data[-1]=data[1] (mirror on 0) <br />// or data[-1]=data[0] (mirror &quot;between&quot; -1 and 0). phase is either 0, 1, or 2<br />// to select among these cases. See if(phase==... below.        <br />        <br />void extend_mirror(float *data,int N,int ofs,int phase)<br /><br />{<br />        int i,k;<br />        int phase1,phase2;<br /><br />        if((phase&lt;0)||(phase&gt;2)) {<br /><br />                printf(&quot;extend_mirror: illegal phase\n&quot;);<br />                exit(1);<br />        }<br /><br />        if(phase==2){<br />                // At left boundary the mirror is on 0.<br />                phase1=0;<br /><br />                // At right boundary the mirror is on N-1.<br />                phase2=1;<br />        }<br />        else {<br /><br />                // phase==0, at left mirror on 0, and at right it&#39;s between.<br />                // phase==1, at left mirror between, and at right it&#39;s on N-1.<br />                phase1=phase2=phase;<br />        }<br /><br />        k=N-1;<br />                <br />        if(N==1) {<br /><br />                for(i=1;i&lt;=ofs;i++) {<br /><br />                        data[-i]=data[0];<br />                        data[k+i]=data[0];<br />                }<br />        }<br />        else<br />                for(i=1;i&lt;=ofs;i++) {<br /><br />                        data[-i]=data[i-phase1];<br />                        data[k+i]=data[N-phase2-i];<br />                }<br />}<br /><br />// This routine is used in evaluating forward wavelet transforms.<br />//<br />// data of dimension N contains the input.<br />// float *filter contains the Nf filter taps.<br />// ofs is the decimation factor.<br />//<br />// filtering starts at beg and continues until N+beg, yielding N/ofs samples. <br />// data needs to be padded suitably at both ends.<br />// This hoopla about the starting point is in place to ensure <br />// correct boundary processing when evaluating wavelet transforms.<br />//<br />// coef returns the result of the filtering and decimation.<br />// <br />// Viewed as a transform the basis function that generates the<br />// coefficient of index 0 is &quot;&lt;- fliplr(filter) -&gt; (beg)&quot;, <br />// i.e., the scalar product obtained by positioning <br />// the flipped filter (formed into a row vector) <br />// with the right side positioned on top of sample beg in data.<br /><br />int filter_n_decimate(float *data,float *coef,int N,float *filter,<br />                                                int Nf,int beg,int ofs)<br /><br />{<br />        int i,j,k;<br />        float temp;<br /><br />        k=0;<br />        for(i=beg;i&lt;N+beg;i+=ofs) {<br /><br />                temp=0;<br />                for(j=i;j&gt;i-Nf;j--)<br />                        temp+=data[j]*filter[i-j];<br /><br />                coef[k]=temp;<br />                k++;<br />        }<br /><br />        return(k);<br />}<br /><br />// This routine is used in evaluating inverse wavelet transforms.<br />//<br />// Upsample and filter to implement a synthesis filter bank.<br />// Basically the inverse of filter_n_decimate() above.<br />// No actual upsampling etc., to avoid zero multiplies.<br />//<br />// coef is the input and contains coefficients resulting from <br />// filtering and decimation by ofs. <br />//<br />// Because this routine is typically called twice for inverse wavelet<br />// transforms, once for the low band and once for high, data is incremented via +=.<br />// Hence data should initially be set to 0.<br />//<br />// Viewed as a transform, filter_n_decimate above starts by putting the <br />// &quot;flipped&quot; forward filter at begf, i.e.,  &lt;- fliplr(ffilter) -&gt;(begf)<br />// The resulting coefficient is at index 0.<br />// Here we are upsampling by ofs and filtering with the inv. filter<br />// time advanced by fbeg so the coefficient at index 0, multiplies the basis function<br />// (-fbeg)&lt;-(ifilter)-&gt;(Nf-1-fbeg=beg).<br />// <br />// How is that for confusing? All of this makes sense,<br />// when you write it down carefully. But who has the time ...<!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--><br /><br />void upsample_n_filter(float *coef,float *data,int N,float *filter,<br />                                                int Nf,int beg,int ofs)<br /><br />{<br />        int i,j,l,n,p,fbeg;<br />        float temp;<br /><br />        fbeg=Nf-beg-1;<br /><br />        for(i=0;i&lt;N;i++) {<br /><br />                l=0;<br />                n=(i+fbeg)%ofs;<br />                p=(i+fbeg)/ofs;<br /><br />                temp=0;<br />                for(j=n;j&lt;Nf;j+=ofs) {<br /><br />                        temp+=coef[p-l]*filter[j];<br />                        l++;<br />                }<br /><br />                // += for successive calls for low and high bands. <br />                data+=temp;<br />        }<br />}<br /><br />// Used in forward wavelet trf.<br />//<br />// All rows of the image are run through the dual filterbank<br />// given by lp and hp. Results are returned in image &quot;in place&quot;.<br />// low freq. coefficients start at 0 and end at N/2, where high freq.<br />// info starts.<br />void filt_n_dec_all_rows(float **image,int Ni,int Nj,float *lp,int Nl,<br />                                                        float *hp,int Nh)<br /><br />{<br />        int i,j,ext,ofs;<br />        float *data;<br /><br />        ext=max(Nl,Nh);<br />        data=allocate_1d_float((Nj+2*ext),0);<br />        // Point in for required extensions.<br />        data+=ext;<br /><br />        // offset for the location where high band coefficients<br />        // should be copied.<br />        ofs=Nj&gt;&gt;1;<br /><br />        for(i=0;i&lt;Ni;i++) {<br />                <br />                // Copy row.<br />                for(j=0;j&lt;Nj;j++)<br />                        data[j]=image[j];<br /><br />                // Extend.<br />                if(PS)<br />                        extend_periodic(data,Nj,ext);<br />                else {<br />                        // Mirrors at end points.<br />                        extend_mirror(data,Nj,ext,2);<br />                }<br /><br />                filter_n_decimate(data,image,Nj,lp,Nl,begflp,2);<br />                filter_n_decimate(data,image+ofs,Nj,hp,Nh,begfhp,2);<br />                }<br /><br />        data-=ext;<br />        free((void *)data);<br />        }<br /><br />// Used in forward wavelet trf.<br />//<br />// Index swapped version of filt_n_dec_all_rows.<br />void filt_n_dec_all_cols(float **image,int Ni,int Nj,float *lp,int Nl,<br />                                                        float *hp,int Nh)<br /><br />{<br />        int i,j,ext,ofs;<br />        float *data,*data2;<br /><br />        ext=max(Nl,Nh);<br />        data=allocate_1d_float((Ni+2*ext),0);<br />        // Point in for required extensions.<br />        data+=ext;<br /><br />        // Need second array since cannot access columns directly via pointers.<br />        data2=allocate_1d_float(Ni,0);<br /><br />        // offset for the location where high band coefficients<br />        // should be copied.<br />        ofs=Ni&gt;&gt;1;<br /><br />        for(j=0;j&lt;Nj;j++) {<br />                <br />                // Copy column.<br />                for(i=0;i&lt;Ni;i++)<br />                        data=image[j];<br /><br />                // Extend.<br />                if(PS)<br />                        extend_periodic(data,Ni,ext);<br />                else {<br />                        // Mirrors at end points.<br />                        extend_mirror(data,Ni,ext,2);<br />                }<br /><br />                filter_n_decimate(data,data2,Ni,lp,Nl,begflp,2);<br />                filter_n_decimate(data,data2+ofs,Ni,hp,Nh,begfhp,2);<br /><br />                for(i=0;i&lt;Ni;i++)<br />                        image[j]=data2;<br />                }<br /><br />        data-=ext;<br />        free((void *)data);<br />        free((void *)data2);<br />        }<br /><br />// Used in inverse wavelet trf.<br />//<br />// All rows of the image are run through the dual synthesis filterbank<br />// given by lp and hp having number of taps Nl and Nh respectively. <br />// Results are returned in image &quot;in place&quot;.<br />//<br />// Here we actaully need to know the applied shift to the transform,<br />// hence the passed parameters lev and shift_arr.<br /><br />void ups_n_filt_all_rows(float **image,int Ni,int Nj,float *lp,int Nl,<br />                                                        float *hp,int Nh,int lev,int *shift_arr)<br /><br />{<br />        int i,j,k,ext,ofs;<br />        float *data1,*data2;<br /><br />        ext=max(Nl,Nh);<br />        ofs=Nj&gt;&gt;1;<br /><br />        data1=allocate_1d_float((ofs+2*ext),0);<br />        data2=allocate_1d_float((ofs+2*ext),0);<br />        data1+=ext;data2+=ext;<br /><br />        for(i=0;i&lt;Ni;i++) {        <br /><br />                for(j=0;j&lt;ofs;j++) {<br /><br />                        k=j+ofs;<br />                        // low pass and high pass coefficients.<br />                        data1[j]=image[j];image[j]=0;<br />                        data2[j]=image[k];image[k]=0;<br />                }<br /><br />                // Take care of the extension at the boundaries.<br />                if(PS) {<br /><br />                        extend_periodic(data1,ofs,ext);        <br />                        extend_periodic(data2,ofs,ext);        <br />                }<br />                else {<br /><br />                        // shift_arr[lev]=0 OR 1.<br />                        // The symmetric banks used are positioned so that on the left side<br />                        // the forward lowpass filter has its point of symmetry exactly on top of 0<br />                        // and forward high pass filter has its point of symmetry exactly on top of 1. <br />                        // This is coordinated by calling filter_n_decimate() with the proper value of beg.<br />                        //<br />                        // The above is reversed at the right side assuming decimation by 2. <br />                        // Hence shift_arr[lev]==0 =&gt; at left boundary the mirror is at 0, <br />                        // at right boundary it&#39;s between, see extend_mirror().<br /><br />                        // If shift_arr[lev]==1 then the positions for the low and high are reversed<br />                        // since the filters are shifted so if<br />                        // shift_arr[lev]==1 =&gt; at left boundary the mirror is between, <br />                        // at right boundary it&#39;s at 0.<br />                        extend_mirror(data1,ofs,ext,shift_arr[lev]);        <br />                        extend_mirror(data2,ofs,ext,1-shift_arr[lev]);        <br />                }<br /><br />                // invert low pass.<br />                upsample_n_filter(data1,image,Nj,lp,Nl,begilp,2);<br />                // invert high pass.<br />                upsample_n_filter(data2,image,Nj,hp,Nh,begihp,2);<br />        }<br /><br />        data1-=ext;data2-=ext;<br />        free((void *)data1);<br />        free((void *)data2);<br />}<br /><br />// Used in inverse wavelet trf.<br />//<br />// Index swapped version of ups_n_filt_all_rows.<br />void ups_n_filt_all_cols(float **image,int Ni,int Nj,float *lp,int Nl,<br />                                                        float *hp,int Nh,int lev,int *shift_arr)<br /><br />{<br />        int i,j,k,ext,ofs;<br />        float *data1,*data2,*data3;<br /><br />        ext=max(Nl,Nh);<br />        ofs=Ni&gt;&gt;1;<br /><br />        data1=allocate_1d_float((ofs+2*ext),0);<br />        data2=allocate_1d_float((ofs+2*ext),0);<br />        data1+=ext;data2+=ext;<br /><br />        // Need third array since cannot access columns directly via pointers.<br />        data3=allocate_1d_float(Ni,0);<br /><br />        for(j=0;j&lt;Nj;j++) {        <br /><br />                for(i=0;i&lt;ofs;i++) {<br /><br />                        k=i+ofs;<br />                        // low pass and high pass coefficients.<br />                        data1=image[j];<br />                        data2=image[k][j];<br />                        data3=data3[k]=0;<br />                }<br /><br />                if(PS) {<br /><br />                        extend_periodic(data1,ofs,ext);        <br />                        extend_periodic(data2,ofs,ext);        <br />                }<br />                else {<br /><br />                        extend_mirror(data1,ofs,ext,shift_arr[lev]);        <br />                        extend_mirror(data2,ofs,ext,1-shift_arr[lev]);        <br />                }<br /><br />                upsample_n_filter(data1,data3,Ni,lp,Nl,begilp,2);<br />                upsample_n_filter(data2,data3,Ni,hp,Nh,begihp,2);<br /><br />                for(i=0;i&lt;Ni;i++)<br />                        image[j]=data3;<br />        }<br /><br />        data1-=ext;data2-=ext;<br />        free((void *)data1);<br />        free((void *)data2);<br />        free((void *)data3);<br />}<br />
回复 支持 反对

使用道具 举报

16#
 楼主| 发表于 17.6.2006 16:33:12 | 只看该作者
以上的是Wavelet Basic的C代码。是不是把#Include &lt;mex.h&gt;<br /><br />放在// Polytechnic University.<br /><br />#include &lt;stdio.h&gt; 之间?<br /><br />这个源代码本身已经包含了很多的Include,该怎么处理呢?<br />
回复 支持 反对

使用道具 举报

17#
 楼主| 发表于 17.6.2006 16:37:31 | 只看该作者
mex wav_basic.c<br />wav_basic.obj .text: undefined reference to &#39;_allocate_1d_float&#39; <br />wav_basic.obj .text: undefined reference to &#39;_PS&#39; <br />wav_basic.obj .text: undefined reference to &#39;_begflp&#39; <br />wav_basic.obj .text: undefined reference to &#39;_begfhp&#39; <br />wav_basic.obj .text: undefined reference to &#39;_begilp&#39; <br />wav_basic.obj .text: undefined reference to &#39;_begihp&#39; <br />Specified export _mexFunction is not defined <br />Missing exports. Aborting <br /> <br />  C:\ROGRAM FILES\MATLAB704\BIN\WIN32\MEX.PL: Error: Link of &#39;wav_basic.dll&#39; failed. <br /> <br />??? Error using ==&gt; mex<br />Unable to complete successfully<br />
回复 支持 反对

使用道具 举报

18#
 楼主| 发表于 17.6.2006 16:38:39 | 只看该作者
<!--QuoteBegin-loveless+17.06.2006, 16:31 --><div class='quotetop'>QUOTE(loveless @ 17.06.2006, 16:31 )</div><div class='quotemain'><!--QuoteEBegin-->// Onur G. Guleryuz 1995, 1996, 1997,<br />// University of Illinois at Urbana-Champaign,<br />// Princeton University,<br />// Polytechnic University.<br /><br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &quot;wav_filters_extern.h&quot;<br />#include &quot;wav_gen.h&quot;<br />#include &quot;alloc.h&quot;<br /><br />// Extend data by ofs pixels on both ends using periodic <br />// symmetry. data should be &quot;pointing in&quot; to allow up to data[-ofs]<br />// and data[N-1+ofs]. <br />// ofs&gt;=N is handled.<br /><br />void extend_periodic(float *data,int N,int ofs)<br /><br />{<br />        int i,k;<br /><br />        k=N-1;<br />        for(i=1;i&lt;=ofs;i++) {<br /><br />&nbsp; data[-i]=data[N-i];<br />&nbsp; data[k+i]=data[i-1];<br />        }<br />}<br /><br />// Extend data by ofs pixels on both ends using mirror <br />// symmetry. data should be &quot;pointing in&quot; to allow up to data[-ofs]<br />// and data[N-1+ofs]. <br />//<br />// There are two possible &quot;mirrors&quot;, i.e., data[-1]=data[1] (mirror on 0) <br />// or data[-1]=data[0] (mirror &quot;between&quot; -1 and 0). phase is either 0, 1, or 2<br />// to select among these cases. See if(phase==... below.        <br />        <br />void extend_mirror(float *data,int N,int ofs,int phase)<br /><br />{<br />        int i,k;<br />        int phase1,phase2;<br /><br />        if((phase&lt;0)||(phase&gt;2)) {<br /><br />&nbsp; printf(&quot;extend_mirror: illegal phase\n&quot;);<br />&nbsp; exit(1);<br />        }<br /><br />        if(phase==2){<br />&nbsp; // At left boundary the mirror is on 0.<br />&nbsp; phase1=0;<br /><br />&nbsp; // At right boundary the mirror is on N-1.<br />&nbsp; phase2=1;<br />        }<br />        else {<br /><br />&nbsp; // phase==0, at left mirror on 0, and at right it&#39;s between.<br />&nbsp; // phase==1, at left mirror between, and at right it&#39;s on N-1.<br />&nbsp; phase1=phase2=phase;<br />        }<br /><br />        k=N-1;<br />&nbsp; <br />        if(N==1) {<br /><br />&nbsp; for(i=1;i&lt;=ofs;i++) {<br /><br />&nbsp;         data[-i]=data[0];<br />&nbsp;         data[k+i]=data[0];<br />&nbsp; }<br />        }<br />        else<br />&nbsp; for(i=1;i&lt;=ofs;i++) {<br /><br />&nbsp;         data[-i]=data[i-phase1];<br />&nbsp;         data[k+i]=data[N-phase2-i];<br />&nbsp; }<br />}<br /><br />// This routine is used in evaluating forward wavelet transforms.<br />//<br />// data of dimension N contains the input.<br />// float *filter contains the Nf filter taps.<br />// ofs is the decimation factor.<br />//<br />// filtering starts at beg and continues until N+beg, yielding N/ofs samples. <br />// data needs to be padded suitably at both ends.<br />// This hoopla about the starting point is in place to ensure <br />// correct boundary processing when evaluating wavelet transforms.<br />//<br />// coef returns the result of the filtering and decimation.<br />// <br />// Viewed as a transform the basis function that generates the<br />// coefficient of index 0 is &quot;&lt;- fliplr(filter) -&gt; (beg)&quot;, <br />// i.e., the scalar product obtained by positioning <br />// the flipped filter (formed into a row vector) <br />// with the right side positioned on top of sample beg in data.<br /><br />int filter_n_decimate(float *data,float *coef,int N,float *filter,<br />&nbsp; &nbsp; &nbsp; int Nf,int beg,int ofs)<br /><br />{<br />        int i,j,k;<br />        float temp;<br /><br />        k=0;<br />        for(i=beg;i&lt;N+beg;i+=ofs) {<br /><br />&nbsp; temp=0;<br />&nbsp; for(j=i;j&gt;i-Nf;j--)<br />&nbsp;         temp+=data[j]*filter[i-j];<br /><br />&nbsp; coef[k]=temp;<br />&nbsp; k++;<br />        }<br /><br />        return(k);<br />}<br /><br />// This routine is used in evaluating inverse wavelet transforms.<br />//<br />// Upsample and filter to implement a synthesis filter bank.<br />// Basically the inverse of filter_n_decimate() above.<br />// No actual upsampling etc., to avoid zero multiplies.<br />//<br />// coef is the input and contains coefficients resulting from <br />// filtering and decimation by ofs. <br />//<br />// Because this routine is typically called twice for inverse wavelet<br />// transforms, once for the low band and once for high, data is incremented via +=.<br />// Hence data should initially be set to 0.<br />//<br />// Viewed as a transform, filter_n_decimate above starts by putting the <br />// &quot;flipped&quot; forward filter at begf, i.e.,&nbsp; &lt;- fliplr(ffilter) -&gt;(begf)<br />// The resulting coefficient is at index 0.<br />// Here we are upsampling by ofs and filtering with the inv. filter<br />// time advanced by fbeg so the coefficient at index 0, multiplies the basis function<br />// (-fbeg)&lt;-(ifilter)-&gt;(Nf-1-fbeg=beg).<br />// <br />// How is that for confusing? All of this makes sense,<br />// when you write it down carefully. But who has the time ...<!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--><br /><br />void upsample_n_filter(float *coef,float *data,int N,float *filter,<br />&nbsp; &nbsp; &nbsp; int Nf,int beg,int ofs)<br /><br />{<br />        int i,j,l,n,p,fbeg;<br />        float temp;<br /><br />        fbeg=Nf-beg-1;<br /><br />        for(i=0;i&lt;N;i++) {<br /><br />&nbsp; l=0;<br />&nbsp; n=(i+fbeg)%ofs;<br />&nbsp; p=(i+fbeg)/ofs;<br /><br />&nbsp; temp=0;<br />&nbsp; for(j=n;j&lt;Nf;j+=ofs) {<br /><br />&nbsp;         temp+=coef[p-l]*filter[j];<br />&nbsp;         l++;<br />&nbsp; }<br /><br />&nbsp; // += for successive calls for low and high bands. <br />&nbsp; data+=temp;<br />        }<br />}<br /><br />// Used in forward wavelet trf.<br />//<br />// All rows of the image are run through the dual filterbank<br />// given by lp and hp. Results are returned in image &quot;in place&quot;.<br />// low freq. coefficients start at 0 and end at N/2, where high freq.<br />// info starts.<br />void filt_n_dec_all_rows(float **image,int Ni,int Nj,float *lp,int Nl,<br />&nbsp; &nbsp; &nbsp;         float *hp,int Nh)<br /><br />{<br />        int i,j,ext,ofs;<br />        float *data;<br /><br />        ext=max(Nl,Nh);<br />        data=allocate_1d_float((Nj+2*ext),0);<br />        // Point in for required extensions.<br />        data+=ext;<br /><br />        // offset for the location where high band coefficients<br />        // should be copied.<br />        ofs=Nj&gt;&gt;1;<br /><br />        for(i=0;i&lt;Ni;i++) {<br />&nbsp; <br />&nbsp; // Copy row.<br />&nbsp; for(j=0;j&lt;Nj;j++)<br />&nbsp;         data[j]=image[j];<br /><br />&nbsp; // Extend.<br />&nbsp; if(PS)<br />&nbsp;         extend_periodic(data,Nj,ext);<br />&nbsp; else {<br />&nbsp;         // Mirrors at end points.<br />&nbsp;         extend_mirror(data,Nj,ext,2);<br />&nbsp; }<br /><br />&nbsp; filter_n_decimate(data,image,Nj,lp,Nl,begflp,2);<br />&nbsp; filter_n_decimate(data,image+ofs,Nj,hp,Nh,begfhp,2);<br />&nbsp; }<br /><br />        data-=ext;<br />        free((void *)data);<br />        }<br /><br />// Used in forward wavelet trf.<br />//<br />// Index swapped version of filt_n_dec_all_rows.<br />void filt_n_dec_all_cols(float **image,int Ni,int Nj,float *lp,int Nl,<br />&nbsp; &nbsp; &nbsp;         float *hp,int Nh)<br /><br />{<br />        int i,j,ext,ofs;<br />        float *data,*data2;<br /><br />        ext=max(Nl,Nh);<br />        data=allocate_1d_float((Ni+2*ext),0);<br />        // Point in for required extensions.<br />        data+=ext;<br /><br />        // Need second array since cannot access columns directly via pointers.<br />        data2=allocate_1d_float(Ni,0);<br /><br />        // offset for the location where high band coefficients<br />        // should be copied.<br />        ofs=Ni&gt;&gt;1;<br /><br />        for(j=0;j&lt;Nj;j++) {<br />&nbsp; <br />&nbsp; // Copy column.<br />&nbsp; for(i=0;i&lt;Ni;i++)<br />&nbsp;         data=image[j];<br /><br />&nbsp; // Extend.<br />&nbsp; if(PS)<br />&nbsp;         extend_periodic(data,Ni,ext);<br />&nbsp; else {<br />&nbsp;         // Mirrors at end points.<br />&nbsp;         extend_mirror(data,Ni,ext,2);<br />&nbsp; }<br /><br />&nbsp; filter_n_decimate(data,data2,Ni,lp,Nl,begflp,2);<br />&nbsp; filter_n_decimate(data,data2+ofs,Ni,hp,Nh,begfhp,2);<br /><br />&nbsp; for(i=0;i&lt;Ni;i++)<br />&nbsp;         image[j]=data2;<br />&nbsp; }<br /><br />        data-=ext;<br />        free((void *)data);<br />        free((void *)data2);<br />        }<br /><br />// Used in inverse wavelet trf.<br />//<br />// All rows of the image are run through the dual synthesis filterbank<br />// given by lp and hp having number of taps Nl and Nh respectively. <br />// Results are returned in image &quot;in place&quot;.<br />//<br />// Here we actaully need to know the applied shift to the transform,<br />// hence the passed parameters lev and shift_arr.<br /><br />void ups_n_filt_all_rows(float **image,int Ni,int Nj,float *lp,int Nl,<br />&nbsp; &nbsp; &nbsp;         float *hp,int Nh,int lev,int *shift_arr)<br /><br />{<br />        int i,j,k,ext,ofs;<br />        float *data1,*data2;<br /><br />        ext=max(Nl,Nh);<br />        ofs=Nj&gt;&gt;1;<br /><br />        data1=allocate_1d_float((ofs+2*ext),0);<br />        data2=allocate_1d_float((ofs+2*ext),0);<br />        data1+=ext;data2+=ext;<br /><br />        for(i=0;i&lt;Ni;i++) {        <br /><br />&nbsp; for(j=0;j&lt;ofs;j++) {<br /><br />&nbsp;         k=j+ofs;<br />&nbsp;         // low pass and high pass coefficients.<br />&nbsp;         data1[j]=image[j];image[j]=0;<br />&nbsp;         data2[j]=image[k];image[k]=0;<br />&nbsp; }<br /><br />&nbsp; // Take care of the extension at the boundaries.<br />&nbsp; if(PS) {<br /><br />&nbsp;         extend_periodic(data1,ofs,ext);        <br />&nbsp;         extend_periodic(data2,ofs,ext);        <br />&nbsp; }<br />&nbsp; else {<br /><br />&nbsp;         // shift_arr[lev]=0 OR 1.<br />&nbsp;         // The symmetric banks used are positioned so that on the left side<br />&nbsp;         // the forward lowpass filter has its point of symmetry exactly on top of 0<br />&nbsp;         // and forward high pass filter has its point of symmetry exactly on top of 1. <br />&nbsp;         // This is coordinated by calling filter_n_decimate() with the proper value of beg.<br />&nbsp;         //<br />&nbsp;         // The above is reversed at the right side assuming decimation by 2. <br />&nbsp;         // Hence shift_arr[lev]==0 =&gt; at left boundary the mirror is at 0, <br />&nbsp;         // at right boundary it&#39;s between, see extend_mirror().<br /><br />&nbsp;         // If shift_arr[lev]==1 then the positions for the low and high are reversed<br />&nbsp;         // since the filters are shifted so if<br />&nbsp;         // shift_arr[lev]==1 =&gt; at left boundary the mirror is between, <br />&nbsp;         // at right boundary it&#39;s at 0.<br />&nbsp;         extend_mirror(data1,ofs,ext,shift_arr[lev]);        <br />&nbsp;         extend_mirror(data2,ofs,ext,1-shift_arr[lev]);        <br />&nbsp; }<br /><br />&nbsp; // invert low pass.<br />&nbsp; upsample_n_filter(data1,image,Nj,lp,Nl,begilp,2);<br />&nbsp; // invert high pass.<br />&nbsp; upsample_n_filter(data2,image,Nj,hp,Nh,begihp,2);<br />        }<br /><br />        data1-=ext;data2-=ext;<br />        free((void *)data1);<br />        free((void *)data2);<br />}<br /><br />// Used in inverse wavelet trf.<br />//<br />// Index swapped version of ups_n_filt_all_rows.<br />void ups_n_filt_all_cols(float **image,int Ni,int Nj,float *lp,int Nl,<br />&nbsp; &nbsp; &nbsp;         float *hp,int Nh,int lev,int *shift_arr)<br /><br />{<br />        int i,j,k,ext,ofs;<br />        float *data1,*data2,*data3;<br /><br />        ext=max(Nl,Nh);<br />        ofs=Ni&gt;&gt;1;<br /><br />        data1=allocate_1d_float((ofs+2*ext),0);<br />        data2=allocate_1d_float((ofs+2*ext),0);<br />        data1+=ext;data2+=ext;<br /><br />        // Need third array since cannot access columns directly via pointers.<br />        data3=allocate_1d_float(Ni,0);<br /><br />        for(j=0;j&lt;Nj;j++) {        <br /><br />&nbsp; for(i=0;i&lt;ofs;i++) {<br /><br />&nbsp;         k=i+ofs;<br />&nbsp;         // low pass and high pass coefficients.<br />&nbsp;         data1=image[j];<br />&nbsp;         data2=image[k][j];<br />&nbsp;         data3=data3[k]=0;<br />&nbsp; }<br /><br />&nbsp; if(PS) {<br /><br />&nbsp;         extend_periodic(data1,ofs,ext);        <br />&nbsp;         extend_periodic(data2,ofs,ext);        <br />&nbsp; }<br />&nbsp; else {<br /><br />&nbsp;         extend_mirror(data1,ofs,ext,shift_arr[lev]);        <br />&nbsp;         extend_mirror(data2,ofs,ext,1-shift_arr[lev]);        <br />&nbsp; }<br /><br />&nbsp; upsample_n_filter(data1,data3,Ni,lp,Nl,begilp,2);<br />&nbsp; upsample_n_filter(data2,data3,Ni,hp,Nh,begihp,2);<br /><br />&nbsp; for(i=0;i&lt;Ni;i++)<br />&nbsp;         image[j]=data3;<br />        }<br /><br />        data1-=ext;data2-=ext;<br />        free((void *)data1);<br />        free((void *)data2);<br />        free((void *)data3);<br />}<br />[right][snapback]1008971[/snapback][/right]<br /><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />我其实只需要Wavelet变换的代码。以上的是不是太多了?<br />
回复 支持 反对

使用道具 举报

19#
 楼主| 发表于 17.6.2006 17:09:46 | 只看该作者
那我该怎么办啊?我把东西都给你,你给我看看行吗?
回复 支持 反对

使用道具 举报

20#
 楼主| 发表于 17.6.2006 17:31:30 | 只看该作者
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

站点信息

站点统计| 举报| Archiver| 手机版| 小黑屋

Powered by Discuz! X3.2 © 2001-2014 Comsenz Inc.

GMT+1, 21.11.2024 18:57

关于我们|Apps

() 开元网

快速回复 返回顶部 返回列表