Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have bicubic interpolation for image zooming but i want B-spline interpolation plz anyone help me.
C#
code bicubic interpolation:

IplImage * bicubic(IplImage *img, int newWidth, int newHeight)
{
        int w= newWidth;
        int h = newHeight;
        IplImage * img2 =0;
        img2 = cvCreateImage(cvSize(w,h),IPL_DEPTH_8U,3);
        uchar * data =( uchar* ) img-imageData;
        uchar * Data =( uchar* ) img2-imageData;
       float tx,ty;

        tx = (float)img-width /newWidth ;
        ty =  (float)img-height / newHeight;

        float C[5] = { 0 };

for (unsigned i = 0; i<newHeight; ++i)
{
    for (unsigned j = 0; j<newWidth; ++j)
    {
        const int x = int(tx * j);
        const int y = int(ty * i);
        const float dx = tx * j - x, dx2 = dx * dx, dx3 = dx2 * dx;
        const float dy = ty * i - y, dy2 = dy * dy, dy3 = dy2 * dy;

        for (int k = 0; k<= 3; ++k)
        {
            for (int jj = 0; jj < 4; ++jj)
            {
                const int idx = y - 1 + jj;
                float a0 =data[(y-1+jj)*img-widthStep + (x)*img-nChannels +k];
                float d0 =data[(y-1+jj)*img-widthStep + (x-1)*img-nChannels +k] -          data[(y-1+jj)*img-gt;widthStep + (x)*img-nChannels +k];
                float d2 = data[(y-1+jj)*img-widthStep + (x+1)*img-nChannels +k] -         data[(y-1+jj)*img-widthStep + (x)*img-nChannels +k];
                float d3 = data[(y-1+jj)*img-widthStep + (x+2)*img-nChannels +k] - data[(y-1+jj)*img-widthStep + (x)*img-nChannels +k];
                float a1 = -(1.0f / 3.0f) * d0 + d2 - (1.0f / 6.0f) * d3;
                float a2 = 0.5f  * d0 +0.5f *  d2;
                float a3 = -(1.0f / 6.0f) * d0 - 0.5f * d2 + (1.0f / 6.0f) * d3;
                C[jj] = a0 + a1 * dx + a2 * dx2 + a3 * dx3;

                d0 = C[0] - C[1];
                d2 = C[2] - C[1];
                d3 = C[3] - C[1];
                a0 = C[1];
                a1 = -(1.0f / 3.0f) * d0 + d2 -(1.0f / 6.0f) * d3;
                a2 = 0.5f  * d0 +0.5f  * d2;
                a3 = -(1.0f / 6.0f) * d0 - 0.5f * d2 + (1.0f / 6.0f) * d3;
                Data[i*img2-widthStep +j*img2-nChannels +k ]=saturate( a0 + a1 * dy + a2 * dy2 + a3 * dy3 );
            }
        }<pre lang="c++">

}
}
return img2;
}
C++

Posted
Updated 12-Apr-16 21:18pm
Comments
KarstenK 24-Apr-16 13:10pm    
try an opencv forum or google for it. The chances for getting an answer for that type of question are very, very low.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900