Thread: Blur Function for Pictures Using Arrays

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    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. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    Quote Originally Posted by robbins View Post
    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. Bisection Method function value at root incorrect
    By mr_glass in forum C Programming
    Replies: 3
    Last Post: 11-10-2005, 09:10 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM