Beispiel #1
0
void YARPBlobFinder::Apply(const YARPImageOf<YarpPixelRGB>& is, YARPImageOf<YarpPixelRGB>& id)
{
	// no padding enforced.
	assert (id.GetPadding() == 0);
	assert (is.GetPadding() == 0);
	assert (id.GetHeight() == is.GetHeight() && id.GetWidth() == is.GetWidth());

	// extract the saliency image.
	m_saliency.Apply (is, m_hsv_enhanced);

	_apply (is, id);
}
void YARPColorConverter::RGB2Normalized (const YARPImageOf<YarpPixelRGB>& in, YARPImageOf<YarpPixelRGBFloat>& out, float threshold)
{
    assert (out.GetIplPointer() != NULL && in.GetIplPointer() != NULL);
    assert (out.GetHeight() == in.GetHeight());
    assert (out.GetWidth() == in.GetWidth());

    unsigned char *inTmp = (unsigned char *) in.GetAllocatedArray();
    unsigned char *outTmp = (unsigned char *) out.GetAllocatedArray();

    int r = 0;
    int c = 0;
    int padIn = in.GetPadding();
    int padOut = out.GetPadding();

    float lum;
    float *tmp;

    for(r = 0; r<in.GetHeight(); r++)
    {
        for(c = 0; c < in.GetWidth(); c++)
        {
            tmp = (float *) outTmp;
            lum = (float)( inTmp[0] + inTmp[1] + inTmp[2]);
            if (lum > threshold)
            {
                tmp[0] = inTmp[0]/lum;
                tmp[1] = inTmp[1]/lum;
                tmp[2] = inTmp[2]/lum;
            }
            else
            {
                tmp[0] = 0.0;
                tmp[1] = 0.0;
                tmp[2] = 0.0;
            }

            inTmp += 3;
            outTmp += 3*sizeof(float);
        }
        inTmp += padIn;
        outTmp += padOut;
    }

}
void YARPGaussianFeatures::Apply (const YARPImageOf<YarpPixelMono>& in)
{
	assert (in.GetPadding() == 0);

	for (int i = 1; i <= m_sigmas; i++)
	{
		m_features(i) = SpecialConvolveX (m_coeffs[i-1], (const unsigned char *)in.GetAllocatedArray());
		m_features(i+m_sigmas) = SpecialConvolveY (m_coeffs[i-1], (const unsigned char *)in.GetAllocatedArray());
	}
}
// this function now is exactly like the RGB one; however, in the future we may want to use
// different weights for different colors.
void YARPColorConverter::RGB2Normalized (const YARPImageOf<YarpPixelBGR>& in, YARPImageOf<YarpPixelBGR>& out, float threshold)
{
    assert (out.GetIplPointer() != NULL && in.GetIplPointer() != NULL);
    assert (out.GetHeight() == in.GetHeight());
    assert (out.GetWidth() == in.GetWidth());

    unsigned char *inTmp = (unsigned char *) in.GetAllocatedArray();
    unsigned char *outTmp = (unsigned char *) out.GetAllocatedArray();

    int r = 0;
    int c = 0;
    int padIn = in.GetPadding();
    int padOut = out.GetPadding();

    float lum;

    for(r = 0; r<in.GetHeight(); r++)
    {
        for(c = 0; c < in.GetWidth(); c++)
        {
            lum = (float) (inTmp[0] + inTmp[1] + inTmp[2]);
            if (lum > threshold)
            {
                outTmp[0] = (unsigned char)((inTmp[0]/lum)*255 + 0.5);	// B
                outTmp[1] = (unsigned char)((inTmp[1]/lum)*255 + 0.5);	// G
                outTmp[2] = (unsigned char)((inTmp[2]/lum)*255 + 0.5);	// R
            }
            else
            {
                outTmp[0] = 0;
                outTmp[1] = 0;
                outTmp[2] = 0;
            }

            inTmp += 3;
            outTmp += 3;
        }
        inTmp += padIn;
        outTmp += padOut;
    }

}