예제 #1
0
IppStatus PrintOutputImages(const Image2D &image_in, const Image2D &image_bpass, const Image2D &image_localmax,
							const Params &Parameters, const int framenumber, const int stacknumber,
							FIMULTIBITMAP *filt_imagestack, FIMULTIBITMAP *over_imagestack)
{
	IppStatus status;

	Image2D image_out(image_in.get_length(), image_in.get_width());
	Image2D image_overlay(image_in.get_length(), image_in.get_width());
	Image2D centerpoints(image_in.get_length(), image_in.get_width());

	Ipp32f brightness = 75;

	//scale points to brightness
	status = ippiMulC_32f_C1R(image_localmax.get_image2D(), image_localmax.get_stepsize(), brightness,
		centerpoints.get_image2D(), centerpoints.get_stepsize(), image_localmax.get_ROIfull());

	//convert and save files as TIFFs
	status = ippiAdd_32f_C1R(
		image_bpass.get_image2D(), image_bpass.get_stepsize(),
		centerpoints.get_image2D(), centerpoints.get_stepsize(),
		image_out.get_image2D(), image_out.get_stepsize(),
		image_out.get_ROIfull());

	status = ippiAdd_32f_C1R(
		image_in.get_image2D(), image_in.get_stepsize(),
		centerpoints.get_image2D(), centerpoints.get_stepsize(),
		image_overlay.get_image2D(), image_overlay.get_stepsize(),
		image_in.get_ROIfull());

	status = IPP_to_TIFF(image_overlay, over_imagestack);
	status = IPP_to_TIFF(image_out, filt_imagestack);
	return status;
}
예제 #2
0
void AtrousGabor::_const_prod(IMAGE_PTR in, IMAGE_PTR out, float gain)
{
#ifdef USE_IPP		
	IppiSize roiSize = {m_i_colsext, m_i_linesext};
	ippiMulC_32f_C1R(in, m_i_strideext, gain, out, m_i_strideext, roiSize);
#else
	int i, j;
	for(i = 0; i < m_i_linesext; i++)
		for(j = 0; j < m_i_colsext; j++)
			out[i*m_i_stridepix+j] = gain*in[i*m_i_stridepix+j];
#endif
}
예제 #3
0
파일: deriv.cpp 프로젝트: HanaLeeHn/opencv
static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int ksize, double scale)
{
    int bufSize = 0;
    cv::AutoBuffer<char> buffer;
    if (ksize == 3 || ksize == 5)
    {
        if ( ddepth < 0 )
            ddepth = src.depth();

        if (src.type() == CV_8U && dst.type() == CV_16S && scale == 1)
        {
            if ((dx == 1) && (dy == 0))
            {
                if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                return (0 <= ippiFilterSobelNegVertBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
                                    (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                    ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
            }

            if ((dx == 0) && (dy == 1))
            {
                if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                return (0 <= ippiFilterSobelHorizBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
                                    (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                    ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
            }

            if ((dx == 2) && (dy == 0))
            {
                if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                return (0 <= ippiFilterSobelVertSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
                                    (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                    ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
            }

            if ((dx == 0) && (dy == 2))
            {
                if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                return (0 <= ippiFilterSobelHorizSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
                                    (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                    ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
            }
        }

        if (src.type() == CV_32F && dst.type() == CV_32F)
        {
#if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R
            return false;
#else
#if 0
            if ((dx == 1) && (dy == 0))
            {
                if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), &bufSize))
                    return false;
                buffer.allocate(bufSize);

                if (0 > ippiFilterSobelNegVertBorder_32f_C1R((const Ipp32f*)src.data, (int)src.step,
                                (Ipp32f*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
                {
                    return false;
                }
                if(scale != 1)
                    ippiMulC_32f_C1R((Ipp32f *)dst.data, (int)dst.step, (Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                return true;
            }

            if ((dx == 0) && (dy == 1))
            {
                if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                if (0 > ippiFilterSobelHorizBorder_32f_C1R((const Ipp32f*)src.data, (int)src.step,
                                (Ipp32f*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
                {
                    return false;
                }
                if(scale != 1)
                    ippiMulC_32f_C1R((Ipp32f *)dst.data, (int)dst.step, (Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                return true;
            }
#endif

            if((dx == 2) && (dy == 0))
            {
                if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                if (0 > ippiFilterSobelVertSecondBorder_32f_C1R((const Ipp32f*)src.data, (int)src.step,
                                (Ipp32f*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
                {
                    return false;
                }
                if(scale != 1)
                    ippiMulC_32f_C1R((Ipp32f *)dst.data, (int)dst.step, (Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                return true;
            }

            if((dx == 0) && (dy == 2))
            {
                if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
                    return false;
                buffer.allocate(bufSize);

                if (0 > ippiFilterSobelHorizSecondBorder_32f_C1R((const Ipp32f*)src.data, (int)src.step,
                                (Ipp32f*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
                                ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
                {
                    return false;
                }

                if(scale != 1)
                    ippiMulC_32f_C1R((Ipp32f *)dst.data, (int)dst.step, (Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                return true;
            }
#endif
        }
    }

    if(ksize <= 0)
        return IPPDerivScharr(src, dst, ddepth, dx, dy, scale);
    return false;
}
예제 #4
0
파일: deriv.cpp 프로젝트: HanaLeeHn/opencv
static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy, double scale)
{
    int bufSize = 0;
    cv::AutoBuffer<char> buffer;
    IppiSize roi = ippiSize(src.cols, src.rows);

    if( ddepth < 0 )
        ddepth = src.depth();

    dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );

    switch(src.type())
    {
    case CV_8U:
        {
            if(scale != 1)
                return false;

            switch(dst.type())
            {
            case CV_16S:
                {
                    if ((dx == 1) && (dy == 0))
                    {
                        if (0 > ippiFilterScharrVertGetBufferSize_8u16s_C1R(roi,&bufSize))
                            return false;
                        buffer.allocate(bufSize);
                        return (0 <= ippiFilterScharrVertBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
                                        (Ipp16s*)dst.data, (int)dst.step, roi, ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
                    }
                    if ((dx == 0) && (dy == 1))
                    {
                        if (0 > ippiFilterScharrHorizGetBufferSize_8u16s_C1R(roi,&bufSize))
                            return false;
                        buffer.allocate(bufSize);
                        return (0 <= ippiFilterScharrHorizBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
                                            (Ipp16s*)dst.data, (int)dst.step, roi, ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
                    }
                    return false;
                }
            default:
                return false;
            }
        }
    case CV_32F:
#if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R
        return false;
#else
        {
            switch(dst.type())
            {
            case CV_32F:
                {
                    if ((dx == 1) && (dy == 0))
                    {
                        if (0 > ippiFilterScharrVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows),&bufSize))
                            return false;
                        buffer.allocate(bufSize);

                        if (0 > ippiFilterScharrVertBorder_32f_C1R((const Ipp32f*)src.data, (int)src.step,
                                        (Ipp32f*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows),
                                        ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
                        {
                            return false;
                        }

                        if (scale != 1)
                            /* IPP is fast, so MulC produce very little perf degradation.*/
                            //ippiMulC_32f_C1IR((Ipp32f)scale, (Ipp32f*)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                            ippiMulC_32f_C1R((Ipp32f*)dst.data, (int)dst.step, (Ipp32f)scale, (Ipp32f*)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                        return true;
                    }
                    if ((dx == 0) && (dy == 1))
                    {
                        if (0 > ippiFilterScharrHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows),&bufSize))
                            return false;
                        buffer.allocate(bufSize);

                        if (0 > ippiFilterScharrHorizBorder_32f_C1R((const Ipp32f*)src.data, (int)src.step,
                                        (Ipp32f*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows),
                                        ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
                            return false;

                        if (scale != 1)
                            ippiMulC_32f_C1R((Ipp32f *)dst.data, (int)dst.step, (Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
                        return true;
                    }
                }
            default:
                return false;
            }
        }
#endif
    default:
        return false;
    }
}