Thread: Good Image Library

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    54

    Good Image Library

    Hi, I am looking to write my own digital watermarking program. So i need a library that can extract the RGB values from an image into a matrix form, so then I can do some kind of transform on the martix, change a few values and then transform back.

    I found this one, but I could not get it working with DevC++

    http://www.ient.rwth-aachen.de/team/...al/genial.html

    Can anyone recommend a good library to use?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    In what way could you not get that library to work in Dev-C++? Could you not get a program to compile or link?

    That's a C++ library, whilst this is the C forum -- what language are you actually using?

    Hi, I am looking to write my own digital watermarking program.
    I don't know what's involved in doing this, but it sounds complicated . . . why are you doing this? Do you want to use an existing library?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    54
    when i included all of the genial header files into my project all of the files that those headers themselfs linked to gave errors saying that the file did not exist..

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Why not use something simple AND written in C like libgd ?

  5. #5
    Registered User kroiz's Avatar
    Join Date
    Jun 2007
    Posts
    116
    ImageMagik can manipulate images and has watermark capabilities.

  6. #6
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    I am looking to write my own digital watermarking program. So i need a library that can extract the RGB values from an image into a matrix form, so then I can do some kind of transform on the martix, change a few values and then transform back.
    You should be able to do this with nothing more than the image file load/save functions.

    To extract the RGB colour components you can either read the image data byte at a time or use bit shifting to extract colour components. But I doubt you would even need that.

    Say if your watermark was to slightly lighten each pixel its applied to by 1 in r, g, and b. you could 'and' each pixel on your image with a bitmask of the watermark. For each pixel to be modified you could then 'or' the existing colour with itself plus 0x010101 to increment r,g, and b in one go. To extract a watermark its just a matter of subtracting the original from a watermarked image.

    Just some ideas for you.
    Last edited by mike_g; 09-24-2007 at 04:28 AM.

  7. #7
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Okay, i realised that post I made above was a bit wrong. Anyway I knocked up a quick working watermark adder in Basic and had a go at converting it to C. I havent tested this yet, but I think it ought to work. As long as I'm not doing bad stuff with the memory (as I usually do).
    Code:
    #define Uint8  unsigned char
    #define Uint16 unsigned short
    #define Uint32 unsigned int
    
    #define COLOUR_MARK 0x00FFFFFF
    #define COLOUR_HILIGHT 0x00FF0000
    
    #define ERROR_DRAW_OUT_OF_BOUNDS 1
    #define ERROR_UNEQUAL_DIMENSIONS 2
    
    struct image
    {
        Uint16 w, h;
        Uint32 *pixel;
    }typedef struct image image;
    
    /* 
       This function draws a watermark to an image
       x_pos / y_pos = start point on image to draw the watermark
       *pic = pointer to image
       *mark = pointer to watermark image 
    */
    int AddWatermark(Uint32 *pic, Uint32 *mark, Uint16 x_pos, Uint16 y_pos)
    {
        if(x_pos + mark.w > pic.w) return ERROR_DRAW_OUT_OF_BOUNDS;
        if(y_pos + mark.h > pic.h) return ERROR_DRAW_OUT_OF_BOUNDS;
    
        Uint8 r, g, b;       
        Uint16 x, y;
        Uint16 scanline = pic.w*4;
        Uint32 *m_ptr = mark.pixel;
        Uint32 *p_ptr = pic.pixel+(y_pos*scanline)+(x_pos*4); 
        
        for(y=0; y<mark.h; y++)
        {
            for(x=0; x<mark.w; x++)
            {
                if(*m_ptr == COLOUR_MARK)
                {
                    r = (*p_ptr >> 16) & 255;   //Get colour elements
                    g = (*p_ptr >> 8) & 255;
                    b = *p_ptr & 255;
                    if(r < 255) r+=1;           //Add watermark to elements
                    if(g < 255) g+=1;
                    if(b < 255) b+=1;
                    *ptr = (r<<16)+(g<<8)+b;    //Write data back to pixel
                }
                p_ptr+=4;
                m_ptr+=4;            
            }
            p_ptr += scanline;
        }  
        return 0;
    }
    
    /* This function hilights pixels on a watermarked image that don't match the original
       *origin = handle for unaltered image
       *marked = handle for watermarked image 
    */
    int GetWatermark(Uint32 *origin, *marked)
    {
        if(origin.w != marked.w) return ERROR_UNEQUAL_DIMENSIONS;
        if(origin.h != marked.h) return ERROR_UNEQUAL_DIMENSIONS;   
    
        Uint32 *o_ptr = origin.pixel;
        Uint32 *m_ptr = marked.pixel;
        Uint16 x, y;
        for(y=0; y<origin.h; y++)
            for(x=0; x<origin.w; x++, o_ptr+=4, m_ptr+=4)
                if(! (*m_ptr - *o_ptr)) //Hilight pixels that don't match the original
                    *m_ptr = COLOUR_HILIGHT; 
    }
    Also something I was wondering was if someone were to hide text in watermarks, that would pretty much be uncrackable to anyone that dident have the original image right? Seems like it could make some kickass encryption
    Last edited by mike_g; 09-25-2007 at 12:56 AM.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It's called steganography
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. image analysis theory: mapping a network
    By elninio in forum C++ Programming
    Replies: 5
    Last Post: 10-30-2008, 01:23 PM
  2. HotSpot image controls (web)
    By novacain in forum C# Programming
    Replies: 0
    Last Post: 06-25-2008, 04:27 AM
  3. A good graphics library?
    By Devils Child in forum C++ Programming
    Replies: 44
    Last Post: 01-26-2008, 10:44 AM
  4. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  5. A Good Graphics Library
    By Imperatus in forum C Programming
    Replies: 1
    Last Post: 06-26-2003, 03:08 AM