Ok, here's a script that will create circles using the average filter.
To run the script, you need to have an open file with a image reference layer named "base." You can flatten the layers as the script runs. This will make the script run faster, but if you plan to do anything with the individual layers, like a layer effect, you shouldn't do this. You can run it several times to get different sized circles. But the more layers, the slower the script will run.
#target photoshop
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var run = true;
var sizeNorm = 200;
var sizeJit = 0;
var locJit = 0;
var spacingX = 0;
var spacingY = 0;
var offsetX = 0;
var offsetY = 0;
var flattenLay = false;
var lay1
var lay2
var dlg = new Window('dialog','Create Circles of Average Blur');
dlg.sizeGp = dlg.add('panel',undefined,'Size');
dlg.sizeGp.orientation = 'row';
dlg.sizeGp.alignment = ['fill','top'];
dlg.sizeGp.sizeNormStxt = dlg.sizeGp.add('statictext',undefined,'Circle size (pixels):');
var sizeNormEtxt = dlg.sizeGp.add('edittext',undefined,sizeNorm);
sizeNormEtxt.size = [70,17];
dlg.sizeGp.sizeJitStxt = dlg.sizeGp.add('statictext',undefined,'Percent Jitter Size (50 = 50% - 25% larger and 25% smaller); 0 = no jitter:');
var sizeJitEtxt = dlg.sizeGp.add('edittext',undefined,sizeJit);
sizeJitEtxt.size = [70,17];
dlg.locGp = dlg.add('panel',undefined,'Location');
dlg.locGp.orientation = 'column';
dlg.locGp.alignment = ['fill','top'];
dlg.locGp.offGp = dlg.locGp.add('panel',undefined,'Offset in percent of size (0=No offset)');
dlg.locGp.offGp.orientation = 'row';
dlg.locGp.offGp.alignment = ['fill','top'];
dlg.locGp.offGp.spaceXStxt = dlg.locGp.offGp.add('statictext',undefined,'X offset:');
var offsetXEtxt = dlg.locGp.offGp.add('edittext',undefined,offsetX);
offsetXEtxt.size = [70,17];
dlg.locGp.offGp.spaceYStxt = dlg.locGp.offGp.add('statictext',undefined,'Y offset:');
var offsetYEtxt = dlg.locGp.offGp.add('edittext',undefined,offsetY);
offsetYEtxt.size = [70,17];
dlg.locGp.spaceGp = dlg.locGp.add('panel',undefined,'Spacing in percent of size (0=No offset; neg numbers for smaller space)');
dlg.locGp.spaceGp.orientation = 'row';
dlg.locGp.spaceGp.alignment = ['fill','top'];
dlg.locGp.spaceGp.spacingXStxt = dlg.locGp.spaceGp.add('statictext',undefined,'X spacing:');
var spacingXEtxt = dlg.locGp.spaceGp.add('edittext',undefined,spacingX);
spacingXEtxt.size = [70,17];
dlg.locGp.spaceGp.spacingYStxt = dlg.locGp.spaceGp.add('statictext',undefined,'Y spacing:');
var spacingYEtxt = dlg.locGp.spaceGp.add('edittext',undefined,spacingY);
spacingYEtxt.size = [70,17];
dlg.locGp.locJitGp = dlg.locGp.add('panel',undefined,'Location jitter in percent of size (0=No offset)');
dlg.locGp.locJitGp.orientation = 'row';
dlg.locGp.locJitGp.alignment = ['fill','top'];
dlg.locGp.locJitGp.locJitStxt = dlg.locGp.locJitGp.add('statictext',undefined,'Location Jitter:');
var locJitEtxt = dlg.locGp.locJitGp.add('edittext',undefined,locJit);
locJitEtxt.size = [70,17];
dlg.flattenGp = dlg.add('panel',undefined,'Flatten');
dlg.flattenGp.orientation = 'row';
dlg.flattenGp.alignment = ['fill','top'];
var flattenLayChBx = dlg.flattenGp.add('checkbox', undefined,'Flatten Layers to speed up script');
dlg.btnGp = dlg.add('group');
dlg.btnGp.orientation = 'row';
dlg.btnGp.orientChildren = ['center','top'];
dlg.btnGp.ok = dlg.btnGp.add('button',undefined,'Okay');
dlg.btnGp.cancel = dlg.btnGp.add('button',undefined,'Cancel');
dlg.btnGp.ok.onClick = function(){
dlg.close();
sizeNorm = parseFloat(sizeNormEtxt.text);
sizeJit = parseFloat(sizeJitEtxt.text);
locJit = parseFloat(locJitEtxt.text);
spacingX = parseFloat(spacingXEtxt.text);
spacingY = parseFloat(spacingYEtxt.text);
offsetX = parseFloat(offsetXEtxt.text);
offsetY = parseFloat(offsetYEtxt.text);
flattenLay = flattenLayChBx.value;
run = true;
}
dlg.btnGp.cancel.onClick = function(){
run = false;
dlg.close();
}
dlg.show();
try{
var base = doc.layers.getByName('base');
}
catch (e){
run = false;
alert('A reference layer needs to be named "base."\n{all lowercase}');
}
if (run){
var stepY = sizeNorm + (sizeNorm*spacingY);
var stepX = sizeNorm + (sizeNorm*spacingX);
for(i=0+ (sizeNorm *offsetY);i-sizeNorm<doc.height;i+= stepY){
for(j=0+ (sizeNorm *offsetX);j-sizeNorm<doc.width;j+= stepX){
doc.activeLayer = base;
var sizeUse = Math.random() *(sizeJit*sizeNorm) + sizeNorm - (sizeNorm*sizeJit)/2;
var locUseX = Math.random() *(locJit*sizeNorm) + j - (sizeNorm*locJit)/2
var locUseY = Math.random() *(locJit*sizeNorm) + i - (sizeNorm*locJit)/2
createAvg (locUseX, locUseY, sizeUse/2)
}//end j loop
}//end i loop
//createAvg (300, 200, 100/2)
}
function createAvg(selCenterX, selCenterY,selSize){
//================make selection
var idsetd = charIDToTypeID( "setd" );
var desc32 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref3.putProperty( idChnl, idfsel );
desc32.putReference( idnull, ref3 );
var idT = charIDToTypeID( "T " );
var desc33 = new ActionDescriptor();
var idTop = charIDToTypeID( "Top " );
var idPxl = charIDToTypeID( "#Pxl" );
desc33.putUnitDouble( idTop, idPxl, selCenterY - selSize );
var idLeft = charIDToTypeID( "Left" );
var idPxl = charIDToTypeID( "#Pxl" );
desc33.putUnitDouble( idLeft, idPxl, selCenterX - selSize );
var idBtom = charIDToTypeID( "Btom" );
var idPxl = charIDToTypeID( "#Pxl" );
desc33.putUnitDouble( idBtom, idPxl, selCenterY + selSize );
var idRght = charIDToTypeID( "Rght" );
var idPxl = charIDToTypeID( "#Pxl" );
desc33.putUnitDouble( idRght, idPxl, selCenterX + selSize );
var idElps = charIDToTypeID( "Elps" );
desc32.putObject( idT, idElps, desc33 );
var idAntA = charIDToTypeID( "AntA" );
desc32.putBoolean( idAntA, true );
executeAction( idsetd, desc32, DialogModes.NO );
//check to see if a selection was made and not outside of canvas area
try{
var test = doc.selection.bounds
}
catch(e){
return
}
//================== duplicate layer
try{
var idCpTL = charIDToTypeID( "CpTL" );
executeAction( idCpTL, undefined, DialogModes.NO );
}
catch(e){return}
//=========== make selection from layer
var idsetd = charIDToTypeID( "setd" );
var desc37 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref4.putProperty( idChnl, idfsel );
desc37.putReference( idnull, ref4 );
var idT = charIDToTypeID( "T " );
var ref5 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idTrsp = charIDToTypeID( "Trsp" );
ref5.putEnumerated( idChnl, idChnl, idTrsp );
desc37.putReference( idT, ref5 );
executeAction( idsetd, desc37, DialogModes.NO );
//========Average
var idAvrg = charIDToTypeID( "Avrg" );
executeAction( idAvrg, undefined, DialogModes.NO );
//==========deselect
var idsetd = charIDToTypeID( "setd" );
var desc44 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref6 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref6.putProperty( idChnl, idfsel );
desc44.putReference( idnull, ref6 );
var idT = charIDToTypeID( "T " );
var idOrdn = charIDToTypeID( "Ordn" );
var idNone = charIDToTypeID( "None" );
desc44.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc44, DialogModes.NO );
//===============flatten
if(flattenLay){
if(lay1== null){lay1 = doc.activeLayer}
else{
lay2 = doc.activeLayer;
doc.activeLayer = lay1;
var idMrgtwo = charIDToTypeID( "Mrg2" );
var desc5 = new ActionDescriptor();
executeAction( idMrgtwo, desc5, DialogModes.NO );
lay1 = doc.activeLayer;
lay2 = null;
}
}
}