473,799 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::bi nary);
if(!rawimage)
{
cerr<<"Error in reading file\n";
exit(1);
}
ofstream dctblock("dct.t xt", ios::out|ios::b inary);
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>>pixel values[k];
}
}
/*************** *****/
/* DCT BLOCK */

for(int jumper=0; jumper<pix; jumper=jumper+8 )
{
for(int vertjump=1; vertjump<2304; vertjump=vertju mp+255)
{
for(int count=0; count<8; count++)
{
countA=(count*v ertjump);
arraytwo[x++]=pixelvalues[countA];
}
}
}
for(int test=0; test<pix; test++)
{
for(int mest=0; mest<pix; mest++, kh++)
{
dctblock<<array two[kh]<<" ";
}
}

Mar 19 '06 #1
3 2360
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::bi nary); ifstream and ios are in namespace std

if(!rawimage)
{
cerr<<"Error in reading file\n";
exit(1);
}
ofstream dctblock("dct.t xt", ios::out|ios::b inary); 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
4916
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 Opera, depending on the width of the browser window, sometimes there is a 1 pixel gap between the 2 div blocks. In Internet Explorer, this is never the case.
10
3110
by: unknown | last post by:
some one can give me a portable source codes that color a pixel? (env *nix) -- unknown
7
3601
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 the bmp1 object? (the pixel location based on the X & Y values and it's color based on the red,blue and green values the I already have)
7
1751
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 pixel the new form of advertising is proving popular with both clients and providers alike. Designed to boost traffic, an image is placed on MillionPixelClick.com with a link to your website. These pixels will be visible for at least 5 years....
2
3465
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 come up with three values (each in the range 0-`55) and I want to use these for the RGB values of the color of the associated pixel. My question is: In VB 2005 how do I set a particular pixel to a color with a given set of RGB values? In VB 6 I...
2
2030
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 in such a way that I come up with three values (each in the range 0-155) and I want to use these for the RGB values of the color of the associated pixel. My question is: In VB 2005 how do I set a particular pixel to a color with a given set of...
33
2440
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 need. The font size scales when I change the browser's font size and the text moves from where I need it.
30
9088
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 450-1000 milliseconds I want speeds less than 10 milliseconds
2
9637
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 bitmap image.so please help me in doing this in c++. thank you.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10470
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10247
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.