int p3a(void)
{
	// initialize data of input
	const char *inputname = "boat.raw";
	int SizeW = 512;
	int SizeH = 512;
	int BytesPerPixel = 1;
	unsigned char inputdata[SizeH][SizeW][BytesPerPixel];

	// initialize data of output
	const char *outputname1 = "3a boat_FT_ans.raw";
	const char *outputname2 = "3a boat_RT_ans.raw";
	const char *outputname3a = "3a boat_DM2_ans.raw";
	const char *outputname3b = "3a boat_DM4_ans.raw";
	int newSizeW = SizeW;
	int newSizeH = SizeH;
	int newBytesPerPixel = BytesPerPixel;
	unsigned char outputdata1[newSizeH][newSizeW][newBytesPerPixel];
	unsigned char outputdata2[newSizeH][newSizeW][newBytesPerPixel];
	unsigned char outputdata3a[newSizeH][newSizeW][newBytesPerPixel];
	unsigned char outputdata3b[newSizeH][newSizeW][newBytesPerPixel];

	// read input
	readimage(inputname, &inputdata[0][0][0], SizeH, SizeW, BytesPerPixel);

	//*** Fixed thresholding ***
	float FixedT = 128.0;
	Fixedthre(FixedT, SizeH, SizeW, &inputdata[0][0][0], &outputdata1[0][0][0]);
	writeimage(outputname1, &outputdata1[0][0][0], newSizeH, newSizeW, newBytesPerPixel);

	//*** Random thresholding ***
	RandomThre(SizeH, SizeW, &inputdata[0][0][0], &outputdata2[0][0][0]);
	writeimage(outputname2, &outputdata2[0][0][0], newSizeH, newSizeW, newBytesPerPixel);

	//*** Dithering Matrix
	Dithering(2, SizeH, SizeW, &inputdata[0][0][0], &outputdata3a[0][0][0]);
	Dithering(4, SizeH, SizeW, &inputdata[0][0][0], &outputdata3b[0][0][0]);
	writeimage(outputname3a, &outputdata3a[0][0][0], newSizeH, newSizeW, newBytesPerPixel);
	writeimage(outputname3b, &outputdata3b[0][0][0], newSizeH, newSizeW, newBytesPerPixel);

	return 0;
}
示例#2
0
Dithering *Dithering::getOrCreate()
{
    return getOrCreateImpl(Dithering());
}