Re: Image reading program




khaleel.alyasini@xxxxxxxxx wrote:
Hello sirs & madams,

I'm currently working on DCT compression algorithm as my project. My
knowledge on C++ and DSP is rather weak/moderate. I was wondering if
any could help me and teach me the guidelines of DCT image compression.
Basically, this is my coding in C++ on extracting pixels values from a
RAW image file. It has errors, anyone could help me?

Nitpicking, but the .h headers suggest C or a very old C++ compiler.



#include <iostream.h>
#include <stdio.h>
#include <math.h>
#include <fstream.h>
#include <conio.h>
#include <malloc.h>
#include <iomanip.h>

#define pix 256
int v[pix][pix];

void main()
{
unsigned char pixelvalues[pix][pix];

/********************/
/* READ */

ifstream rawimage("lena.raw");
if(!rawimage)
{
cerr<<"Error in reading file\n";
}

for(int i=0; i<pix; i++)
{
for(int j=0; j<pix; j++)
{
rawimage>>pixelvalues[j][i];
}
}
rawimage.close();

/********************/
/* DISPLAY */
for(int m=0; m<pix; m++)
{
for(int n=0; n<pix; n++)
{
cout<<pixelvalues[n][m]<<" ";
}
cout<<"\n";
}
}

by the way, when i run this program, the output shows the values in
unsigned char, how to convert to decimal values in C++? anyway, what's
the next step in image compression by using DCT algorithm?


Sci.image.processing for the image processing part.

In these situations, my advice is always to create yourself a little
toolkit; maybe your time is short, but it will pay off. In fact, the
chance of you achieving anything the way you are going is slim. With
the toolkit you can divide up the problem; as it is, the required
program is large and complex and too difficult to think about and/or
implement and test in bits.

And you'll learn nothing.

If you can do it in C++, create a very simple Image class. Represent
the image as double or float; use set(value, row, col) to write; use
double get(row, col) to read. You probably need utility stuff like max,
min; and a constructor which creates an image and sets all pixels to
zero.

If you are in a big hurry, you might even get away with a
representation like

private:

double image[MAXNR][MAXNC];

Then I would write a 'print' that prints to a stream.

And maybe a 'print' that prints to a simple graphics file format like
PGM; that gives you a method of display.

Maybe someone can suggest a lightweight image processing toolkit / API
that you can use.

A DCT shouldn't be hard to find.

Best regards,

Jon C.

.



Relevant Pages

  • Re: dct implementation with blocks
    ... > one of the main step of dct based compression of a data sequence X, ... Then DCT computation for each block is applied. ... > DCT directly the whole data sequence X? ... There is more correlation between close-by pixels than between a pixel ...
    (comp.soft-sys.matlab)
  • Re: Lossless compression on a GPU
    ... to work at will outrun a CPU anyway. ... apart from expensive compression strategies (such as arithmetic coding), unless the GPU can exceed 500MB-1GB/sec, it is hard-pressed to beat out a CPU side decoder. ... I also have an optionally lossless codec, basically resembling an M-JPEG/MPEG-1 hybrid using WHT and RCT instead of DCT and YCbCr, albeit its raw speed isn't particularly impressive. ...
    (comp.arch)
  • Image reading program
    ... I'm currently working on DCT compression algorithm as my project. ... any could help me and teach me the guidelines of DCT image compression. ...
    (comp.programming)
  • Image reading program
    ... I'm currently working on DCT compression algorithm as my project. ... any could help me and teach me the guidelines of DCT image compression. ...
    (sci.image.processing)
  • Re: Image reading program
    ... I'm currently working on DCT compression algorithm as my project. ... What is a RAW image file? ...
    (sci.image.processing)