Example #1
0
//  Choose applicable inaccuracy functions for current game mode and target type
void Player::Inaccuracy(){
	int i = 0;
	if (p_colinmode) {
		switch (p_targettype) {
			case 0: ColinSingle(); break;
			case 1: ColinSingle(); break;
			case 2: ColinDouble(); break;
			case 3: ColinTreble(); break;
			case 4: ColinBull(); break;		
		}
		if (p_targettype == 2 || p_targettype == 3) {
			for (i = 0; boardpoints[i] != p_hit/p_targettype; i++){	
			}
			p_targetindex = i;
		} else if (p_targettype == 0) {
			for (i = 0; boardpoints[i] != p_hit; i++) {		
			}
			p_targetindex = i;
		}
	} else {
		switch (p_targettype) {
			case 0: Single(); break;
			case 1: Bull(); break;
			case 2: Double(); break;
			case 3: Treble(); break;
			case 4: BullsEye(); break;
		}
	}
}
    /**
     * @brief ProcessAux
     * @param imgIn
     * @param bBilateral
     * @param nSuperPixels
     * @return
     */
    Image *ProcessAux(Image *imgIn, bool bBilateral, int nSuperPixels = 4096)
    {
        if(bBilateral) {
            float minVal, maxVal;
            imgIn->getMinVal(NULL, &minVal);
            imgIn->getMaxVal(NULL, &maxVal);

            float nLevels = log10f(maxVal) - log10f(minVal) + 1.0f;
            float nLayer = ((maxVal - minVal) / nLevels) / 4.0f;
            float area = imgIn->widthf * imgIn->heightf * perCent;
            int iterations = MAX(int(sqrtf(area)) / 2, 1);

            //create filters
            if(fltIt == NULL) {
                fltBil = new FilterBilateral2DS(1.0f, nLayer);
                fltIt  = new FilterIterative(fltBil, iterations);
            }

    #ifdef PIC_DEBUG
            printf("Layer: %f iterations: %d\n", nLayer, iterations);
    #endif
            //Iterative bilateral filtering
            Image *imgOut = fltIt->Process(Single(imgIn), imgIn_flt);

            return imgOut;
        } else {
            Slic sp;
            sp.execute(imgIn, nSuperPixels);
            Image *imgOut = sp.getMeanImage(NULL);
            return imgOut;
        }
    }
 static Image *execute(Image *imgIn, Image *imgOut,
                       float sigma1, float sigma2,
                       int direction)
 {
     FilterDiffGauss1D filter(sigma1, sigma2, direction);
     return filter.Process(Single(imgIn), imgOut);
 }
    /**
     * @brief Execute_XYZ_to_RGB
     * @param imgIn
     * @param imgOut
     * @return
     */
    static Image *Execute_XYZ_to_RGB(Image *imgIn, Image *imgOut)
    {
        FilterLinearColorSpace flt;

        flt.getXYZ2RGBMatrix();

        return flt.ProcessP(Single(imgIn), imgOut);
    }
 /**
  * @brief execute
  * @param imgIn
  * @param imgOut
  * @param sigma_s
  * @param sigma_r
  * @return
  */
 static Image *execute(Image *imgIn, Image *imgOut,
                          float sigma_s, float sigma_r)
 {
     //filter
     FilterBilateral2DF filter(sigma_s, sigma_r);
     Image *out = filter.Process(Single(imgIn), imgOut);
     return out;
 }
    /**
     * @brief fromRGBtoXYZ
     * @param imgIn
     * @param imgOut
     * @return
     */
    static Image *fromRGBtoXYZ(Image *imgIn, Image *imgOut)
    {
        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;

        FilterColorConv flt;

        flt.insertColorConv(&cc_from_RGB_to_XYZ,    true);
        return flt.Process(Single(imgIn), imgOut);
    }
Example #7
0
    /**
     * @brief Test
     */
    static void Test()
    {
        Image imgIn(1, 512, 512, 3);
        imgIn = 1.0f;

        FilterChannel filter(0);
        Image *outR = filter.Process(Single(&imgIn), NULL);

        filter.setChannel(1);
        Image *outG = filter.Process(Single(&imgIn), NULL);

        filter.setChannel(2);
        Image *outB = filter.Process(Single(&imgIn), NULL);

        outR->Write("channel_R.pfm");
        outG->Write("channel_G.pfm");
        outB->Write("channel_B.pfm");
    }
Example #8
0
    /**
     * @brief test
     */
    static void test()
    {
        Image img(1, 512, 512, 3);
        img = 1.0f;

        FilterCrop flt(Vec2i(100, 100), Vec2i(200, 200));

        Image *out = flt.Process(Single(&img), NULL);

        out->Write("test_crop_2d_output.pfm");
    }
    /**
     * @brief fromCIELABtoRGB
     * @param imgIn
     * @param imgOut
     * @return
     */
    static Image *fromCIELABtoRGB(Image *imgIn, Image *imgOut)
    {
        ColorConvRGBtoXYZ    cc_from_RGB_to_XYZ;
        ColorConvXYZtoCIELAB cc_from_XYZ_to_CIELAB;

        FilterColorConv flt;

        flt.insertColorConv(&cc_from_XYZ_to_CIELAB, false);
        flt.insertColorConv(&cc_from_RGB_to_XYZ,    false);

        return flt.Process(Single(imgIn), imgOut);
    }
Example #10
0
File: Single.cpp Project: Skpd/Ip
	bool Single::buildFromString(std::string value, std::vector<Single>& list)
	{
		uint32_t iValue = inet_addr(value.c_str());

		if (iValue) {
			list.push_back(Single(iValue));

			return true;
		}

		return false;
	}
Example #11
0
void Bitboard::Print(U64 b)
{
	out("\n");
	for (int f = 0; f < 64; f++)
	{
		if (b & Single(f))
			out(" 1");
		else
			out(" -");
		if (Col(f) == 7) out("\n");
	}
	out("\n");
}
Example #12
0
    /**
     * @brief ExectueCIELABtoRGB
     * @param imgIn
     * @param imgOut
     * @param bDirect
     * @return
     */
    static Image *CIELABtoRGB(Image *imgIn, Image *imgOut,
                                        bool bDirect)
    {
        ColorConvRGBtoXYZ       csXYZ;
        ColorConvXYZtoCIELAB    csCIELAB;

        FilterColorConv flt(NULL, bDirect);

        flt.insertColorConv(&csCIELAB);
        flt.insertColorConv(&csXYZ);

        return flt.Process(Single(imgIn), imgOut);
    }
Example #13
0
    /**
     * @brief RGBtoLogLuv
     * @param imgIn
     * @param imgOut
     * @param bDirect
     * @return
     */
    static Image *RGBtoLogLuv(Image *imgIn, Image *imgOut,
                                        bool bDirect)
    {
        ColorConvRGBtoXYZ       csXYZ;
        ColorConvXYZtoLogLuv    csLogLuv;

        FilterColorConv flt(NULL, bDirect);

        flt.insertColorConv(&csXYZ);
        flt.insertColorConv(&csLogLuv);

        return flt.Process(Single(imgIn), imgOut);
    }
Example #14
0
    /**
     * @brief ExecuteTest
     * @param nameIn
     * @param nameOut
     * @return
     */
    static Image *ExecuteTest(std::string nameIn, std::string nameOut)
    {
        Image imgIn(nameIn);

        FilterChannel filter(0);
        Image *outR = filter.Process(Single(&imgIn), NULL);

        filter.setChannel(1);
        Image *outG = filter.Process(Single(&imgIn), NULL);

        filter.setChannel(2);
        Image *outB = filter.Process(Single(&imgIn), NULL);

        ImageVec src;
        src.push_back(outR);
        src.push_back(outG);
        src.push_back(outB);

        FilterCombine filterC;
        Image *ret = filterC.Process(src, NULL);

        ret->Write(nameOut);
        return ret;
    }
