0% found this document useful (0 votes)
26 views2 pages

New Text Dhfghfocument

The document contains a C program that processes a matrix (image) using a kernel (filter) to produce a new matrix. It includes functions for reading matrices, displaying them, and applying the kernel to the image. The main function orchestrates the input and output of the original image and kernel, and displays the processed result.

Uploaded by

tudor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

New Text Dhfghfocument

The document contains a C program that processes a matrix (image) using a kernel (filter) to produce a new matrix. It includes functions for reading matrices, displaying them, and applying the kernel to the image. The main function orchestrates the input and output of the original image and kernel, and displays the processed result.

Uploaded by

tudor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

valoare_procesata(parametri: I,G,c,n,i,j)

N=sizeof(G)
pentru k de la 0 la N-1
pentru l_mic de la 0 la N-1
G(k,l_mic)*I(c,i-k,j-l_mic)

pentru c de la 0 la 2
pentru i de la 0 la L-1
pentru j de 0 la C-1
J(c,i,j)=valoare_procesata(I,G,c,i,n,j)

#include <stdio.h>

void afisare(int a[50][50],int n , int m)


{
int i, j;
for(i = 0 ; i < n ; i++)
{
for(j = 0 ; j < m ; j++)
printf("%d ", a[i][j]);
printf("\n");
}
}

int citire_matrice(int n,int m)


{
int i, j, a[50][50];

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


for(j = 0; j < m; j++)
{
printf("elementul de pe linia %d si coloane %d este: ", i, j);
scanf("%d", &a[i][j]);
}
return a;
}

int functie_corespondenta(int i, int j ,int I[50][50],int G[50][50],int N)


{
int rezultat=0, l ,k;
for(k = 0; k < N-1; k++)
for(l = 0; l < N-1; l++)
rezultat=rezultat+G[k][l]*I[i-k+1][j-l+1];
return rezultat;
}

int main()
{
int I[50][50], J[50][50], G[50][50], i, j, m, n, N, l, k;
printf("citim imaginea originala ");
printf("numar de linii: ");
scanf("%d", &n);
printf("numar de coloane: ");
scanf("%d", &m);
for(i = 0; i < n; i++)
for(j = 0; j < m; j++)
{
printf("elementul de pe linia %d si coloane %d este: ", i, j);
scanf("%d", &I[i][j]);
}
afisare(I,n,m);
printf("\n");
printf("citim kernel (matricea G): ");
printf("numar de linii, coloane: ");
scanf("%d", &N);
for(i = 0; i < N; i++)
for(j = 0; j < N; j++)
{
printf("elementul de pe linia %d si coloane %d este: ", i, j);
scanf("%d", &G[i][j]);
}

afisare(G,N,N);
printf("\n");
for(i = 0; i < n; i++)
for(j = 0; j < m; j++)
J[i][j]=functie_corespondenta(i,j,I,G,N);

afisare(J,n,m);
printf("\n");
afisare(I,n,m);
return 0;
}

You might also like