// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int EdgeGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { herr_t err = 0; SharedVertexList::Pointer vertices = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedVertexList>(DREAM3D::Geometry::SharedVertexList, parentId, preflight, err); SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadListFromHDF5<SharedEdgeList>(DREAM3D::Geometry::SharedEdgeList, parentId, preflight, err); if (edges.get() == NULL || vertices.get() == NULL) { return -1; } size_t numEdges = edges->getNumberOfTuples(); size_t numVerts = vertices->getNumberOfTuples(); FloatArrayType::Pointer edgeCentroids = GeometryHelpers::GeomIO::ReadListFromHDF5<FloatArrayType>(DREAM3D::StringConstants::EdgeCentroids, parentId, preflight, err); if (err < 0 && err != -2) { return -1; } ElementDynamicList::Pointer edgeNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::EdgeNeighbors, parentId, numEdges, preflight, err); if (err < 0 && err != -2) { return -1; } ElementDynamicList::Pointer edgesContainingVert = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5<uint16_t, int64_t>(DREAM3D::StringConstants::EdgesContainingVert, parentId, numVerts, preflight, err); if (err < 0 && err != -2) { return -1; } setVertices(vertices); setEdges(edges); setElementCentroids(edgeCentroids); setElementNeighbors(edgeNeighbors); setElementsContainingVert(edgesContainingVert); return 1; }
static void findBackgroundPixels(struct pam * const inpamP, tuple const backgroundColor, bool const verbose, const unsigned char * const ** const piP) { /*---------------------------------------------------------------------------- Figure out which pixels of the image are background. Read the image from the input file described by *inpamP (positioned now to the start of the raster) and generate the matrix *piP telling which pixels are background and which are foreground, given that the background color is 'backgroundColor'. Note that it isn't as simple as finding which pixels are of color 'backgroundColor'. They have to be part of a contiguous region that touches one of the 4 edges of the image. In the matrix we return, there is one element for each pixel in the image, and it has value PT_BG or PT_FG. -----------------------------------------------------------------------------*/ unsigned char ** pi; bool backgroundComplete; unsigned int passes; pi = newPi(inpamP->width, inpamP->height); initPi(pi, inpamP, backgroundColor); setEdges(pi, inpamP->width, inpamP->height); backgroundComplete = FALSE; passes = 0; while (!backgroundComplete) { bool expandedHoriz, expandedVert; expandBackgroundHoriz(pi, inpamP->width, inpamP->height, &expandedHoriz); expandBackgroundVert(pi, inpamP->width, inpamP->height, &expandedVert); backgroundComplete = !expandedHoriz && !expandedVert; ++passes; } if (verbose) pm_message("Background found in %u passes", passes); *piP = (const unsigned char * const *)pi; }
void mathGraph::set_matrix(int cow, int row, int size) { int tempSize = 2; tempSize += qMax(cow, row); if (tempSize > matrixOfSize.size()) matrixOfSize.resize(tempSize); else tempSize = matrixOfSize.size(); for (int i = 0; i < matrixOfSize.size(); ++i) matrixOfSize[i].resize(tempSize); matrixOfSize[cow][row] = size; matrixOfSize[row][cow] = size; if(size != 0) setEdges(cow,row,size); }
BetaGridGenerator::BetaGridGenerator(double minRho, double maxRho, unsigned int binRho, unsigned int binPhi) { setEdges(minRho, maxRho, binRho, binPhi); }
ShapeContextGenerator::ShapeContextGenerator(double minRho, double maxRho, unsigned int binRho, unsigned int binPhi) { setEdges(minRho, maxRho, binRho, binPhi); }
static void setEdgeCircle(size_t xo, size_t yo, size_t xe, size_t ye, size_t dx, size_t dy, size_t swap, size_t radius, int *sx, int *sy, Points &points) { //Bresenham's circule draw algorithm int x = 0, y = radius, d = 3 - (radius<<1); int mask = 255; int ddx = xe - xo; *sx = 0; *sy = 0; if (ddx < 0) ddx=-1; else ddx=1; while (x < y) { int rrr = x * dx; int rrr2 = y * dy; if(swap) { if(rrr>=rrr2) { mask = 255-1-2-128-64; if(!rrr) { *sx = y; *sy = ddx*x; } } else { mask = 255-128-1-2-4; if(ddx<0) mask = 255-2-4-8-16; *sx = ddx*y; *sy = x; } } else { if(rrr>=rrr2) { mask = 255-1-2-4-8; if(!rrr) { *sx = ddx*x; *sy = y; } } else { mask = 255-1-2-4-128; if(ddx<0) mask = 255-2-4-8-16; *sx = ddx*x; *sy = y; } } if (ddx < 0) mask=~ mask; setEdges (xo, yo, x, y, mask, points); setEdges (xe, ye, x, y, ~mask, points); if (d < 0) d = d + 4*x + 6; else { d = d + 4*(x-y) + 10; --y; } ++x; } if (x == y) { setEdges (xo, yo, x, y, mask, points); setEdges (xe, ye, x, y, ~mask, points); } }
void smooth(int dim, pixel *src, pixel *dst){ int i,j; int temp; temp = dim*dim-dim; setEdges(dim,src,dst); for(j = 1;j < dim-1;j++){ setPixelTop(j,dim,src,dst); setPixelBottom((dim-1)*dim+j,dim,src,dst); } for(i = 1;i < dim-1;i++){ setPixelLeft(i*dim,dim,src,dst); setPixelRight(i*dim+dim-1,dim,src,dst); } temp = dim; pixel_int tleft; pixel_int tright; pixel_int bleft; pixel_int bright; dst+=1+dim; src+=1+dim; for(i = 1;i < dim-1; i+=2){ for(j = 1;j < dim-1;j+=2){ tleft.red = src->red; tleft.green = src->green; tleft.blue = src->blue; src++; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; src+=dim; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; src--; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; src--; tright = bleft = bright = tleft; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; src-=dim; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; bleft = tleft; src-=dim; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; src++; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; tright.red += src->red; tright.green += src->green; tright.blue += src->blue; src++; tleft.red += src->red; tleft.green += src->green; tleft.blue += src->blue; tright.red += src->red; tright.green += src->green; tright.blue += src->blue; src++; tright.red += src->red; tright.green += src->green; tright.blue += src->blue; src+=dim; bright.red += src->red; bright.green += src->green; bright.blue += src->blue; tright.red += src->red; tright.green += src->green; tright.blue += src->blue; src+=dim; bright.red += src->red; bright.green += src->green; bright.blue += src->blue; tright.red += src->red; tright.green += src->green; tright.blue += src->blue; src+=dim; bright.red += src->red; bright.green += src->green; bright.blue += src->blue; src--; bright.red += src->red; bright.green += src->green; bright.blue += src->blue; bleft.red += src->red; bleft.green += src->green; bleft.blue += src->blue; src--; bright.red += src->red; bright.green += src->green; bright.blue += src->blue; bleft.red += src->red; bleft.green += src->green; bleft.blue += src->blue; src--; bleft.red += src->red; bleft.green += src->green; bleft.blue += src->blue; src-=2*dim-3; dst->red = tleft.red/9; dst->green = tleft.green/9; dst->blue = tleft.blue/9; dst+=dim; dst->red = bleft.red/9; dst->green = bleft.green/9; dst->blue = bleft.blue/9; dst++; dst->red = bright.red/9; dst->green = bright.green/9; dst->blue = bright.blue/9; dst-=dim; dst->red = tright.red/9; dst->green = tright.green/9; dst->blue = tright.blue/9; dst++; } src+=2+dim; dst+=2+dim; } }
void Interval::setRightEdge(double right) { setEdges(leftEdge(), right); }
void Interval::setLeftEdge(double left) { setEdges(left, rightEdge()); }
void Interval::move(double delta) { setEdges(leftEdge()+delta, rightEdge()+delta); }