Exemplo n.º 1
0
void testanistropic(int argc,char **argv)
{//sqrt change 
	//datatype write data	test.writeImage(*output);
	char *pt="single_well";
	int l=281,m=481,n=2501,l1=0,l2=0,iter_outer=30;
	//int LX=0,LY=0,LZ=0;

	RawImage test;
	unsigned char * indata=new unsigned char [l*m*n];
	//short * indata=new short  [l*m*n];


	test.readImage(indata,"F:\\lab\\VTKproj\\mig.raw",l*m*n);
	Raw *initial=new Raw(l,m,n);
	float *inputo=new PIXTYPE[l*m*n];
	for (int i = 0; i < l*m*n; i++)
	{
		inputo[i]=(unsigned char) indata[i];
	}
	delete [] indata;
	
	Raw *input=new Raw(l,m,n,inputo);

	IShowraw(*input,1,argv);
	WipeNioisePde *pm=new WipeNioisePde(*input,1,1.0,0);
	Raw  * output=new Raw (pm->Perona_Malik(*input));
	//test.writeImage();
	IShowraw(*output,1,argv);
	test.writeImage(*output);
	
}
Exemplo n.º 2
0
void testlobster(int argc,char **argv)
{
	char *pt="single_well";
	int l=301,m=324,n=56,l1=0,l2=0,iter_outer=50;
	RawImage test;
	unsigned char * indata=new unsigned char [l*m*n];
	//Raw *inputeasy=new Raw(l,m,n);
	Raw *initial=new Raw(l,m,n);

	test.readImage(indata,"E:\\geo\\lobster.raw",301*324*56);

	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);
	int width=10;

	int x1=138,x2=144,y1=137,y2=155,z1=30,z2=35; //test for little data

	for (int i=0;i<l;i++)
	{
		for (int j=0;j<m;j++)
		{
			for (int k=0;k<n;k++)
			{

				if (i>x1 && j>y1 && k>z1 && i<x2 && j<y2 && k<z2)
				{
					initial->put(i,j,k,-2.0);
				} 
				else if (i<x1|| j<y1 || k < z1 || i>x2 || j>y2 || k> z2)
				{
					initial->put(i,j,k,2.0);
				}
				else {
					initial->put(i,j,k,-2.0);
				}

			}
		}
	}
	RawImage *write=new RawImage();

	ThreeDim_LevelSet *ls=new ThreeDim_LevelSet();
	//IShowraw(*input,argc,argv);
	ls->initialg(*input);	
	ls->minimal_surface(*initial,*input,5.0,0.1,-3,1.5,1,iter_outer,pt);
	IShowraw(*initial,argc,argv);
	test.writeImage(*initial);


}
Exemplo n.º 3
0
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);

	}

}
Exemplo n.º 4
0
void testsesmic()
{
	char *pt="single_well";
	int l = 201,m = 201,n = 851, l1=0,l2=0,iter_outer = 10;
	RawImage test;
	char dirbody[100];
	unsigned char * indata=new unsigned char[l*m*n];
	test.readImage(indata,"K:\\sdf\\geo\\Probe_fault_Amp.probe .raw",l*m*n);//F:\\PA1\\ST1\\SE1\\  //K:\\sdf\\MRI
	Raw *initial=new Raw(l,m,n);
	float *inputo=new float[l*m*n];
	short min = 1000,max = -100;
	for (int i = 0; i < l*m*n; i++)
	{
		//change the big --little
		//float * p= (float *)(indata+i);
		//unsigned char * bp= (unsigned char *)p;
		//std:swap(bp[0],bp[3]);
		//std::swap(bp[1],bp[2]);
		min < indata[i] ? min=min:min=indata[i];
		max > indata[i] ? max=max:max=indata[i];
		//cal the max and min data
	/*	if ( indata[i] >= 864 && indata[i] <= 1063 )
		{
			inputo[i] = 100;
		} 
		else
		{
			inputo[i] = (short )0;
		}
		*/
		inputo[i]=(float) indata[i];		
	}

	cout <<min << max <<endl;

	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 
					//if ((i >= 172 && i <= 352 && j >= 164 && j <= 376 && z>19 && z <))
				if ((i >= 196 && i <= 220 && j >= 202 && j <= 267 && k > 40 && k < 50))
				{
					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);
	//if you available this, don,t
	//forget to change the next line to initial
	test.writeMRI(*initial,"K:\\sdf\\geo\\data.raw");//F:\\PA1\\ST1\\SE1

}