Пример #1
0
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);
}
Пример #2
0
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);
}