Kaynağa Gözat

* Add mode 8, for the very first graphic in the paper.

* Add results for mode 8 in part0/lena-values.txt.
  * Make the bytecode version use less memory.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/research@2288 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 16 yıl önce
ebeveyn
işleme
c4c76c0f35
4 değiştirilmiş dosya ile 1227 ekleme ve 49 silme
  1. +32
    -1
      2008-displacement/README
  2. +13
    -7
      2008-displacement/main-cpushare
  3. +59
    -41
      2008-displacement/main.c
  4. +1123
    -0
      2008-displacement/part0/lena-values.txt

+ 32
- 1
2008-displacement/README Dosyayı Görüntüle

@@ -15,9 +15,15 @@ for x in part2/*txt ; do grep '^.2' $x | awk '{ print $3,$5 }' >| $x.clean; done
for x in part2/*txt ; do grep '^.2' $x | awk '{ print $3,$9 }' >| $x.clean; done ; ./vote part2/*clean | sort -rnk3 | head -30 ; rm -f part2/*clean

# Get phase 3 and phase 4 stuff
ssh canard.zoy.org "cd test-20080329; tar cz *raster.txt *serp.txt" | tar xz
# .. from canard
ssh canard.zoy.org "cd test-20080329; tar cz *raster.txt" | tar xz
ssh canard.zoy.org "cd test-20080329; tar cz *serp.txt" | tar xz
for x in *-raster.txt; do y="$x"; y="${y%%-raster.txt}"; y="${y%%.tiff}"; y="${y##usc-sipi}"; \mv "$x" part3/"$y".txt; done
for x in *-serp.txt; do y="$x"; y="${y%%-serp.txt}"; y="${y%%.tiff}"; y="${y##usc-sipi}"; \mv "$x" part4/"$y".txt; done
# .. from poulet (cpushare)
scp poulet.zoy.org:cpushare/'test*-*.txt' .
for f in test6-*.txt; do grep '###' $f|cut -f2 -d'`'|cut -f1 -d"'"|tr / .|while read i ; do sed -ne '/`'$i'/,/limit/p' $f | cut -b61- >| part3/$(echo $i | cut -f5 -d.).txt ; done; done; rm -f test6-*.txt
for f in test7-*.txt; do grep '###' $f|cut -f2 -d'`'|cut -f1 -d"'"|tr / .|while read i ; do sed -ne '/`'$i'/,/limit/p' $f | cut -b61- >| part4/$(echo $i | cut -f5 -d.).txt ; done; done; rm -f test7-*.txt

# Condorcet voting for part 3 and 4
for x in part3/*txt ; do cat $x | awk '{ print $2,$4 }' >| $x.clean; done ; ./vote part3/*clean | sort -rnk3 | head -20 ; rm -f part3/*clean
@@ -37,6 +43,31 @@ cat part3/aerials2.1.01.txt | grep K | while read x k y ; do grep $k part3/* | a
cat part4/aerials2.1.01.txt | grep K | while read x k y ; do grep $k part4/* | awk '{ dx+=$10; dy+=$12; n+=1 } END { print dx/n, dy/n }' | read dx dy; echo "$k $(grep $k part4/* | awk 'BEGIN { dx='$dx'; dy='$dy' } { x=dx-$10; y=dy-$12; t+=2.^-5*(x*x+y*y); a+=t*$4; n+=t } END { print a/n, n }')"; done | sort -nk2 | head -20
cat part4/aerials2.1.01.txt | grep K | while read x k y ; do grep $k part4/* | awk '{ dx+=$10; dy+=$12; n+=1 } END { print dx/n, dy/n }' | read dx dy; echo "$k $(grep $k part4/* | awk 'BEGIN { dx='$dx'; dy='$dy' } { x=dx-$10; y=dy-$12; t+=2.^-5*(x*x+y*y); a+=t*$8; n+=t } END { print a/n, n }')"; done | sort -nk2 | head -20

# Plot lena displacement
set contour
unset surface
set view 0,0
set cntrparam levels discrete 0.31, 0.35, 0.42, 0.52, 0.7, 1, 1.5
set xrange [-1:1]
set yrange [1:-1]
set mxtics 2
set mytics 2
set size square
set xzeroaxis
set yzeroaxis
set xlabel "dx" font "Italic,32"
splot 'part0/lena-values.txt' with lines


#set border 0
set style line 1 lt 1 lw 1
set style line 2 lt 2 lw 1
set style line 3 lt 3 lw 1
set style line 4 lt 6 lw 1
set style line 5 lt 1 lw 3
set style line 6 lt 2 lw 3
set style line 7 lt 3 lw 3
set style line 8 lt 6 lw 3
###
###
###


+ 13
- 7
2008-displacement/main-cpushare Dosyayı Görüntüle

@@ -16,7 +16,7 @@ todo = 0
if len(sys.argv) < 4:
print 'Usage: %s <buy_order.cpu> -<mode> [image list]' % (sys.argv[0],)
sys.exit(-1)
mode = sys.argv[2][1]
mode = sys.argv[2]
done = 0
source = sys.argv[3:]
result = [False] * len(source)
@@ -33,19 +33,25 @@ class buy_state_machine_class(object):
self.handler = self.stringReceived

def start(self):
global todo, source
global mode, todo, source
gd.gdMaxColors = 256 * 256 * 256
while todo < len(source):
try:
self.index = todo
im = gd.image(source[self.index])
break
except:
todo += 1
self.result = "Error\n"
if todo >= len(source):
return # We're finished... FIXME: is the transaction kept stuck?
self.index = todo
return # We're finished... FIXME: isn't the transaction stuck?
todo += 1
gd.gdMaxColors = 256 * 256 * 256
im = gd.image(source[self.index])
# Send argument count
self.protocol.sendString(PROTO_SECCOMP_FORWARD + chr(3))
# Send arguments
msg = chr(3)
msg += "bytecode\0"
msg += "-1\0"
msg += mode + "\0"
msg += source[self.index] + "\0"
self.protocol.sendString(PROTO_SECCOMP_FORWARD + msg)
# Send image size


+ 59
- 41
2008-displacement/main.c Dosyayı Görüntüle

@@ -24,7 +24,7 @@ static int WIDTH, HEIGHT;
int main(int, char *[]);

#ifdef BYTECODE
# define MAXIMAGES 128
# define MAXIMAGES 6
static int slots[MAXIMAGES];
static double slotbuf[MAXIMAGES * MAXWIDTH * MAXHEIGHT];

@@ -382,36 +382,24 @@ static double dist(double const *p1, double const *p2, double max)
static double *load(char const *name)
{
double *floats;
int x, y;
int w, h, x, y;

#ifdef BYTECODE
char c;

if(sys_read(0, &c, 1) != 1)
sys_exit(-5);
WIDTH = ((int)(unsigned char)c) << 8;
w = ((int)(unsigned char)c) << 8;
if(sys_read(0, &c, 1) != 1)
sys_exit(-5);
WIDTH |= (int)(unsigned char)c;
w |= (int)(unsigned char)c;

if(sys_read(0, &c, 1) != 1)
sys_exit(-5);
HEIGHT = ((int)(unsigned char)c) << 8;
h = ((int)(unsigned char)c) << 8;
if(sys_read(0, &c, 1) != 1)
sys_exit(-5);
HEIGHT |= (int)(unsigned char)c;

floats = new();
if(!floats)
return NULL;

for(y = 0; y < HEIGHT; y++)
for(x = 0; x < WIDTH; x++)
{
if(sys_read(0, &c, 1) != 1)
sys_exit(-5);
put(floats, x, y, (double)(unsigned char)c / 0xff);
}
h |= (int)(unsigned char)c;
#else
SDL_Surface *tmp, *surface;
uint32_t *pixels;
@@ -420,12 +408,28 @@ static double *load(char const *name)
if(!tmp)
return NULL;

WIDTH = tmp->w > MAXWIDTH ? MAXWIDTH : tmp->w;
HEIGHT = tmp->h > MAXHEIGHT ? MAXHEIGHT : tmp->h;
w = tmp->w;
h = tmp->h;
#endif

WIDTH = w > MAXWIDTH ? MAXWIDTH : w;
HEIGHT = h > MAXHEIGHT ? MAXHEIGHT : h;

floats = new();
if(!floats)
return NULL;

#ifdef BYTECODE
for(y = 0; y < h; y++)
for(x = 0; x < w; x++)
{
if(sys_read(0, &c, 1) != 1)
sys_exit(-5);
if(x >= WIDTH || y >= HEIGHT)
continue;
put(floats, x, y, (double)(unsigned char)c / 0xff);
}
#else
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, WIDTH, HEIGHT, 32,
0xff0000, 0xff00, 0xff, 0x0);
pixels = (uint32_t *)surface->pixels;
@@ -858,6 +862,7 @@ static void usage(char *argv[])
msg(" -5 <src> exhaustive displacement study on src\n");
msg(" -6 <src> restrained (a,b,c,d) ED kernel analysis on src\n");
msg(" -7 <src> restrained displacement study on src\n");
msg(" -8 <src> displacement values on src\n");
}

int main(int argc, char *argv[])
@@ -890,8 +895,8 @@ int main(int argc, char *argv[])
case 1:
{
double *dest = ed(src, false, 7, 0,
0, 3, 5, 1, 0,
0, 0, 0, 0, 0);
0, 3, 5, 1, 0,
0, 0, 0, 0, 0);
study(src, dest, 1.2, 0.001, .16, .28);
del(dest);
del(src);
@@ -1067,6 +1072,38 @@ int main(int argc, char *argv[])
}
break;

case 8:
{
const int STEP = 32;
double mat[NN][NN];
double *dest = ed(src, false, 7, 0,
0, 3, 5, 1, 0,
0, 0, 0, 0, 0);
double *tmp, *tmp2;
int dx, dy;

makegauss(mat, 1.2, 0., 0.);
tmp = gauss(src, mat);
for(dy = 0; dy <= STEP; dy++)
{
for(dx = 0; dx <= STEP; dx++)
{
double fy = 2. / STEP * (dy - STEP / 2.);
double fx = 2. / STEP * (dx - STEP / 2.);

makegauss(mat, 1.2, fx, fy);
tmp2 = gauss(dest, mat);
msg("%g %g %g\n", fy, fx, 1000. * dist(tmp, tmp2, 1.));
del(tmp2);
}
msg("\n");
}
del(tmp);
del(dest);
del(src);
}
break;

#if 0
tmp = ed(src, 7, 0, 0, 3, 5, 1, 0, 0, 0, 0, 0, 0);
//dest = dbs(src, tmp, 0., 0.);
@@ -1098,25 +1135,6 @@ int main(int argc, char *argv[])
#endif

#if 0
# define STEP 32
dest = ed(src, 7, 0, 0, 3, 5, 1, 0, 0, 0, 0, 0, 0);
makegauss(mat, 1.2, 0., 0.);
tmp = gauss(src, mat);
for(dy = 0; dy < STEP; dy++)
{
for(dx = 0; dx < STEP; dx++)
{
double fy = 2. / STEP * (dy - STEP / 2.);
double fx = 2. / STEP * (dx - STEP / 2.);

makegauss(mat, 1.2, fx, fy);
tmp2 = gauss(dest, mat);
msg("%g %g %g\n", fy, fx, 1000. * dist(tmp, tmp2, 1.));
fflush(stdout);
del(tmp2);
}
msg("\n");
}

save(dest, "output.bmp");
#endif


+ 1123
- 0
2008-displacement/part0/lena-values.txt
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


Yükleniyor…
İptal
Kaydet