473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

seperating pixel values to DCT blocks

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::out|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]<<" ";
}
}

Mar 19 '06 #1
3 2328
kh**************@gmail.com 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::out|ios::binary); ditto for ofstream.
[remainder redacted by red floyd]
}

Mar 19 '06 #2

kh**************@gmail.com 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.

Mar 20 '06 #3
thanks for the info. any ideas on how to implement DCT formulas in C++?
1-D DCT should be okay ;) thanks in advance

Mar 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Veerle | last post by:
Hi, I have 2 div blocks with each div taking up half of the page width. So in the CSS they both have width: 50%. See http://home.scarlet.be/~vv991306/leftright.html In Mozilla Firefox and...
10
by: unknown | last post by:
some one can give me a portable source codes that color a pixel? (env *nix) -- unknown
7
by: TomHL | last post by:
hello, - I have a Bitmap Object named: bmp1 - I already have the numerical values of:red,blue and green colors + I have the X and Y cordinates. How do I set the pixel value via safe code on...
7
by: walter.alex | last post by:
November 16 2005 -- The recent launch of the new 5 year advertising solution from MillionPixelClick.com means the pixel advertising craze will continue unabated. Selling advertising space by the...
2
by: fripper | last post by:
I want to generate a graphic in a picture box control where the color of each pixel is determined by particular values calculated for each pixel. These values are manipulated in such a way that I...
2
by: fripper | last post by:
I am using VB 2005 and want to generate a graphic in a picture box control where the color of each pixel is determined by particular values calculated for each pixel. These values are manipulated...
33
by: Dave (DreamIsle) | last post by:
Hello. I'm working on a layout that I need to be pixel specific. How can I get the font to stay precisely the height I need? Specifying line-height or font-size in px doesn't yield the results I...
30
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
2
by: ajay_itbhu | last post by:
Hi everyone, I want to read the pixel values of 2 similar images in bitmap format like 2 continuous frame of a video for calculating the median. But i dont know how to read the pixel values of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.