visual c++ - Local binary pattern in C++ -


i have problem code:private:

private: system::void lbptoolstripmenuitem_click(system::object^  sender, system::eventargs^  e) {              int ** yp;                bitmap ^ bmppicturelbp = gcnew bitmap(w, h);             int vn[2][8] = { { 0, 1, 1, 1, 0, -1, -1, -1 },              { 1, 1, 0, -1, -1, -1, 0, 1 } };               yp = new int*[w];              (int = 0; < w; i++)              {                  yp[i] = new int[h];                  (int j = 0; j < h; j++)                  {                       (int k = 0; k < 8; k++)                      (int l = 0; k < 8; k++)                           yp[i][j] = y[i + vn[1][k]][j +vn[2][l]];                        bmppicturelbp->setpixel(i, j, color::fromargb(yp[i][j], yp[i][j], yp[i][j]));                  }              } 

is can me? firtly dont appear errors, after debugging tell me " indication order memory corrupt", , in autos window appear red: + yp[i] 0x0669afb0 int*.

i see several issues:

for (int k = 0; k < 8; k++) (int l = 0; k < 8; k++) 

i'm assuming typo, , second for loop should doing more l.

int vn[2][8] = { { 0, 1, 1,  1,  0, -1, -1, -1 },                  { 1, 1, 0, -1, -1, -1,  0,  1 } };  yp[i][j] = y[i + vn[1][k]][j +vn[2][l]]; 
  • you've declared vn being array of size 2, means array indexes 0 , 1. you're accessing array indexes 1 , 2; you're going off end of array.
  • you're accessing yp @ various nearby indexes: i+1, i-1, j+1, j-1.
    • you haven't initialized yp[i+1] yet, don't until next iteration through loop.
    • you aren't range checking anything: if i or j 0? you'll access yp[-1] or yp[i][-1], neither of valid.

finally, comment on algorithm: you're modifying yp[i][j] on , over, you're not saving results last time. shown, blur algorithm going copy pixel yp[i-1][j+1], shifting image top-right 1 pixel. (perhaps have code mix pixels properly, , didn't copy web.)


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -