c++ - Unhandled exception at std::length_error at memory location 0x002ff5dc -


im new in opencv code

 #include <opencv2/imgproc/imgproc.hpp>     #include <opencv2/highgui/highgui.hpp>  #include <iostream>  #include <fstream> #include <vector> #include <string> #include <complex> #include <cmath> #include <algorithm> #include "wavelet2d.h" #include "opencv/cv.h" #include "opencv/highgui.h" #include "opencv/cxcore.h"  using namespace std; using namespace cv;  void* maxval(vector<vector<double> > &arr, double &max){     max = 0;     (unsigned int =0; < arr.size(); i++) {         (unsigned int j =0; j < arr[0].size(); j++) {             if (max <= arr[i][j]){                 max = arr[i][j];             }         }     }     return 0; }  void* maxval1(vector<double> &arr, double &max){     max = 0;     (unsigned int =0; < arr.size(); i++) {         if (max <= arr[i]){             max = arr[i];         }      }     return 0; }   int main() {     iplimage* img = cvloadimage("apple.jpg");     if (!img){         cout << " can't read image. try different format." << endl;         exit(1);     }     int height, width;     height = img->height;     width = img->width;     int nc = img->nchannels;     //   uchar* ptr2 =(uchar*) img->imagedata;     int pix_depth = img->depth;     cvsize size;     size.width =width;     size.height=height;     cout << "depth" << pix_depth <<  "channels" << nc << endl;       cvnamedwindow("original image", cv_window_autosize);     cvshowimage("original image", img);     cvwaitkey();     cvdestroywindow("original image");     cvsaveimage("orig.bmp",img);       int rows =(int) height;     int cols =(int) width;     mat matimg(img);      vector<vector<double> > vec1(rows, vector<double>(cols));       int k =1;     (int i=0; < rows; i++) {         (int j =0; j < cols; j++){             unsigned char temp;             temp = ((uchar*) matimg.data + * matimg.step)[j  * matimg.elemsize() + k ];             vec1[i][j] = (double) temp;         }      }      string nm = "db3";     vector<double> l1,h1,l2,h2;     filtcoef(nm,l1,h1,l2,h2);     // unsigned int lf=l1.size();     //  int rows_n =(int) (rows+ j*(lf-1));     //  int cols_n =(int)  (cols + j * ( lf -1));      // finding 2d dwt transform of image using symetric extension algorithm     // extension set 3 (eg., int e = 3)      vector<int> length;     vector<double> output,flag;     int j =3;     dwt_2d_sym(vec1,j,nm,output,flag,length);      double max;     vector<int> length2;     // algorithm computes dwt of image of given size. convolution ,     // subsampling operations clear subsampled images of different length     // dyadic length images. in order compute "effective" size of dwt additional     // calculations.     dwt_output_dim_sym(length,length2,j);     // length2 gives integer vector contains size of subimages     // combine form displayed output image. last 2 entries of length2 gives     // size of dwt ( rows_n cols_n)      int siz = length2.size();     int rows_n=length2[siz-2];     int cols_n = length2[siz-1];      vector<vector< double> > dwtdisp(rows_n, vector<double>(cols_n));     dispdwt(output,dwtdisp, length ,length2, j);      // dispdwt returns 2d object dwtdisp displayed using opencv's image     // handling functions      vector<vector<double> >  dwt_output= dwtdisp;      maxval(dwt_output,max);// max value needed take care of overflow happens because     // of convolution operations performed on unsigned 8 bit images      //displaying scaled image     // creating image in opencv     iplimage *cvimg; // image used output     cvsize imgsize; // size of output image      imgsize.width = cols_n;     imgsize.height = rows_n;      cvimg = cvcreateimage( imgsize, 8, 1 );     // dwt_hold created hold dwt output further operations need     // carried out on dwt_output in order display scaled images.     vector<vector<double> > dwt_hold(rows_n, vector<double>( cols_n));     dwt_hold = dwt_output;     // setting coefficients of created image scaled dwt output values     (int = 0; < imgsize.height; i++ ) {         (int j = 0; j < imgsize.width; j++ ){             if ( dwt_output[i][j] <= 0.0){                 dwt_output[i][j] = 0.0;             }             if ( <= (length2[0]) && j <= (length2[1]) ) {                 ((uchar*)(cvimg->imagedata + cvimg->widthstep*i))[j] =                         (char) ( (dwt_output[i][j] / max) * 255.0);             } else {                 ((uchar*)(cvimg->imagedata + cvimg->widthstep*i))[j] =                         (char) (dwt_output[i][j]) ;             }         }     }      cvnamedwindow( "dwt image", 1 ); // creation of visualisation window     cvshowimage( "dwt image", cvimg ); // image visualisation     cvwaitkey();     cvdestroywindow("dwt image");     cvsaveimage("dwt.bmp",cvimg);      // finding idwt      vector<vector<double> > idwt_output(rows, vector<double>(cols));      idwt_2d_sym(output,flag, nm, idwt_output,length);        //displaying reconstructed image      iplimage *dvimg;     cvsize dvsize; // size of output image      dvsize.width = idwt_output[0].size();     dvsize.height = idwt_output.size();      cout << idwt_output.size() << idwt_output[0].size() << endl;     dvimg = cvcreateimage( dvsize, 8, 1 );      (int = 0; < dvsize.height; i++ )         (int j = 0; j < dvsize.width; j++ )             ((uchar*)(dvimg->imagedata + dvimg->widthstep*i))[j] =                     (char) (idwt_output[i][j])  ;      cvnamedwindow( "reconstructed image", 1 ); // creation of visualisation window     cvshowimage( "reconstructed image", dvimg ); // image visualisation     cvwaitkey();     cvdestroywindow("reconstructed image");     cvsaveimage("recon.bmp",dvimg);            return 0; } 

and when compile output success, can shown image of apple

but when want wavelet image pressing enter, crashed, here : unhandled exception @ 0x7736c41f in lab09.exe: microsoft c++ exception: std::length_error @ memory location 0x003bf30c.. break or continue.

please me thanks.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -