Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
what is different between this code :
this different code must be given same result, but this is not happen

C#
IplImage *Image=cvCreateImage(cvSize(640,500),IPL_DEPTH_32F,3);
for(int row=0; row<50; row++ )
{
    for(int col=0; col<Image->width; col++ ) {
        ((double *)(Image->imageData + row*Image->widthStep))[col*Image->nChannels + 0]=175;
        ((double *)(Image->imageData + row*Image->widthStep))[col*Image->nChannels + 1]=0;
        ((double *)(Image->imageData + row*Image->widthStep))[col*Image->nChannels + 2]=0;
    }
}
cvNamedWindow("A",0);
cvShowImage("A",Image);
cvWaitKey(0)

And ,
IplImage *Image=cvCreateImage(cvSize(640,500),IPL_DEPTH_32F,3);

CvScalar Sca;
Sca.val[0]=175;
Sca.val[1]=0;
Sca.val[2]=0;
for(int row=0; row<50; row++ )
{
    for(int col=0; col<Image->width; col++ )
    {
        cvSet2D(Image,row,col,Sca);
    }
}
cvNamedWindow("A",0);
cvShowImage("A",Image);
cvWaitKey(0);
Posted
Comments
Sergey Alexandrovich Kryukov 5-Aug-13 16:12pm    
Well, first fragment of code has 12 lines, and the second one — 16 lines. Do you need to spot some other differences? :-)
Please understand: "what is the difference questions" are usually incorrect. What makes you believe that the codes are equivalent? What are you trying to achieve?
The riddles like yours are not very productive...
—SA
Anderso0on 5-Aug-13 16:42pm    
i want to access each chanel in pixel with pointer.
i know how i can do this with cvget*D and cvscalar

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