Example #15
0
/*
**** This test is designed to test the validity of the Evaluate member of the PolyFit class
**** This particular test only involves using Evaluate for a single datum and a blank, singular
**** and a normal PolyFit.

**** The Evaluate is tested by using the solution to a + b*x = d

*/
void xPolyFit :: evalTestSingle (void)
{
	gpstk::PolyFit<double> Blank;
	gpstk::PolyFit<double> Single(2);
	gpstk::PolyFit<double> Eval(2);
	
	double data[4] = {0.,2.,4.,-1.};
	double time[4] = {3.,3.,4.,2.,};
	double dataS[4] = {1.,1.,1.,1.};
	double timeS[4] = {0.,0.,0.,1.,};
	
	for (int i =0;i<4;i++)
	{
		Eval.Add(time[i],data[i]);
		Single.Add(timeS[i],dataS[i]);
	}
	
	gpstk::Vector<double> EvalSolution = Eval.Solution();
	
	CPPUNIT_ASSERT_EQUAL(0.,Blank.Evaluate(3.));
	CPPUNIT_ASSERT_EQUAL(0.,Single.Evaluate(10.));
	CPPUNIT_ASSERT_DOUBLES_EQUAL(EvalSolution[0]+3.*EvalSolution[1], Eval.Evaluate(3.),1e-6);
}
int main ()
{
	int num  = 10;
	int temp = 0;

	header = (struct List*)malloc(sizeof(struct List));

	now = header;

	for(temp = 0;temp<num-1&&num>=1;temp++)
	{
		now->next = (struct List*)malloc(sizeof(struct List));
		now = now->next;
		if(temp == num-2)
		{
			now->next = NULL;
		}
	}

	printf("The number of the node in single list is :%d\n",Single(header));

	return 0;
}
Example #17
0
/*
**** This test is designed to test the validity of the Evaluate member of the PolyFit class
**** This particular test only involves using Evaluate for a gpstk::Vectors of data with
**** a blank, singular, and a normal PolyFit.

**** The Evaluate is tested by using the solution to a + b*x = d

*/
void xPolyFit :: evalTestVector (void)
{
	gpstk::PolyFit<double> Blank;
	gpstk::PolyFit<double> Single(2);
	gpstk::PolyFit<double> Eval(2);
	
	gpstk::Vector<double> SData(4,0.);
	SData[0] = 1.;
	SData[1] = 1.;
	SData[2] = 1.;
	SData[3] = 1.;
	gpstk::Vector<double> STime(4,0.);
	STime[0] = 0.;
	STime[1] = 0.;
	STime[2] = 0.;
	STime[3] = 1.;
	
	gpstk::Vector<double> EData(4,0.);
	EData[0] = 0.;
	EData[1] = 2.;
	EData[2] = 4.;
	EData[3] = -1.;
	gpstk::Vector<double> ETime(4,0.);
	ETime[0] = 3.;
	ETime[1] = 3.;
	ETime[2] = 4.;
	ETime[3] = 2.;
	
	Single.Add(STime,SData);
	Eval.Add(ETime,EData);
	
	gpstk::Vector<double> EvalSolution = Eval.Solution();
	
	CPPUNIT_ASSERT_EQUAL(0.,Blank.Evaluate(3.));
	CPPUNIT_ASSERT_EQUAL(0.,Single.Evaluate(10.));
	CPPUNIT_ASSERT_DOUBLES_EQUAL(EvalSolution[0]+3.*EvalSolution[1], Eval.Evaluate(3.),1e-6);
}
 /**
  * @brief execute
  * @param imgIn
  * @param imgOut
  * @return
  */
 static Image *execute(Image *imgIn, Image *imgOut)
 {
     FilterBackwardDifference filter;
     return filter.Process(Single(imgIn), imgOut);
 }
Example #19
0
 static Image *Execute(Image *imgIn, Image *imgOut, float sigma,
                          int direction)
 {
     FilterGaussian1D filter(sigma, direction);
     return filter.ProcessP(Single(imgIn), imgOut);
 }
Example #20
0
 /**
  * @brief Execute
  * @param in
  * @param isb
  * @param scale
  * @return
  */
 static Image *Execute(Image *in, ImageSampler *isb, float scale)
 {
     FilterSampler3D filterUp(scale, isb);
     Image *out = filterUp.Process(Single(in), NULL);
     return out;
 }
 /**
  * @brief execute
  * @param imgIn
  * @param imgOut
  * @param color
  * @param sigma
  * @return
  */
 static Image *execute(Image *imgIn, Image *imgOut, float *color,
                          float sigma)
 {
     FilterColorDistance fltColDst(color, sigma);
     return fltColDst.Process(Single(imgIn), imgOut);
 }
Example #22
0
 /**
  * @brief Transform
  * @param imgIn
  * @param imgOut
  * @param nCoeff
  * @return
  */
 static Image *Transform(Image *imgIn, Image *imgOut, int nCoeff)
 {
     FilterDCT2D filter(nCoeff, true);
     return filter.Process(Single(imgIn), imgOut);
 }
Example #23
0
 /**
  * @brief Inverse
  * @param imgIn
  * @param imgOut
  * @param nCoeff
  * @return
  */
 static Image *Inverse(Image *imgIn, Image *imgOut, int nCoeff)
 {
     FilterDCT2D filter(nCoeff, false);
     return filter.ProcessP(Single(imgIn), imgOut);
 }
