This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

6713 with image



my project is about median filtering a grey image using dsp processor C6713 and the simulator is CCS v3.....the problem i'm facing is that the processor is unable to read the image...may be there is a requirement for header file of the image that must be included in windows....i have attached my c code so please go through and solve my problem.

 

below my c file

#include<stdio.h>

#include<stdlib.h>

#include<alloc.h>
#define M 480

#define N 480

main()

{

FILE *fs,*ft,*fe;

int i,j,k,l,m,n,temp;

int **image,**image1;

image=(int**)calloc(N,sizeof(int));

image1=(int**)calloc(N+2,sizeof(int));


for(i=0;i<N;i++)

{
image[i]=(int*)calloc(M,sizeof(int));

}

for(i=0;i<N+2;i++)

{

image1[i]=(int*)calloc(M+2,sizeof(int));

}


fs=fopen("Image225.pnm","r");

if(fs==NULL)

{
puts("can not open the source file");

exit(0);
}

 

ft=fopen("newcar1.pnm","w");

for(i=0;i<N;i++)

for(j=0;j<M;j++)

{
fscanf(fs,"%d\n",&image[i][j]);

//printf("%d\n",image[i][j]);
}

fclose(fs);

 

for(i=0;i<N+2;i++)

for(j=0;j<M+2;j++)

{
image1[i][j]=0;
}


for(i=1;i<N+1;i++)

for(j=1;j<M+1;j++)

{
image1[i][j]=image[i-1][j-1];
}

/*for(i=0;i<N+2;i++)

for(j=0;j<M+2;j++)

{
 printf("%d\n",image1[i][j]);
}
*/
//fclose(ft);
//}

// median filter
//Pick the nine elements under the mask

 

for(m=1;m<N+1;m++)
{
for(n=1;n<M+1;n++)

{
 int kk=0,window[9];
 
for(k=m-1;k<m+2;k++)
 
{
 for(l=n-1;l<n+2;l++)
 
{
  window[kk]=image1[k][l];

//  printf("%d\n",window[kk]);

//  getchar();
         
kk++;
      
// printf("%d\n",window[kk])
 
      
}
      
}
//sorting elements in ascending order

for(i=0;i<9;i++)
{
for(j=i+1;j<9;j++)

{
 if(window[j]< window[i])
 
{
  temp=window[i];
 
 window[i]=window[j];
 
 window[j]=temp;
    
   }
 }
 }

//replace the element with the median value i.e. the 4th value

/*for(i=0;i<9;i++)
 
 {
   printf("%d\n",window[i]);
   getchar();
   }
*/
image1[m][n]=window[4];
}
}

fe=fopen("ss.int","w");


for(i=0;i<N;i++)

for(j=0;j<M;j++)

{
fprintf(fe,"%d\n",image1[i+1][j+1]);

fprintf(ft,"%d\n",image1[i+1][j+1]);
}

fclose(ft);

fclose(fe);

}