HI everybody!

i want create Morphological operation Dilation and erosion, i m using Format_Mono for create binary image this is my code:
Qt Code:
  1. QImage BinaryImage::createProbe(int width, int height, bool *data[])
  2. {
  3. QImage temp(width,height,QImage::Format_Mono);
  4. for(int i=0; i<width;i++)
  5. for(int j=0; j<height;j++)
  6. temp.setPixel(i,j,(uint) data[i][j]);
  7.  
  8. return temp;
  9. }
  10.  
  11. bool **data;
  12. data = new bool*[3];
  13. for(int i=0;i<3;i++)
  14. data[i] = new bool[3];
  15.  
  16. for(int i=0;i<3;i++)
  17. for(int j=0;j<3;j++)
  18. data[i][j] = 1;
  19.  
  20. BinaryImage::createProbe(3,3,data);
To copy to clipboard, switch view to plain text mode 

this work great, i convert a Rgb32 image to Binary image with this code:
Qt Code:
  1. void BinaryImage::convertToBinary(QImage* image,float treshholding)
  2. {
  3. QImage temp(image->width(),image->height(),QImage::Format_Mono);
  4.  
  5. if(image->isNull()) return;
  6.  
  7. for(int i=0; i < image->height();i++)
  8. {
  9. QRgb* p =(QRgb *)image->scanLine(i);
  10. for(int j=0;j<image->width();j++)
  11. {
  12. int c = (qRed(p[j])+qGreen(p[j])+qBlue(p[j]))/3;
  13. c = (c > treshholding * 1000)? 1 : 0;
  14. temp.setPixel(j,i,c);
  15. }
  16. }
  17.  
  18. *image = temp;
  19. }
To copy to clipboard, switch view to plain text mode 

this works great too.

but my function for create dilation image is like this:
Qt Code:
  1. Morphology::Morphology(QImage image, QImage probe)
  2. {
  3. if(image.format() == QImage::Format_Mono || probe.format() == QImage::Format_Mono)
  4. {
  5. this->image = image;
  6. this->probe = probe;
  7. }
  8. }
  9.  
  10. QImage Morphology::applyDilation()
  11. {
  12. QImage dest(image.width(),image.height(),QImage::Format_Mono);
  13.  
  14. QVector<uchar> pix_values;
  15. int i,j;
  16.  
  17. for(int row =0;row<image.height();row++)
  18. {
  19. //uchar* dst_row_ptr = dest.scanLine(row);
  20. for(int column = 0; column < image.width(); column++)
  21. {
  22. pix_values.clear();
  23. for(int prow = 0; prow < probe.height(); prow++)
  24. {
  25. i = prow + row - probe.height() / 2;
  26. //uchar* img_row_ptr = image.scanLine(i);
  27. //uchar* prb_row_ptr = probe.scanLine(prow);
  28.  
  29. for(int pcolumn = 0; pcolumn < probe.width(); pcolumn++)
  30. {
  31. j = column + pcolumn - probe.width() / 2;
  32. if(i >= 0 && i < image.height() && j >= 0 && j < image.width())
  33. if(probe.pixelIndex(prow, pcolumn) == 1)
  34. pix_values.push_back(image.pixelIndex(i, j));
  35. }
  36. }
  37. dest.setPixel(row,column,(uint)*std::max_element(pix_values.begin(), pix_values.end())); //the max goes in the destination
  38. }
  39. }
  40.  
  41. return dest;
  42. }
  43.  
  44. //run code is this
  45. BinaryImage::convertToBinary(img,0.17);
  46.  
  47. bool **data;
  48. data = new bool*[3];
  49. for(int i=0;i<3;i++)
  50. data[i] = new bool[3];
  51.  
  52. for(int i=0;i<3;i++)
  53. for(int j=0;j<3;j++)
  54. data[i][j] = 1;
  55. Morphology morph(*img,BinaryImage::createProbe(3,3,data));
  56. imageLabel->setPixmap(QPixmap::fromImage(morph.applyDilation()));
  57. imageLabel->adjustSize();
To copy to clipboard, switch view to plain text mode 
this function is work too but get a lot of warnings QImage:ixelInde() that is out of range and run program too slow.
what is the problem?
what i can do for i havent any warning and run program fast?