Skip to main content
GameDev.net gamedev.net
🔒 Locked

image editing

Started by superchritch Jan 2, 2005 at 9:10 PM 2 replies 1.1k views
Original Post
superchritch
superchritch
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.
smitty1276
smitty1276
That's a bit confusing... if you just want to edit an image, use Paint Shop Pro or Photoshop or something.

If you want to learn to LOAD an image, goto nehe.gamedev.net and look though the tutorials until you find the one about loading BMP files (I'm pretty sure there is one in there).

As for code to allow for "editing", you will have to write that yourself, as it is a huge topic and the features to be included would be something of a personal decision.

(I suppose you could download the GIMP source).
superchritch
superchritch
thanks. actually i 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.
a38750
a38750
What you need to learn is how to load and save an image file format. When you've loaded your image, the pixel data is simply stored in an array, so you can do whatever operations you want on the pixels simply by iterating through the array. Here's an overview of a load/edit/save system:

struct pixel_t {    byte red, green, blue;};struct image_t {    int width, height;    pixel_t *pixel_data;};image_t *load_image(const char *file){    image_t *image = new image_t;    //open the file, read in the info you need    //eg. width and height    image->pixel_data = new pixel_t[image->width*image->height];    //read the pixel data in from the file either directly into    //image->pixel_data (if the format permits), or by loading    //into a temporary buffer and copying into image->pixel_data    //pixel by pixel    return image;}void my_image_edit(image_t *image){    for(int i=0; i<(image->width*image->height); ++i) {        //do what you want with image->pixel_data    }}void save_image(const image_t *image, const char *file){    //open the file, write out the image    //in the format of the file}


Hope that helps.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.