How to make histogram but the PImage location is not 0, 0

Hi, im a beginner in processing and tried to make histogram from PImage but the location i want to start it for example 200, 100. I tried play around with it and i got nothing, so pls any help i really appreciate it, and here’s the code

 * Histogram. 
 * Calculates the histogram of an image. 
 * A histogram is the frequency distribution 
 * of the gray levels with the number of pure black values
 * displayed on the left and number of pure white values on the right. 
 * Note that this sketch will behave differently on Android, 
 * since most images will no longer be full 24-bit color.

size(640, 360);

// Load an image from the data directory
// Load a different image by modifying the comments
PImage img = loadImage("frontier.jpg");
image(img, 200, 100);
int[] hist = new int[256];

// Calculate the histogram
for (int i = 0; i < img.width; i++) {
  for (int j = 0; j < img.height; j++) {
    int bright = int(brightness(get(i, j)));

// Find the largest value in the histogram
int histMax = max(hist);

// Draw half of the histogram (skip every second value)
for (int i = 0; i < img.width; i += 2) {
  // Map i (from 0..img.width) to a location in the histogram (0..255)
  int which = int(map(i, 0, img.width, 0, 255));
  // Convert the histogram value to a location between 
  // the bottom and the top of the picture
  int y = int(map(hist[which], 0, histMax, img.height, 0));
  line(i, img.height, i, y);


There are tutorials, examples and references here:

I saw a good example in there of processing a portion of an image that may help.

There are also examples that come with the Processing IDE.

There is an example here where I get() a portion of an image and work with it: