We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've followed the instructions in the histogram example but I get into trouble when I want to move the histogram to different coordinates, here's the script I've created in accordance with the histogram example that's on the processing page :
PImage object;
size(1000,500);
background(0);
object=loadImage("og.jpg");
image(object,0,0);
int [] hist = new int[256];
for (int i = 0; i< object.width; i++){
for (int j = 0; j< object.height; j++){
int bright = int (brightness(get(i,j)));
hist[bright]++;
}
}
int histMax = max(hist);
stroke(255);
for (int i = 0; i< object.width; i +=2){
int which = int(map(i,0, object.width,0,255));
int y = int (map(hist[which], 0, histMax,object.height,0));
line(i,object.height,i,y);
}
Answers
Edit your post (gear icon in the top right corner of your post), select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
You have to change the values of i when you call line() in the last function.
Your sketch is defined as
size(1000,500);
We don't know anything about your image's original size. However, we can constrained it to use only half of the sketch's surface:
object.resize(500,0);
which could be improved by callingobject.resize(width/2,0);
instead. Please check the reference related to the resize() functionality.Now what you can do:
line(i+width/2, object.height, i+width/2, y); //Introduce an X offset for your hist
Kf
The line () function at the end I have created with what you have instructed, and the result is successful My original image is 500x500 pixel then I made 1000,500 size Thanks kfrajer for always being present and answering any questions from me
You are very welcome. Please don't forget to edit your post and format your code. This will help other forum-goers.
Kf
Of course sir, thanks for the help