c - Segmentation fault in function of TAD -


i need create tad read pgm image, convolution operation , output image, implementing functions:

/***********************i implemented following

the lines

new_img[img->lin+2][0]=img->img[img->lin+1][1];//inferior esquerdo new_img[0][img->col+2]=img->img[1][img->col+1];//superior direito new_img[0][0]=img->img[1][1];//superior esquerdo new_img[img->lin+2][img->col+2]=img->img[img->lin+1][img->col+1];//inferior direito 

look wrong dimensioned new_img as

unsigned char new_img[img->lin+2][img->col+2]; 

so can access img->lin+1 on first index , img->col+1 on second. img->img has dimensions img->lin , img->col you've gone out of bounds there too.

also, looks have typo in

    if(somatorio<=0) saida->img[contador1-1][contador2-1]=0;         else if(somatorio>=255) saida->img[contador1-1][contador2-1]=255;             else saida->img[contador1-1][contador1-1]=somatorio; 

that last line looks should have contador2-1 second array index.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -