Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > seperating pixel values to DCT blocks

Reply
Thread Tools

seperating pixel values to DCT blocks

 
 
khaleel.alyasini@gmail.com
Guest
Posts: n/a
 
      03-19-2006
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+
{
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]<<" ";
}
}

 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      03-19-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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>


With the exception of stdlib.h, all of these are non-standard headers.
#include <iostream>
#include <fstream>
#include <iomanip>

>
> const int pix=256;
> static const double pi = 3.141593;
>
>
>
>
> int main()
> {
> [redacted by red floyd]
> if(pixelvalues == 0)
> {
> cout<<"Memory allocation failed !\n";


cout is not defined in the global namespace -- should be std::cout.

> exit(1);
> }
>
>
> /********************/
> /* READ */
>
> ifstream rawimage("lena.raw", ios::in|ios::binary);

ifstream and ios are in namespace std


> if(!rawimage)
> {
> cerr<<"Error in reading file\n";
> exit(1);
> }
>
>
> ofstream dctblock("dct.txt", ios:ut|ios::binary);

ditto for ofstream.

> [remainder redacted by red floyd]
> }

 
Reply With Quote
 
 
 
 
BigBrian
Guest
Posts: n/a
 
      03-20-2006

(E-Mail Removed) wrote:
> pixelvalues = new unsigned char [pix*pix];
> if(pixelvalues == 0)
> {
> cout<<"Memory allocation failed !\n";
> exit(1);
> }



new() will not return 0 even if memory cannot be allocated unless you
use std::nothrow, so your if test will never be true.

 
Reply With Quote
 
khaleel.alyasini@gmail.com
Guest
Posts: n/a
 
      03-20-2006
thanks for the info. any ideas on how to implement DCT formulas in C++?
1-D DCT should be okay thanks in advance

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
procs/blocks - blocks with procs, blocks with blocks? matt Ruby 1 08-06-2004 01:33 AM
Re: Pixel size of individual Pixel Robert E. Williams Digital Photography 2 09-16-2003 03:02 PM
Re: Pixel size of individual Pixel Tom Thackrey Digital Photography 2 09-14-2003 04:17 PM
Hot pixel vs. stuck pixel Abrasha Digital Photography 5 09-02-2003 04:49 PM



Advertisments