image editing

Started by
2 comments, last by darookie 19 years, 3 months ago
hi, i'm really new at image processing and i was hoping that someone here could teach me, or lend me any JAVA or C code which will allow me to edit an image pixel by pixel. i would really appreciate all the help i can get. thank you very much. p.s. this is for my undergraduate thesis... i nid help. thanks again.
Advertisement
This code reads a 32-bit RGBA .tga image, and lets you manipulate the pixels. It does not error-check the format (i e, other formats will cause undefined behavior):

#include <stdio.h>class TgaImage {unsigned short tgaHeader[9];unsigned int * pixels;unsigned int xSize;unsigned int ySize;public:TgaImage( char const * path ) {  FILE * f = fopen( path, "rb" );  fread( tgaHeader, 2, 9, f );  xSize = tgaHeader[6];  ySize = tgaHeader[7];  pixels = new unsigned int[ xSize*ySize ];  fread( pixels, 4, xSize*ySize, f );  fclose( f );}~TgaImage() {  delete[] pixels;}unsigned int pixelAt( unsigned int x, unsigned int y ) const {  return pixels[x+y*xSize];}void setPixelAt( unsigned int x, unsigned int y, unsigned int pixel ) {  pixels[x+y*xSize] = pixel;}};


On x86 hardware, the pixel format is 0xaarrggbb, i e 0xff000000 would be opaque black, and 0x0000ff00 would be bright green.

Disclaimer: I typed this code into the posting box from scratch.
enum Bool { True, False, FileNotFound };
thanks, i wil try that. ü anyway, describing specifically what i plan to do: i actually nid a (java or c) code snippet because i will just be embedding that method into a larger system. i have just a implemented a skin color detection program and the output of that program is that it identifies each pixel as to whether it is under skin color or not. what i would like to do is to edit the same image that i used, convert all pixels that were determined to be skin into white and all the rest into black, is there any way to do that? thanks.
Use an image processing library such as NexgenIPL (click "Products" in the navigation bar to get to the download page). Writing your own image load/save/manipulation code is time-consuming and error-prone. A library that takes care of this part will let you focus on your manipulation algorithm.

Good luck,
Pat.

This topic is closed to new replies.

Advertisement