Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r510 - in branches/AFR/Engine/ImageTraversers: . AFR
- Date: Sat, 27 Aug 2005 17:51:53 -0600 (MDT)
Author: abe
Date: Sat Aug 27 17:51:52 2005
New Revision: 510
Modified:
branches/AFR/Engine/ImageTraversers/AFImageTraverser.cc
branches/AFR/Engine/ImageTraversers/AFR/kdtree.cc
branches/AFR/Engine/ImageTraversers/AFR/sample.h
branches/AFR/Engine/ImageTraversers/AFR/tiles.cc
Log:
Incremental changes for the afternoon
Modified: branches/AFR/Engine/ImageTraversers/AFImageTraverser.cc
==============================================================================
--- branches/AFR/Engine/ImageTraversers/AFImageTraverser.cc (original)
+++ branches/AFR/Engine/ImageTraversers/AFImageTraverser.cc Sat Aug 27
17:51:52 2005
@@ -163,26 +163,26 @@
float t = (float)chunkTimeStamp[context.proc];
Color color[5];
+
+ const static double offset[5][2] = {
+ { 0.0, 0.0},
+ {-1.0, 0.0},
+ { 1.0, 0.0},
+ { 0.0,-1.0},
+ { 0.0, 1.0}
+ };
for(int i=0;i<size;i++) {
- // normalized
+
double px, py;
- switch(i)
- {
- case 0: cx = sx; cy = sy;
- break; // center
- case 1: cx = sx-1; cy = sy;
- break; // left
- case 2: cx = sx+1; cy = sy;
- break; // right
- case 3: cx = sx; cy = sy-1;
- break; // bottom
- case 4: cx = sx; cy = sy+1;
- break; // top
- };
+
+ cx = sx+offset[i][0];
+ cy = sy+offset[i][1];
+
//cout << "raytracing: " << cx << ", " << cy << endl;
// we will jitter later, now just add 0.5 <TODO>
- if(xres>yres) // let the smaller dimension be mapped to [-1,1]
+
+ if(xres > yres) // let the smaller dimension be mapped to [-1,1]
{
px = (double)(-1.0 + 2.0*cx/(double)yres);
py = (double)(-1.0 + 2.0*cy/(double)yres);
@@ -192,52 +192,34 @@
px = (double)(-1.0 + 2.0*cx/(double)xres);
py = (double)(-1.0 + 2.0*cy/(double)xres);
}
- //printf("%f, %f\n", (float)px, (float)py);
+
+ // Specify the pixel.
rays.setPixel(i, 0, px, py, &color[i]);
}
+
+
/////////////////////////////////////////////////////////////////////////////
// Trace the rays. The results will automatically go into the fragment
context.renderer->traceEyeRays(context, rays);
rays.computeHitPositions();
+
/////////////////////////////////////////////////////////////////////////////
// okay now copy from fragment to temporalQ
for(int i=0;i<size;i++) {
RayPacket::Element& re = rays.get(i);
+
RGBColor tempcol = color[i].convertRGB();
Point p = re.hitPosition;
- switch(i)
- {
- case 0:
- ss.set(CENTER_SAMPLE, sx, sy, t, p.x(), p.y(), p.z(),
- tempcol.r(), tempcol.g(), tempcol.b());
- image->set((int)sx, (int)sy, color[i]);
- break;
- case 1:
- ss.set(LEFT_SAMPLE, sx-1, sy, t, p.x(), p.y(), p.z(),
- tempcol.r(), tempcol.g(), tempcol.b());
- image->set((int)sx-1, (int)sy, color[i]);
- break;
- case 2:
- ss.set(RIGHT_SAMPLE, sx+1, sy, t, p.x(), p.y(), p.z(),
- tempcol.r(), tempcol.g(), tempcol.b());
- image->set((int)sx+1, (int)sy, color[i]);
- break;
- case 3:
- ss.set(BOTTOM_SAMPLE, sx, sy-1, t, p.x(), p.y(), p.z(),
- tempcol.r(), tempcol.g(), tempcol.b());
- image->set((int)sx, (int)sy-1, color[i]);
- break;
- case 4:
- ss.set(TOP_SAMPLE, sx, sy+1, t, p.x(), p.y(), p.z(),
- tempcol.r(), tempcol.g(), tempcol.b());
- image->set((int)sx, (int)sy+1, color[i]);
- break;
- };
+
+ ss.set( (CrosshairSampleLoc)i, sx, sy, t, p.x(), p.y(),
p.z(),tempcol.r(), tempcol.g(), tempcol.b() );
+ image->set( (int)sx, (int)sy, color[i] );
}
+
//cout << "computing gradients" << endl;
ss.computeGradients(t);
// add the sample to the corresponding kdtree
kdtree[context.proc].updateStatsAddSampleSet(&ss,
(float)chunkTimeStamp[context.proc], samplingrate);
+
// samples_done[context.proc] += 5;
samples_done[context.proc].addFive();
}
Modified: branches/AFR/Engine/ImageTraversers/AFR/kdtree.cc
==============================================================================
--- branches/AFR/Engine/ImageTraversers/AFR/kdtree.cc (original)
+++ branches/AFR/Engine/ImageTraversers/AFR/kdtree.cc Sat Aug 27 17:51:52
2005
@@ -459,18 +459,24 @@
add the new element
*/
int x, y;
-
+
+ // Determine which leaf this sample maps to.
x = (int)newsampleset->viewX;
y = (int)newsampleset->viewY;
int index = Tile::leafMapping[x/2][y/2];
if(!tile[index].checkBounds(x,y)) return;
int vtileindex;
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Update stats up the kdtree to the root.
while(index>0)
{
tile[index].updateStatsAddSampleSet(newsampleset,
currenttime, A, B, tile, sampling_rate, numTiles);
if(tile[index].isValid()) vtileindex = index;
index/=2;
}
+
+
updateMinMax(vtileindex);
}
Modified: branches/AFR/Engine/ImageTraversers/AFR/sample.h
==============================================================================
--- branches/AFR/Engine/ImageTraversers/AFR/sample.h (original)
+++ branches/AFR/Engine/ImageTraversers/AFR/sample.h Sat Aug 27 17:51:52
2005
@@ -36,19 +36,21 @@
float timestamp;
};
- class Sample
- {
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ // SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE
SAMPLE
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ class Sample {
public:
/** color of the sample */
- FloatColor c;
+ FloatColor c; // float[3]
float viewCoord[3]; // floating point 2D coordinate
of the sample on camera viewport
- /** time at which the sample was generated
(in milliseconds) */
+
+ /** time at which the sample was generated (in milliseconds) */
float worldCoord[3]; // the 3d location of the sample
Timestamp t; // timestamp of the sample.
- /**
- * @name Constructors
- * @{
- */
+
Sample()
{
reset();
@@ -152,65 +154,61 @@
};
};
- enum CrosshairSampleLoc { CENTER_SAMPLE, LEFT_SAMPLE,
RIGHT_SAMPLE,
-
TOP_SAMPLE, BOTTOM_SAMPLE, TEMPORAL_SAMPLE};
- class SampleSet
- {
+ // Position in the sampling pattern of each sample.
+ enum CrosshairSampleLoc { CENTER_SAMPLE,
+ LEFT_SAMPLE,
+ RIGHT_SAMPLE,
+
BOTTOM_SAMPLE,
+ TOP_SAMPLE,
+ TEMPORAL_SAMPLE };
+
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ // SAMPLE SET SAMPLE SET SAMPLE SET SAMPLE SET SAMPLE SET SAMPLE
SET
+
///////////////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////////////
+ class SampleSet {
public:
- Sample left, right, bottom, top, center,
temporal;
+
+ // Sample left, right, bottom, top, center, temporal;
+ Sample sample[6];
+
float tgrad, xgrad, ygrad;
Timestamp timestamp;
float viewX, viewY, viewZ;
- SampleSet()
- {
- reset();
- }
+ // Constructor.
+ SampleSet() { reset(); }
void reset()
{
xgrad = ygrad = tgrad = 0.0;
viewX = viewY = viewZ = 0;
timestamp = 0.0;
- left.reset();
- right.reset();
- top.reset();
- bottom.reset();
- center.reset();
- temporal.reset();
+
+ // Reset the samples.
+ for (int i=0;i<6;++i) {
+ sample[i].reset();
+ }
}
void set(CrosshairSampleLoc sloc, const float
x, const float y, const Timestamp tstamp,
const float wx, const float wy, const float wz,
const float r, const float g, const float b)
{
- switch(sloc)
- {
- case CENTER_SAMPLE:
center.set(x,y,tstamp,wx,wy,wz,r,g,b);
- break;
- case LEFT_SAMPLE:
left.set(x,y,tstamp,wx,wy,wz,r,g,b);;
- break;
- case RIGHT_SAMPLE:
right.set(x,y,tstamp,wx,wy,wz,r,g,b);;
- break;
- case BOTTOM_SAMPLE:
bottom.set(x,y,tstamp,wx,wy,wz,r,g,b);;
- break;
- case TOP_SAMPLE:
top.set(x,y,tstamp,wx,wy,wz,r,g,b);;
- break;
- case TEMPORAL_SAMPLE:
temporal.set(x,y,tstamp,wx,wy,wz,r,g,b);;
- break;
- default: return;
- };
+
sample[sloc].set(x,y,tstamp,wx,wy,wz,r,g,b);
timestamp = tstamp;
}
- void computeGradients(Timestamp currenttime)
- {
+ void computeGradients(Timestamp currenttime) {
+
// float li, ri, bi, ti, ci,
tmpi;
- viewX = center.viewCoord[0];
- viewY = center.viewCoord[1];
- viewZ = center.viewCoord[2];
+ viewX =
sample[CENTER_SAMPLE].viewCoord[0];
+ viewY =
sample[CENTER_SAMPLE].viewCoord[1];
+ viewZ =
sample[CENTER_SAMPLE].viewCoord[2];
timestamp = currenttime;
+
// li = left.intensity();
// ri = right.intensity();
// ti = top.intensity();
@@ -218,43 +216,47 @@
// ci = center.intensity();
// tmpi = temporal.intensity();
-
if(fabsf(center.viewCoord[0]-left.viewCoord[0])>0.001
- &&
fabsf(center.viewCoord[0]-right.viewCoord[0])>0.001 )
+
if(fabsf(sample[CENTER_SAMPLE].viewCoord[0]-sample[LEFT_SAMPLE].viewCoord[0])>0.001
&&
+
fabsf(sample[CENTER_SAMPLE].viewCoord[0]-sample[RIGHT_SAMPLE].viewCoord[0])>0.001
)
{
//xgrad =
fabsf(ci-li)/fabsf(center.viewCoord[0]-left.viewCoord[0])
// +
fabsf(ci-ri)/fabsf(center.viewCoord[0]-right.viewCoord[0]);
- xgrad =
center.getRGBDistance(left.c)/fabsf(center.viewCoord[0]-left.viewCoord[0])
- +
center.getRGBDistance(right.c)/fabsf(center.viewCoord[0]-right.viewCoord[0]);
+ xgrad =
sample[CENTER_SAMPLE].getRGBDistance(sample[LEFT_SAMPLE].c) /
+
fabsf(sample[CENTER_SAMPLE].viewCoord[0]-sample[LEFT_SAMPLE].viewCoord[0]) +
+
sample[CENTER_SAMPLE].getRGBDistance(sample[RIGHT_SAMPLE].c) /
+
fabsf(sample[CENTER_SAMPLE].viewCoord[0]-sample[RIGHT_SAMPLE].viewCoord[0]);
}
else
{
//xgrad = (fabsf(ci-li) +
fabsf(ci-ri))/2.0;
- xgrad =
(center.getRGBDistance(left.c) + center.getRGBDistance(right.c))/2.0;
+ xgrad =
(sample[CENTER_SAMPLE].getRGBDistance(sample[LEFT_SAMPLE].c) +
sample[CENTER_SAMPLE].getRGBDistance(sample[RIGHT_SAMPLE].c))/2.0f;
}
-
if(fabsf(center.viewCoord[0]-top.viewCoord[1])>0.001
- &&
fabsf(center.viewCoord[0]-bottom.viewCoord[1])>0.001 )
+
if(fabsf(sample[CENTER_SAMPLE].viewCoord[0]-sample[TOP_SAMPLE].viewCoord[1])>0.001
&&
+
fabsf(sample[CENTER_SAMPLE].viewCoord[0]-sample[BOTTOM_SAMPLE].viewCoord[1])>0.001
)
{
//ygrad =
fabsf(ci-bi)/fabsf(center.viewCoord[1]-top.viewCoord[1])
// +
fabsf(ci-ti)/fabsf(center.viewCoord[1]-bottom.viewCoord[1]);
- ygrad =
center.getRGBDistance(bottom.c)/fabsf(center.viewCoord[1]-top.viewCoord[1])
- +
center.getRGBDistance(top.c)/fabsf(center.viewCoord[1]-bottom.viewCoord[1]);
+ ygrad =
sample[CENTER_SAMPLE].getRGBDistance(sample[BOTTOM_SAMPLE].c) /
+
fabsf(sample[CENTER_SAMPLE].viewCoord[1]-sample[TOP_SAMPLE].viewCoord[1]) +
+
sample[CENTER_SAMPLE].getRGBDistance(sample[TOP_SAMPLE].c) /
+
fabsf(sample[CENTER_SAMPLE].viewCoord[1]-sample[BOTTOM_SAMPLE].viewCoord[1]);
}
else
{
//ygrad = (fabsf(ci-bi) +
fabsf(ci-ti))/2.0;
- ygrad =
(center.getRGBDistance(bottom.c) + center.getRGBDistance(top.c))/2.0;
+ ygrad =
(sample[CENTER_SAMPLE].getRGBDistance(sample[BOTTOM_SAMPLE].c) +
sample[CENTER_SAMPLE].getRGBDistance(sample[TOP_SAMPLE].c))/2.0f;
}
- if(fabsf(center.t-temporal.t)>0.001)
+
if(fabsf(sample[CENTER_SAMPLE].t-sample[TEMPORAL_SAMPLE].t)>0.001)
{
//tgrad =
fabsf(ci-tmpi)/(center.t - temporal.t);
- tgrad =
center.getRGBDistance(temporal.c)/(center.t - temporal.t);
+ tgrad =
sample[CENTER_SAMPLE].getRGBDistance(sample[TEMPORAL_SAMPLE].c)/(sample[CENTER_SAMPLE].t
- sample[TEMPORAL_SAMPLE].t);
}
else
{
//tgrad = fabsf(ci-tmpi);
- tgrad =
center.getRGBDistance(bottom.c);
+ tgrad =
sample[CENTER_SAMPLE].getRGBDistance(sample[BOTTOM_SAMPLE].c);
}
//<TODO> set occlusion status here
@@ -262,18 +264,18 @@
void print_to_file(FILE *fp)
{
- left.print_to_file(fp);
- right.print_to_file(fp);
- top.print_to_file(fp);
- bottom.print_to_file(fp);
- center.print_to_file(fp);
+ sample[LEFT_SAMPLE].print_to_file(fp);
+
sample[RIGHT_SAMPLE].print_to_file(fp);
+ sample[TOP_SAMPLE].print_to_file(fp);
+
sample[BOTTOM_SAMPLE].print_to_file(fp);
+
sample[CENTER_SAMPLE].print_to_file(fp);
}
void print()
{
/* cout << "sample set ---------------->" <<
endl;
cout << "center: "; center.print();
- cout << "left: "; left.print();
+ cout << "left: ";
sample[LEFT_SAMPLE].print();
cout << "right: "; right.print();
cout << "top: "; top.print();
cout << "bottom: "; bottom.print();
@@ -281,50 +283,10 @@
cout <<
"<---------------------------" << endl << endl;*/
}
- float getIntensity(CrosshairSampleLoc sloc)
- {
- switch(sloc)
- {
- case CENTER_SAMPLE: return
center.intensity();
- break;
- case LEFT_SAMPLE: return
left.intensity();
- break;
- case RIGHT_SAMPLE: return
right.intensity();
- break;
- case BOTTOM_SAMPLE: return
bottom.intensity();
- break;
- case TOP_SAMPLE: return
top.intensity();
- break;
- case TEMPORAL_SAMPLE: return
temporal.intensity();
- break;
- default: return 0.0;
- };
- }
-
- Timestamp
getSampleTimeStamp(CrosshairSampleLoc sloc)
- {
- switch(sloc)
- {
- case CENTER_SAMPLE: return
center.t;
- break;
- case LEFT_SAMPLE: return
left.t;
- break;
- case RIGHT_SAMPLE: return
right.t;
- break;
- case BOTTOM_SAMPLE: return
bottom.t;
- break;
- case TOP_SAMPLE: return
top.t;
- break;
- case TEMPORAL_SAMPLE: return
temporal.t;
- break;
- default: return 0.0;
- };
- }
-
- bool isOccluded()
- {
- return false; //<TODO>
- }
+ float getIntensity(CrosshairSampleLoc
sloc) { return sample[sloc].intensity(); }
+ Timestamp
getSampleTimeStamp(CrosshairSampleLoc sloc) { return sample[sloc].t; }
+ bool isOccluded() { return false; }
+
};
} // end namespace Afr
} // end namespace Manta
Modified: branches/AFR/Engine/ImageTraversers/AFR/tiles.cc
==============================================================================
--- branches/AFR/Engine/ImageTraversers/AFR/tiles.cc (original)
+++ branches/AFR/Engine/ImageTraversers/AFR/tiles.cc Sat Aug 27 17:51:52
2005
@@ -130,8 +130,12 @@
float uerror = (currenttime - sum_tstamps.getMean())*0.33/0.1651225 -
1.0;
if(uerror>1.0) uerror = 1.0;
if(uerror<0.0) uerror = 0.0;
+
+ //
float oerror = getOcclusionMeasure(tree, nTiles);
- if(oerror>1.0) oerror = 1.0;
+
+
+ if(oerror>1.0) oerror = 1.0;
error = (0.25*(uerror) + 2.0*(verror) +0.25*(oerror))*num_pixels ;
}
@@ -186,13 +190,16 @@
float ratio = getWeight(A, B, (currenttime - time_last_updated));
float temptime = newsampleset->getSampleTimeStamp(TEMPORAL_SAMPLE);
float stime = newsampleset->timestamp;
+
+
intensity.addElement(newsampleset->getIntensity(CENTER_SAMPLE),
wt_new, ratio);
intensity.addElement(newsampleset->getIntensity(TOP_SAMPLE), wt_new,
1.0);
intensity.addElement(newsampleset->getIntensity(BOTTOM_SAMPLE),
wt_new, 1.0);
intensity.addElement(newsampleset->getIntensity(LEFT_SAMPLE), wt_new,
1.0);
intensity.addElement(newsampleset->getIntensity(RIGHT_SAMPLE),
wt_new, 1.0);
- intensity.addElement(newsampleset->getIntensity(TEMPORAL_SAMPLE),
- getWeight(A, B, (currenttime
- temptime)),
+
+ intensity.addElement(newsampleset->getIntensity(TEMPORAL_SAMPLE),
+ getWeight(A, B, (currenttime - temptime)),
1.0);
xGradient.addElement(newsampleset->xgrad, wt_new, ratio);
@@ -248,11 +255,13 @@
if(denom<0.1) denom = 0.1;
float tgradRatio = ratio;//getWeight(A, B/denom, (currenttime -
time_last_updated));
tGradient.addElement(tgrad, wt_new, tgradRatio);
- if(occ)
+
+ if(occ)
occlusion.addElement(1.0, wt_new, tgradRatio);
else
occlusion.addElement(0.0, wt_new, tgradRatio);
- updateCommon(currenttime, tree, nTiles, sampling_rate);
+
+ updateCommon(currenttime, tree, nTiles, sampling_rate);
}
void Tile::updateMinMax(Tile *tree)
- [MANTA] r510 - in branches/AFR/Engine/ImageTraversers: . AFR, abe, 08/27/2005
Archive powered by MHonArc 2.6.16.