K
khaleel.alyasini
Hi, currently I'm working on DCT algorithm on C++. I was wondering if
anyone out there could point me out how to seperate the pixel values
into DCT blocks. Here, i have enclosed my source code(incomplete).
specs:
1. seperates pixels values into block of 8x8
2. stores the values in a new pointer.
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <iomanip.h>
const int pix=256;
static const double pi = 3.141593;
int main()
{
int l=0, k=0, x=0, kh=0, countA;
int * arraytwo;
arraytwo = new int [pix*pix];
unsigned char * pixelvalues;
pixelvalues = new unsigned char [pix*pix];
if(pixelvalues == 0)
{
cout<<"Memory allocation failed !\n";
exit(1);
}
/********************/
/* READ */
ifstream rawimage("lena.raw", ios::in|ios::binary);
if(!rawimage)
{
cerr<<"Error in reading file\n";
exit(1);
}
ofstream dctblock("dct.txt", ios:
ut|ios::binary);
if(!dctblock)
{
cerr<<"Error in reading file\n";
exit(1);
}
for(int i=0; i<pix; i++)
{
for(int j=0; j<pix; j++, k++)
{
rawimage>>pixelvalues[k];
}
}
/********************/
/* DCT BLOCK */
for(int jumper=0; jumper<pix; jumper=jumper+8)
{
for(int vertjump=1; vertjump<2304; vertjump=vertjump+255)
{
for(int count=0; count<8; count++)
{
countA=(count*vertjump);
arraytwo[x++]=pixelvalues[countA];
}
}
}
for(int test=0; test<pix; test++)
{
for(int mest=0; mest<pix; mest++, kh++)
{
dctblock<<arraytwo[kh]<<" ";
}
}
anyone out there could point me out how to seperate the pixel values
into DCT blocks. Here, i have enclosed my source code(incomplete).
specs:
1. seperates pixels values into block of 8x8
2. stores the values in a new pointer.
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <iomanip.h>
const int pix=256;
static const double pi = 3.141593;
int main()
{
int l=0, k=0, x=0, kh=0, countA;
int * arraytwo;
arraytwo = new int [pix*pix];
unsigned char * pixelvalues;
pixelvalues = new unsigned char [pix*pix];
if(pixelvalues == 0)
{
cout<<"Memory allocation failed !\n";
exit(1);
}
/********************/
/* READ */
ifstream rawimage("lena.raw", ios::in|ios::binary);
if(!rawimage)
{
cerr<<"Error in reading file\n";
exit(1);
}
ofstream dctblock("dct.txt", ios:
if(!dctblock)
{
cerr<<"Error in reading file\n";
exit(1);
}
for(int i=0; i<pix; i++)
{
for(int j=0; j<pix; j++, k++)
{
rawimage>>pixelvalues[k];
}
}
/********************/
/* DCT BLOCK */
for(int jumper=0; jumper<pix; jumper=jumper+8)
{
for(int vertjump=1; vertjump<2304; vertjump=vertjump+255)
{
for(int count=0; count<8; count++)
{
countA=(count*vertjump);
arraytwo[x++]=pixelvalues[countA];
}
}
}
for(int test=0; test<pix; test++)
{
for(int mest=0; mest<pix; mest++, kh++)
{
dctblock<<arraytwo[kh]<<" ";
}
}