Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:46:58+00:00 2026-06-15T09:46:58+00:00

Anyone know why I get this error? Essentially this program displays an image, displays

  • 0

Anyone know why I get this error? Essentially this program displays an image, displays the histogram or the image. It then adjust each pixels brightness and once more displays the image and histogram with the adjusted values.

The error is:

The method drawHistogram(int[], int, int) is not applicable for arguments (PImage, int[]);

PImage rocks;
PImage rocksBrightened;
PImage rocks2;
int rockBytes[][];
int rockBrights[][];

void setup() {  

  rocks = loadImage("rocks.png");
  size(rocks.width+256, rocks.height*2);
  rocks2 = createGraphics(rocks.width, rocks.height, P2D);
  rocks2.loadPixels();

  int h = rocks.height;
  size(rocks.width*2, rocks.height*2);
  image(rocks, 0, 0);
  rockBytes = new int[rocks.width][rocks.height];
  rockBrights = new int[rocks.width][rocks.height];
  for (int i = 0;i < rocks.width; i++) {  
    for (int j = 0; j < rocks.height; j++) {
    rockBytes[i][j] = rocks.get(i, j);
    } 
  }  
  for (int i = 0; i < rocks.width; i++) { 
    for (int j = 0; j < rocks.height; j++) { 
      rockBrights[i][j] = rocksBrightened.get(i, j); 
      }  
    } 
  drawHistogram(rocks, computeHistogram(rocks)); //THIS LINE CAUSES ERROR
  brighten(rockBrights);
  // makeImage(rocksBrightened, rockBrights);
  image(rocksBrightened, 0, h);
  }

void loadPixelArray(PImage anImage) { 
  anImage.loadPixels(); //load pixels into pixels[] array
  }

int[] computeHistogram (PImage anImage) {
  int histogram[] = new int[256];
  for (int i = anImage.pixels.length-1; i >= 0; --i) {
    int v = (int) brightness(anImage.pixels[i]);
    histogram[v]++;
  }
  int maxV = 0;
  for (int i = 0; i < 256; i++) {
    maxV = max(maxV,histogram[i]);
  }
  for (int i = 0; i < 256; i++) {
    histogram[i] = (int) (histogram[i]*100.0/maxV);
  }
  return histogram; 
}


void brighten(int anyArray[][]) { 

   for (int i = rocks.pixels.length-1; i >= 0; --i) {
      int v = rocks.pixels[i];
      float br = brightness(v);
      float r = constrain(br*-.004436+2.1308*red(v),0,255);
      float g = constrain(br*-.004436+2.1308*green(v),0,255);
      float b = constrain(br*-.004436+2.1308*blue(v),0,255);
      rocks2.pixels[i] = color(r,g,b);
      } 
  }

  void drawHistogram(int histogram[], int x, int y) {
  noStroke();
  fill(0);
  stroke(255);
  rect(x, y, 256, 256);
  for (int i = 0; i < 256; i++) {
    line(x + i, y+256, x + i, y+256 - histogram[i]);
  }
 }


 void makeImage(PImage anImage, int imgArray[][]) { 

   anImage.loadPixels();
   for (int i = 0; i < imgArray.length; i++) {   
     for (int j = 0; j < imgArray[0].length; j++) {   
     int loc = i + j*imgArray.length;   
     set(i, j+100, color(imgArray[i][j])); 
     } 
   }
   anImage.updatePixels();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:46:59+00:00Added an answer on June 15, 2026 at 9:46 am

    Well, the error message says it all:

    The method drawHistogram(int[], int, int) is not applicable for arguments (PImage, int[]);

    This means that you’re trying to call the method drawHistogram(), which is declared as drawHistogram(int[], int, int) (which means it takes an int array and two ints as arguments), but that you pass a PImage and an int array instead of the required arguments. That doesn’t make sense.

    It’s a bit like trying to stick a dollar bill into a machine accepting coins only: it doesn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know what these error's mean? I get this when I click a
Anyone know why I would get this error when trying to create a grails
Does anyone know why I get this error when running mysqlimport? mysqlimport -u someone
Does anyone know how to get around this error ? this sql works fine,
Anyone know how to get this to work if it's possible? class Foo def
I get a segmentation fault when running this code. Anyone know why? Thanks. #include
We catch this error sporadically. Does anyone know what could it be? The URL
does anyone know why i get the error DirectCast(err, SetupApiError) = InWow64 {-536870347} when
Does anyone know how to get the operating system information from a microsoft sql
Does anyone know how to get the correct mouse position during a drag-and-drop operation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.