Example #24
0
 const char* Quote::Single (const char* str)
 {
   csStringBase& outStr (GetReturnString());
   Single (outStr, str);
   return outStr;
 }
Example #25
0
 /**
  * @brief Execute
  * @param imgIn
  * @param imgOut
  * @param min
  * @param max
  * @return
  */
 static Image *Execute(Image *imgIn, Image *imgOut, Vec4i min,
                          Vec4i max)
 {
     FilterCrop fltCrop(min, max);
     return fltCrop.Process(Single(imgIn), imgOut);
 }
Example #26
0
 /**
  * @brief execute
  * @param imgIn
  * @param imgOut
  * @return
  */
 static Image *execute(Image *imgIn, Image *imgOut)
 {
     DurandTMO dtmo(5.0f);
     return dtmo.Process(Single(imgIn), imgOut);
 }
Example #27
0
 /**
  * @brief Execute
  * @param imgIn
  * @param imgOut
  * @param size
  * @return
  */
 static Image *Execute(Image *imgIn, Image *imgOut, int size)
 {
     FilterMax filter(size);
     return filter.ProcessP(Single(imgIn), imgOut);
 }
Example #28
0
 /**
  * @brief Execute
  * @param imgIn
  * @param imgOut
  * @param channel
  * @return
  */
 static Image *Execute(Image *imgIn, Image *imgOut, int channel = 0)
 {
     FilterChannel fltCh(channel);
     return fltCh.ProcessP(Single(imgIn), imgOut);
 }
 /**
  * @brief execute
  * @param imgIn
  * @param imgOut
  * @param isb
  * @return
  */
 static Image *execute(Image *imgIn, Image *imgOut, ImageSampler *isb)
 {
     FilterSampler2DSub filter(isb);
     return filter.Process(Single(imgIn), imgOut);
 }
Example #30
0
    /**
     * @brief execute
     * @param imgIn
     * @param imgOut
     * @return
     */
    Image *execute(Image *imgIn, Image *imgOut)
    {
        if(imgIn == NULL) {
            return NULL;
        }

        if(!imgIn->isValid()) {
            return NULL;
        }

        if(imgOut == NULL) {
            imgOut = new Image(1, imgIn->width, imgIn->height, imgIn->channels);
        }

        //compute segmentation map
        seg_map = seg.Process(imgIn, seg_map);

        /*	0 ---> Drago et al. 2003
        	1 ---> Reinhard et al. 2002
        	LumZone     = [-2, -1, 0, 1, 2, 3, 4];
        	TMOForZone =  [ 0,  0, 1, 0, 1, 0, 0];	*/

        int count[2];
        count[0] = 0;
        count[1] = 0;

        for(int i = 0; i < seg_map->size(); i++) {
            int indx = int(seg_map->data[i]);

            if((indx == 2) || (indx == 4)) {
                seg_map->data[i] = 1.0f;
                count[1]++;
            } else {
                seg_map->data[i] = 0.0f;
                count[0]++;
            }
        }

#ifdef PIC_DEBUG
        seg_map->Write("weight_map.pfm");
#endif

        //check if we have different zones
        int value = 10;

        if(count[0] > 0 && count[1] > 0) {
            value = 10;
        }

        if(count[0] > 0 && count[1] == 0) {
            value = 0;
        }

        if(count[0] == 0 && count[1] > 0) {
            value = 1;
        }

        switch(value) {
        case 0: {
            fltDragoTMO.Process(Single(imgIn), imgOut);
        }
        break;

        case 1: {
            fltReinhardTMO.Process(Single(imgIn), imgOut);
        }
        break;

        case 10: {
            //Drago TMO
            imgDrago = fltDragoTMO.Process(Single(imgIn), imgDrago);

            if(pyrA == NULL) {
                pyrA = new Pyramid(imgDrago, true);
            } else {
                pyrA->update(imgDrago);
            }

            //Reinhard TMO
            imgReinhard = fltReinhardTMO.Process(Single(imgIn), imgReinhard);

            if(pyrB == NULL) {
                pyrB = new Pyramid(imgReinhard, true);
            } else {
                pyrB->update(imgReinhard);
            }

            //compute blending weight
            if(pyrWeight == NULL) {
                pyrWeight = new Pyramid(seg_map, false);
            } else {
                pyrWeight->update(seg_map);
            }

            //blend
            pyrA->blend(pyrB, pyrWeight);
            pyrA->reconstruct(imgOut);
        }
        break;
        }

        return imgOut;
    }