Skip to content

Instantly share code, notes, and snippets.

@thequbit
Created February 11, 2014 03:56
Show Gist options
  • Save thequbit/8929023 to your computer and use it in GitHub Desktop.
Save thequbit/8929023 to your computer and use it in GitHub Desktop.
function sums = getsums1d(name,boxsize,noise)
if( noise == 1 )
folder = strcat("/cygdrive/c/dev/af_paper/images/",name,"/noise/");
else
folder = strcat("/cygdrive/c/dev/af_paper/images/",name,"/resized/");
endif;
files = dir(folder);
%sums = zeros(length(files));
for j = 3:length(files)
filename = strcat(folder,files(j).name);
img = imread(filename);
width = imfinfo(filename).Width;
height = imfinfo(filename).Height;
xstart = floor((width/2)-(boxsize/2));
ystart = floor((height/2)-(boxsize/2));
total = 0;
for y = ystart:(ystart+boxsize)
for x = xstart:(xstart+boxsize)
val1 = (double(img(x,y,1)) * .33) + (double(img(x,y,1)) * .33) + (double(img(x,y,1)) * .33);
val2 = (double(img(x-1,y,1)) * .33) + (double(img(x-1,y,1)) * .33) + (double(img(x-1,y,1)) * .33);
diff = abs(val1-val2);
total = total + diff;
end
end
sums(j-2) = total;
%printf('%i/%i = %f\n',j-2,length(files)-2,total);
printf(".");
end
printf("\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment