See changes to your code in draw():
Code
PImage img;
ArrayList<Float> array = new ArrayList<Float>();
int cols = 30;
int rows = 50;
float res, ry;
void setup(){
size(600,600);
img = loadImage("test.png");
res = img.width/cols;
ry = img.height/rows;
for(int i=0;i<cols;i++){
for(int j=0;j<rows;j++){
int p = int(i*res + j*ry * img.width);
if(p<img.pixels.length){
float r = red(img.pixels[p]);
float g = green(img.pixels[p]);
float bb = blue(img.pixels[p]);
float br = brightness(img.pixels[p]);
float h = (red(img.pixels[p]) + green(img.pixels[p]) + blue(img.pixels[p]) + brightness(img.pixels[p]))/4;
//h = ;
//if(r>h)h = r;
//if(g>h)h = g;
//if(bb>h)h = bb;
//if(br>h)h = br;
//h = map(blue(img.pixels[p]),0,ma,0,100);
//array[p] = h;
array.add(h);
}}}
};
void draw(){
background(0);
for(int i=0;i<cols;i++){
for(int j=0;j<rows;j++){
int p = j + i*rows;
//noStroke();
//fill(array.get(p));
//rect(j*res,i*res,res,res);
//rect(i,j,1,1);
stroke(array.get(p));
point(i, j);
}
}
};
:)
200x200:
30x50: