For example the image processing code (C ++, MATLAB, OpenCV)

A, C image information stored by the array, the subscript index:

pbTag [y * newWidth + x]

See: https://www.cnblogs.com/wxl845235800/p/11149853.html
HRESULT Imagejoint(PBYTE pbSrc,int iWidth,int iHeight,double dbZoom,PBYTE pbTag)

PBYTE pbSrc = NULL, pbTag = NULL ; // FIG source, target FIG PBYTE pbImage = NULL; Load the presence of this latter image // PDWORD pdwImage = NULL; // save the image for
        CString str = "src4.bmp";
        LPCTSTR filename = (LPCTSTR)str;
      cImage.Load(filename);
            iWidth=cImage.GetWidth();
            iHeight=cImage.GetHeight();
FIG source // allocate memory 
            pbSrc = (PBYTE) malloc (iWidth * iHeight);


Two, MATLAB with img (m, n), the image index starts.

Matlab subscript rows and columns can be referenced at the same time, and like a C language reference only once.

A (2: 3,3: -1: 1) represents a reference to an array of rows 2 to 3, 3 to a corresponding element 
A (:, end) represents the last reference to an element ":" indicates that all columns or rows , "end" indicates the last column or row, "end-n" represents the reciprocal of the n-th row or column of 
a (1, end-1) represents the reference first row penultimate element 
a ([2 1 3 3] , [ 11221]) represented by two vectors refer to the specified reference element, i.e., 2,1,3,3 a row of column elements and the corresponding 1,1,2,2,1.

https://blog.csdn.net/sinat_26492471/article/details/52959511

ima=double(imread('lenna2.bmp'));

Original%

ima = rgb2gray (ima);

ima (:,:) = 255;

See: https://www.cnblogs.com/wxl845235800/p/10898203.html

https://www.cnblogs.com/wxl845235800/p/7700887.html

Three, OpenCV in: Call matrix elements

(float)img.at<char>(m,n)

Mat img = imread("test3.png",0);

std::cout<<(float)img.at<uchar>(1,1)<< std::endl;

https://www.cnblogs.com/wxl845235800/p/9082025.html

Mat img = imread ( "test.png", 0); // grayscale
    M = img.rows; // number of rows, the image height 
    N = img.cols; // number of columns, the width of the image
cv::Mat F= (cv::Mat_<int>(64,4) <<
Mat out(2*M,N,CV_8UC1,Scalar(0));
   for(col=0;col<N;col++)
    {
        for(row=0;row<2*M;row++)
        {
            double tmp=(row-1)/M+1/(2*64);
            int i=floor(tmp);
            int phaseNum=floor((tmp-i)*64)+1;
            if(i==0)
            {
                out.at<uchar>(row,col)=
                    (float)img.at<uchar>(1,col)*F.at<uchar>(phaseNum,1)+
                    (float)img.at<uchar>(1,col)*F.at<uchar>(phaseNum,2)+
                    (float)img.at<uchar>(2,col)*F.at<uchar>(phaseNum,3)+
                    (float)img.at<uchar>(3,col)*F.at<uchar>(phaseNum,4);
            }

 

Guess you like

Origin www.cnblogs.com/wxl845235800/p/11495239.html