# Blur Function for Pictures Using Arrays

This is a discussion on Blur Function for Pictures Using Arrays within the C++ Programming forums, part of the General Programming Boards category; I have the binary function done for this question, but I can't get the blur function to work using arrays/matrices. ...

1. ## Blur Function for Pictures Using Arrays

I have the binary function done for this question, but I can't get the blur function to work using arrays/matrices. Can anyone help me? This is what I have so far:

Code:
``` void threshold(int src[], int rows, int cols, int dest[], int thr) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++)
if (src[i*cols + j] > thr)
dest[i*cols + j] = 255;
else
dest[i*cols + j] = 0;
}
}
/** blur ******************************************************************
* @params - src, in any units, @pre=>0
* rows, in any units, @pre=>0, must be a whole number
* cols, in any units, @pre=>0, must be a whole number
* dest, in any units, @pre=0 or 255
* @modifies - returns the array dest
* @returns - nothing
**************************************************************************/
void blur(int src[], int rows, int cols, int dest[]) {
int count;
for (int i = 0; i<rows; i++) {
for (int j = 0; j<cols; j++)
for (int count = 4; count <= i*cols + j; count++)
int sum[i*j];
sum += src[count];
dest = sum / count;
}
}```

I'm not exactly sure where I'm going wrong.

All the resources and information can be found here:

http://www.engr.mun.ca/~mpbl/content...n8/assign8.htm

2. Originally Posted by robbins
Code:
```void blur(int src[], int rows, int cols, int dest[]) {
int count;
for (int i = 0; i<rows; i++) {
for (int j = 0; j<cols; j++)
for (int count = 4; count <= i*cols + j; count++)
int sum[i*j];
sum += src[count];
dest = sum / count;
}
}```
I'm not exactly sure where I'm going wrong.
I'm not exactly sure where you're going right. Your indentation is non-existent (which I fixed in my quote). Your link to the assignment is broken (I had to Google for it).

Also, you apparently didn't read the assignment. He even gives you the formula for blur, and I don't even see any attempt on your part to use his formula. Maybe you should reread the assignment.... Your answer doesn't even make sense. Why would you declare an array repeatedly inside of a double nested loop?