'Array too small for DCT transformation in LabWindows CVI
I have been doing a school project about digital watermark based on DCT using LabWindows CVI 2012. I divide an image with the size of 512 * 512 into many 8 * 8 blocks, and then use DCT transformation on each of them. But there is an error message that the input array is too small. I don't know which part I do wrong, can someone help me with this?
int CVICALLBACK Img_to_array (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char *Arraydata;
Point point;
int x,y;
PixelValue pixelvalue;
imaqGetImageSize(SourceImage,&width,&height);
switch (event)
{
case EVENT_COMMIT:
Arraydata = imaqImageToArray (SourceImage, IMAQ_NO_RECT, NULL, NULL);
for(y=0;y<height;y++)
{
for(x=0;x<width;x++)
{
point.x=x;
point.y=y;
imaqGetPixel (SourceImage,point,&pixelvalue);
Arraydata[y*width+x]=(char)pixelvalue.grayscale;
}
}
//-----------divide into 8*8 block and DCT transform-------------
char block[8][8];
char dct_block[8][8];
int i,j,row,column;
for(x=0;x<width/8;x++)
for(y=0;y<height/8;y++)
{
for(row=0,j=0;row<8;row++,j++)
for(column=0,i=0;column<8;column++,i++)
block[row][column]=Arraydata[(x*8+i)+(y*512*8+j*512)];
DCT2D (block, 8, 8, dct_block);
for(row=0,j=0;row<8;row++,j++)
for(column=0,i=0;column<8;column++,i++)
Arraydata[(x*8+i)+(y*512*8+j*512)]=dct_block[row][column];
}
//---------------------------------------------
imaqArrayToImage (DestImage, Arraydata, width, height);
imaqSetWindowTitle (1,"AfterDCT result");
imaqMoveWindow (1,imaqMakePoint(150,260));
imaqDisplayImage (DestImage,1,TRUE);
break ;
}
return 0;
}
Here is the error info: https://i.stack.imgur.com/jemUk.png
Here is the function DCT2D info: https://zone.ni.com/reference/en-XX/help/370051AG-01/cvi/libref/cvidct2d/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|