void testcolonway2(int argc, string dir) { char *pt = "single_well"; int l = 0, m = 0, n = 0, l1 = 0, l2 = 0, iter_outer = 10; RawImage test; char dirhead[200] = input2; //K:\\sdf\\volume\\clean\\clean\\ep\\ char dirbody[100]; strcpy(dirbody, dir.c_str()); cout << "dirbody" << dirbody << endl; strcat(dirhead, dirbody); cout << "dirhead" << dirhead << endl; short * indata = test.readStream(dirhead, &l, &m, &n); Raw *initial = new Raw(l, m, n); float *inputo = new float[l*m*n]; for (int i = 0; i < l*m*n; i++) { inputo[i] = (float)indata[i]; } Raw *input = new Raw(l, m, n, inputo); Filter *f = new Filter(); //input=f->guass3DFilter(input,3); RawImage *write = new RawImage(); ThreeDim_LevelSet *ls = new ThreeDim_LevelSet(); ls->initialg(*input); for (int i = 0; i<input->getXsize(); i++) { for (int j = 0; j<input->getYsize(); j++) { for (int k = 0; k<input->getZsize(); k++) { if (input->get(i, j, k) >= 1) { initial->put(i, j, k, -2); } else initial->put(i, j, k, 2); } } } *initial = ls->minimal_surface(*initial, *input, 5.0, 0.1, -3, 1.5, 1, iter_outer, pt); char *outname1 = "inner.raw"; char outdir[200] = output; strcat(outdir, dirbody); strcat(outdir, outname1); test.writeImageName(*initial, outdir); //Raw temp(*initial); ls->outerwall(*initial, *input, 5.0, 0.1, -3, 1.5, 1, 10, pt); //*initial -=temp; char *outname2 = "outer5-8_2.raw"; char outdir2[200] = output; strcat(outdir2, dirbody); strcat(outdir2, outname2); test.writeImageName(*initial, outdir2); evaluate(dir, l, m, n); }
void rate(string dir) { char *pt="single_well"; int l=0,m=0,n=0,l1=0,l2=0,iter_outer=10; RawImage test; char dirhead[200]=input2; //K:\\sdf\\volume\\clean\\clean\\ep\\ char dirbody[100]; strcpy(dirbody,dir.c_str()); cout <<"dirbody"<<dirbody<<endl; strcat(dirhead,dirbody); cout << "dirhead" << dirhead<< endl; short * indata=test.readStream(dirhead,&l,&m,&n); delete [] indata; }
void threshold() { int l = 512; int m = 512; int n = 700; RawImage test; char dir2[200] = "K:\\sdf\\volume\\clean\\clean\\ep\\test3\\WI_3035_P_iso_clean.raw"; char dir1[200] = "L:\\sdfdata2\\testthreshold\\WI_3035_P_iso_clean_threshold.raw"; short * indata1 = test.readStream(dir2, &l, &m, &n); for (int i = 0; i < n; i++) { for (int j = 0; j < l; j++) { for (int k = 0; k < m; k++) { short *val = &indata1[i*l*m + j*m + k]; if (*val >-938 && *val < -124) { *val = 100; } else *val = 0; } } } //Raw *indata=new Raw(l,m,n,indata1); FILE *p; p = fopen(dir1, "wb"); fwrite(indata1, sizeof(short), l*m*n, p); fclose(p); fflush(stdout); delete[] indata1; }
void HUandThickness() { //thickness data string dir1(input1);//K:\sdf\volume\clean\clean\ep// D:\sdfdata\distance\rocdata //origion data string dir2(input2);//K:\sdf\volume\clean\clean\ep\rocdatao //skeleton data string dir3(input3);//K:\sdf\volume\clean\clean\ep\rocdatao //cout << dir1 <<endl; vector<string> files1; vector<string> files2; vector<string> files3; GetFileNameFromDir(dir1, files1); GetFileNameFromDir(dir2, files2); GetFileNameFromDir(dir3, files3); vector<string>::iterator iterFile1, iterFile2 = files2.begin(), iterFile3 = files3.begin(); for (iterFile1 = files1.begin(); iterFile1 != files1.end(); iterFile1++) { iterFile1->assign(iterFile1->substr(dir1.size() + 1)); iterFile2->assign(iterFile2->substr(dir2.size() + 1)); iterFile3->assign(iterFile3->substr(dir3.size() + 1)); cout << *iterFile1 << endl; cout << *iterFile2 << endl; //iterFile2++; int l = 0, m = 0, n = 0; char dst1[200], dst2[200], dst3[200]; strcpy(dst1, (*iterFile1).c_str()); //string-->char strcpy(dst2, (*iterFile2).c_str()); strcpy(dst3, (*iterFile3).c_str()); RawImage test; char dir3[200] = input1; char dir4[200] = input2; char dir5[200] = input1; char dir6[200] = input3; strcat(dir3, dst1); strcat(dir4, dst2); strcat(dir5, dst1); strcat(dir6, dst3); short*orgiondata = test.readStream(dir4, &l, &m, &n); PIXTYPE * innerdata = new PIXTYPE[l*m*n]; test.readImage2(innerdata, dir3, l*m*n); unsigned char * skeletondata = new unsigned char[l*m*n]; test.readImage(skeletondata, dir6, l*m*n); float *inputo = new float[l*m*n]; PIXTYPE *skeletondataF = new PIXTYPE[l*m*n]; PIXTYPE *innerdataF = new PIXTYPE[l*m*n]; PIXTYPE max = 0, min = 1000; for (int i = 0; i < l*m*n; i++) { PIXTYPE a = inputo[i] = (float)orgiondata[i] + 1020; max > a ? max = max : max = a; min < a ? min = min : min = a; PIXTYPE b = skeletondataF[i] = biglittleedian(float(skeletondata[i])); //if (PIXTYPE c=innerdataF[i]=biglittleedian((float)innerdata[i])) //{ // cout <<"aaa"<<endl; //} PIXTYPE c = innerdataF[i] = biglittleedian((float)innerdata[i]); } cout << max << endl; cout << min << endl; delete[]skeletondata; delete[]innerdata; delete[] orgiondata; Raw *thickness = new Raw(l, m, n, innerdataF, true); Raw *orgion = new Raw(l, m, n, inputo); Raw *skeleton = new Raw(l, m, n, skeletondataF); Raw *hu = thicknessequalHU(orgion, thickness); queue<Point>q; vector<Point> c; DivideRegion *dr = new DivideRegion(q, skeleton, c); dr->putskletoninorder(); dr->DivideRegionv2(skeleton, hu); dr->DivideRegionthicknessv2(skeleton, thickness); } }
void rocwayinner2people(string dir1, string dir2) { int l = 0, m = 0, n = 0; char dst1[200], dst2[200]; strcpy(dst1, dir1.c_str()); //string-->char strcpy(dst2, dir2.c_str()); RawImage test; char dir3[200] = "L:\\sdfdata2\\inner\\"; char dir4[200] = "K:\\sdf\\volume\\clean\\clean\\ep\\clean\\"; char dir5[200] = "D:\\segdata\\people\\"; strcat(dir3, dst1); strcat(dir4, dst2); strcat(dir5, dst1); //short * indata2=test.readStream(dir4,&l,&m,&n); //cout<<m<<endl; //float * indata1=test.readStreamfloat(dir3,&l,&m,&n); //char * file="L:\\sdfdata2\\inner\\", // *file1="K:\\sdf\\volume\\clean\\clean\\ep\\clean\\"; //int l = 512, // m = 512, // n = 700; //int l = 0, // m = 0, // n = 0; //RawImage test; short*orgiondata = test.readStream(dir4, &l, &m, &n); PIXTYPE * innerdata = test.readStreamfloat(dir3, &l, &m, &n); Raw src(l, m, n, innerdata); float *inputo = new float[l*m*n]; for (int i = 0; i < l*m*n; i++) { inputo[i] = (float)orgiondata[i]; } Raw *orgion = new Raw(l, m, n, inputo); int count = 0, time = 4; do { //Raw srcnew(src); for (int k = 1; k< n - 1; k++) { for (int j = 1; j < m - 1; j++) { for (int i = 1; i < l - 1; i++) { PIXTYPE val = src.get(i, j, k); //unsigned char * p= (unsigned char *)innerdata; //std::swap(p[0],p[3]); //std::swap(p[1],p[2]); if (val == 100) { PIXTYPE data1 = orgion->get(i - 1, j, k); //PIXTYPE *q=&data1; //unsigned char * p= (unsigned char*) q; //std::swap(p[0],p[3]); //std::swap(p[1],p[2]); if (sign(data1)) { src.put(i - 1, j, k, 100); count++; } if (sign(orgion->get(i - 1, j - 1, k))) { src.put(i - 1, j - 1, k, 100); count++; } if (sign(orgion->get(i - 1, j + 1, k))) { src.put(i - 1, j + 1, k, 100); count++; } if (sign(orgion->get(i, j - 1, k))) { src.put(i, j - 1, k, 100); count++; } if (sign(orgion->get(i, j + 1, k))) { src.put(i, j + 1, k, 100); count++; } if (sign(orgion->get(i + 1, j, k))) { src.put(i + 1, j, k, 100); count++; } if (sign(orgion->get(i + 1, j - 1, k))) { src.put(i + 1, j - 1, k, 100); count++; } if (sign(orgion->get(i + 1, j + 1, k))) { src.put(i + 1, j + 1, k, 100); count++; } } } } } time--; cout << count << endl; } while (time); test.writeImageName(src, dir5); }
void pvalue(string dir1, string dir2, string dir22) { int l = 0, m = 0, n = 0; char dst1[200], dst2[200], dst3[200]; strcpy(dst1, dir1.c_str()); //string-->char strcpy(dst2, dir2.c_str()); strcpy(dst3, dir22.c_str()); RawImage test; char dir3[200] = input1; //"D:\\sdfdata\\distance\\rocdata\\" ; char dir4[200] = input2; //"K:\\sdf\\volume\\clean\\clean\\ep\\rocdatao\\"; char dir5[200] = "K:\\sdf\\volume\\clean\\clean\\ep\\clean\\"; strcat(dir3, dst1); strcat(dir4, dst2); strcat(dir5, dst3); short * indata2 = test.readStream(dir5, &l, &m, &n); delete[] indata2; cout << m << endl; float * indata1 = test.readStreamfloat(dir3, &l, &m, &n); //level-set data float * indata3 = test.readStreamfloat(dir4, &l, &m, &n); //robot data int TT = 0, TF = 0, FT = 0, FF = 0; double *res = new double[4]; for (int i = 100; i < n - 100; i++) { for (int j = 0; j < l; j++) { for (int k = 0; k < m; k++) { PIXTYPE val1 = indata1[i*l*m + j*m + k]; //cout<<val1<<endl; short val2 = indata3[i*l*m + j*m + k]; //if (val2 !=0) //{ // cout << val2 <<endl; //} //else //{ //} if (val1 == 100) { //cout <<val1<<endl; if (val2 == 100) //or val [-924,-124] { TT++; } else { FT++; } } if (val2 == 100 && ((j - 256) * (j - 256) + (k - 256) * (k - 256)) <= 200 * 200) //> -938 && val2 <-124 { if (val1 == 0) { TF++; } } else if (val1 == 0) { FF++; } } } } res[0] = TT; res[1] = FT; res[2] = TF; res[3] = FF; cout << "TT:" << TT << "TF:" << TF << "FF:" << FF << "FT" << FT << endl; //FILE *p=fopen("K:\\sdf\\volume\\clean\\clean\\ep\\roc.txt","at+"); //fwrite(res,sizeof(double),4,p); //fclose(p); //fflush(stdout); ofstream os("K:\\sdf\\volume\\clean\\clean\\ep\\roc.txt", ios::app); if (os) { for (int i = 0; i <4; i++) { os << res[i] << " "; } os << endl; } else cerr << "no file" << endl; delete[] res; delete[] indata1; delete[] indata3; }
void testcolon(int argc,char **argv) { char *pt="single_well"; int l=0,m=0,n=0,l1=0,l2=0,iter_outer=10; //cin>> l >> m >> n; //int LX=0,LY=0,LZ=0; RawImage test; //unsigned char * indata=new unsigned char [l*m*n]; //test.readStream(indata,"E:\\volume\\clean\\WI_3032_P_iso_clean.raw",l*m*n); short * indata=test.readStream("K:\\sdf\\volume\\clean\\WI_3110_S_iso_clean.raw",&l,&m,&n); Raw *initial=new Raw(l,m,n); float *inputo=new float[l*m*n]; for (int i = 0; i < l*m*n; i++) { inputo[i]=(float) indata[i]; } //for (int i=0;i<l;i++) //{ // for (int j=0;j<m;j++) // { // for (int k=0;k<n;k++) // { // PIXTYPE *val=inputo+i*m*n+k*n+k; // if(k<473 &&k> 37 && j>164 &&j <373) // { // if (*val!=-924) // { // *val=0; // } // //else *val=100; // } // else *val=0; // } // } //} Raw *input=new Raw(l,m,n,inputo); //IShowraw(*initial,argc,argv); RawImage *write=new RawImage(); //IShowraw(*input,1,argv); //Raw bak(*input); ThreeDim_LevelSet *ls=new ThreeDim_LevelSet(); ls->initialg(*input); //IShowraw(*input,argc,argv); for (int i=0; i<input->getXsize(); i++) { for (int j=0; j<input->getYsize(); j++) { for (int k=0; k<input->getZsize(); k++) { if (input->get(i,j,k)>=1) { initial->put(i,j,k,-2); } else initial->put(i,j,k,2); } } } //IShowraw(*input,argc,argv); //IShowraw(*initial,argc,argv); ls->minimal_surface(*initial,*input,5.0,0.1,-3,1.5,1,iter_outer,pt); //IShowraw(*initial,argc,argv); //for (int i=0;i<initial->getXsize();i++) //{ // for (int j=0;j<initial->getYsize();j++) // { // for (int k=0;k<initial->getZsize();k++) // { // if (initial->get(i,j,k)>=0) // { // initial->put(i,j,k,1); // } // else // { // initial->put(i,j,k,0); // } // } // } //} //*initial*=bak; //ls->outerwall(*initial,*input,5.0,0.1,-3,1.5,1,iter_outer,pt); //IShowraw(*initial,argc,argv); test.writeImage(*initial); //delete [] inputo; }