<dfn id="is4kg"></dfn>
  • <ul id="is4kg"></ul>
  • <abbr id="is4kg"></abbr>
  • <ul id="is4kg"></ul>
    <bdo id="is4kg"></bdo>

    曙海教育集團論壇DSP專區(qū)DSP系統(tǒng)和硬件開發(fā)討論區(qū) → 李現(xiàn)路:DSP6000圖像位置移動與變形的典型算法(三)


      共有7482人關注過本帖樹形打印

    主題:李現(xiàn)路:DSP6000圖像位置移動與變形的典型算法(三)

    客人(124.78.*.*)
      1樓


    李現(xiàn)路:DSP6000圖像位置移動與變形的典型算法(三)  發(fā)帖心情 Post By:2009-12-3 13:48:22

    李現(xiàn)路:DSP6000圖像位置移動與變形的典型算法(三)

     

    三、圖像的水平鏡像變換算法

    數(shù)學表達式原理:


    設圖像高度為IHeight,寬度為IWidth,原圖中(x0,y0)經(jīng)過水平鏡像后從未將變?yōu)?/p>

    (IWidth-x0,y0),其表達式為:

    X0=IWidth-y1; y0=y1


    算法的C語言代碼:


    /*水平鏡像變換處理*/

    void horizTranspose()

    {

             int i,j;

             for(i=0;i<numLines;i++)

             {            

                  /*前半部分為原始圖像*/

                  //傳送臨時Y緩沖區(qū)

                       DAT_copy((void *)(capYbuffer + i * numPixels),

                          (void *)(tempYbuffer + i * numPixels),

                          numPixels>>1);                                                       

                 //傳送臨時Cb緩沖區(qū)

                 DAT_copy((void *)(capCbbuffer + i * (numPixels >> 1)),

                          (void *)(tempCbbuffer + i * (numPixels >> 1)),

                          numPixels>>2);        

                 //傳送臨時Cr緩沖區(qū)

                 DAT_copy((void *)(capCrbuffer + i * (numPixels >> 1)),

                          (void *)(tempCrbuffer + i * (numPixels >> 1)),

                          numPixels>>2);                                                                          

                      

                       /*后半部分為水平鏡像圖像*/

                       for(j=numPixels/2;j<numPixels;j++)

                       {

                                //傳送臨時Y緩沖區(qū)               

                                *(Uint8 *)(tempYbuffer + i*numPixels + j) = *(Uint8 *)(capYbuffer + i*numPixels + numPixels-1-j);             

                       }

                                   

                 for(j=(numPixels>>2);j<(numPixels>>1);j++)

                       {

                                //傳送臨時Cb緩沖區(qū)

                                *(Uint8 *)(tempCbbuffer + i*(numPixels>>1) + j) = *(Uint8 *)(capCbbuffer + i*(numPixels>>1) + (numPixels>>1)-1-j);                   

                                //傳送臨時Cr緩沖區(qū)

                                *(Uint8 *)(tempCrbuffer + i*(numPixels>>1) + j) = *(Uint8 *)(capCrbuffer + i*(numPixels>>1) + (numPixels>>1)-1-j);                   

                       }

                                          

              }

    }



    四、圖像的縮放算法

    數(shù)學表達式原理:

    假設圖像x軸方向縮放比率fx,y軸方向縮放比率是fy,那么原圖中點(x0,y0)對應

    于新圖中的點(x1,y1)的轉(zhuǎn)換表達式為:

    X0=x1/fx; y0=y1/fy


    算法的C語言代碼:

     

    /*圖像縮放參數(shù)*/

    Float fXZoomRatio=0.5; //水平縮放比率

    Float fYZoomRatio=0.5; //垂直縮放比率

    /*縮放處理函數(shù)*/


    /*縮放處理*/

    void zoom()

    {

             int i,j;

             int intCapX,intCapY;

             for(i=0;i<numLines;i++)

             {

                 for(j=0;j<numPixels;j++)

                 {                    

                intCapX = (int)(j/fYZoomRatio+0.5);

                intCapY = (int)(i/fXZoomRatio+0.5);          

                

                //判斷是否在原圖范圍內(nèi)

                if((intCapX>=0) && (intCapX<numPixels))  

                {  

                         if((i<numLines/2) && (intCapY>=0) && (intCapY<numLines/2))

                         {

                                             //傳送亮度信號

                                             *(Uint8 *)(tempYbuffer + i*numPixels + j) = *(Uint8 *)(capYbuffer + intCapY*numPixels + intCapX); 

                                    }

                                    else if((i>=numLines/2) && (i<numLines) && (intCapY>=numLines/2) && (intCapY<numLines))

                                    {

                                                 //傳送亮度信號

                                             *(Uint8 *)(tempYbuffer + i*numPixels + j) = *(Uint8 *)(capYbuffer + intCapY*numPixels + intCapX);                        

                                    }

                                    else

                                    {

                                        *(Uint8 *)(tempYbuffer + i*numPixels + j) = 0xFF;

                                    }                                                                                  

                     }

                else

                {

                          *(Uint8 *)(tempYbuffer + i*numPixels + j) = 0xFF;

                }                                             

                       }       

             }

    }


    [此貼子已經(jīng)被作者于2009-12-3 13:54:26編輯過]

    支持(0中立(0反對(0單帖管理 | 引用 | 回復 回到頂部

    返回版面帖子列表

    李現(xiàn)路:DSP6000圖像位置移動與變形的典型算法(三)








    簽名