# The function "red(int)" does not exist?

**URL:** https://discourse.processing.org/t/the-function-red-int-does-not-exist/44567
**Category:** Beginners
**Created:** [June 9, 2024, 3:09pm UTC](https://discourse.processing.org/t/the-function-red-int-does-not-exist/44567 "2024-06-09T15:09:36Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [June 10, 2024, 6:47am UTC](https://discourse.processing.org/t/the-function-red-int-does-not-exist/44567/6 "2024-06-10T06:47:52Z")

</div>

> [@flice](#):
>
> unfortunately it still doesn’t seem to work… the error is still there 😭

There are other problems in the list (in the image) you provided and you did not share the related code.  
Once you correct the existing problems you will see other problems and that is where my post will help.

_[Guidelines—Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147#is-your-problem-isolated-4)_ \< Can you post an MCVE?

The code below works with Processing 4.3 on W10 and does not report any problems.

Try this (your code with additions by me) and report the result on your end:

```auto
import java.util.*;
// If using int:
List<int[]> cl = new ArrayList<int[]>();

// If using Integer:
//List<Integer[]> cl = new ArrayList<Integer[]>(); // If using Integer

//PImage sf;

void setup()
  {
  size(200, 200);  
  PImage sf = loadImage("http://learningprocessing.com/code/assets/sunflower.jpg");
  averageColor(sf);
  noLoop();
  }

public void averageColor(PImage img) 
  {
  for (int i = 0; i < 3; i++) 
    {
    // If using int:
    int [] Color = new int[3];
    
    // If using Integer:
    //Integer[] Color = new Integer[3];    
    //for(int j=0; j<3; j++)
    // {
    // Color[j] = 0;
    // }
 
    int times = 0;    
    
    for (int r = 0; r < img.width; r += 16) 
      {
      for (int c = 0; c < img.height; c += 16) 
        {
        color currentColor = img.get(r, c);
        Color[0] += (int) red(currentColor);
        Color[1] += (int) green(currentColor);
        Color[2] += (int) blue(currentColor);
        times++;
        }
      }
    Color[0] = Color[0]/times;
    Color[1] = Color[1]/times;
    Color[2] = Color[2]/times;
    cl.add(Color);
    printArray(cl.get(i));
    //println(hex(cl.get(i)[0]), hex(cl.get(i)[1]), hex(cl.get(i)[2]));
    }
  }

```

What version of Processing are you using?  
What operating system?

`:)`

---

_[View the full topic](https://discourse.processing.org/t/the-function-red-int-does-not-exist/44567)._
