How can I get this halftone effect on a folder containing images, and then export them to another folder?

How much help do you need? Or on what skill level? Do you have any code yet ready? It would be a good starting point to help you forward.

I have this code, but I just want it to be exported in halftone


 
PImage img;
int bsize = 3 ;
boolean offset = true;
 
import processing.pdf.*;
 
void setup() {
 
  println( brightness( color(255)));
  println( brightness( color(0)));
 
  noStroke();
  img = loadImage("testpattern.jpg");
  size(500, 500);
  background(255);
  //tint(255, 170);
  image(img, 0, 0);
 
  noLoop();
  beginRecord(PDF, "Halftonize export.pdf"); 
 
  //filter(POSTERIZE,4);
  //filter(THRESHOLD);
  noTint();
 
  for (int x=0; x < width; x+=bsize) {
    for (int y=0; y < height; y += bsize) {
 
      color c = getavg(x, y, bsize);
      float b = brightness(c);
      int r = 0;
 
      fill(0);
 
      if ( b > 0   && b < 50) {
        r = bsize;
      }
      if ( b > 50  && b < 90) {
        r = floor(bsize * .9);
      }
      if ( b > 90  && b < 130) {
        r = floor(bsize * .8);
      }
      if ( b > 130 && b < 190) {
        r = floor(bsize * .4);
      }
      if ( b > 190 && b < 230) {
        r = floor(bsize * .2);
      }
      if ( b > 230) {
        r = 1;
      }
 
      if ( offset) {
        ellipse(x+bsize, y, r, r);
      }
      else {
        ellipse(x, y, r, r);
      }
      offset = ! offset;
    }
  }
 
  println("Finished");
  //saveFrame("output/output##.jpg");
}
 
color getavg(int x, int y, int blocksize) {
  float r =0;
  float g =0;
  float  b =0;
  int count=0;
 
  for (int xx=x; xx < x+ blocksize; xx++) {
    for (int yy=y; yy< y +blocksize; yy++) {
      r += red( img.get(xx, yy) );
      g += green( img.get(xx, yy));
      b += blue( img.get(xx, yy));
      count++;
    }
  }
  return color( r/count, g/count, b/count);
}
 
void draw() {
  endRecord();
}

and the halftone images I want them to resemble those in the image above