Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Colouration Image

  1. #1
    RafalD is offline Member
    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    Default Colouration Image

    Hi!

    Does anyone know, how can i make program that will make colouration image?

    Like this:
    Colouration Image-orginal.gif
    to example this:
    Colouration Image-colorize.gif
    or example this:
    Colouration Image-colorize2.gif

    (made in Gimp)

    Program will be transform entrance image to new image after user give main color new image.
    I try make program with java.awt library, but i think it's very hard.
    I started use JMagick, but i don't see right methods(with right filter).

    You know suitable library or way to make this program? (I don't want finished solution, only help)

    Greetings,
    Rafał

    PS: Sorry for my bad english.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Colouration Image

    Are the images monochromatic? That is, do they contain different saturation/intensities of just one hue?

    If so, you should be able to obtain the saturation/intensity (or brightness) values using a RGB to HSI /HSB convertor, then generate new RGB values after changing the Hue.

    But before that, are you familiar with the BufferedImage API?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    RafalD is offline Member
    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    Default Re: Colouration Image

    I don't know. Images are in gif and png and they are on the website (background, bar, box). They have not many colour's. My job is to do the generator changing styles all pictures from pages for a specific color. With BufferedImage I can't do this. Colors don't change in simple way. It is like on this forum. They are dark blue bar, light blue bar etc. and i want change e.g. to dark green, light green and respectively.
    Last edited by RafalD; 12-07-2012 at 07:42 PM.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Colouration Image

    Do you know and understand the RGB / HSI / HSB color models? If you don't, then start by learning about them.

    db
    RafalD likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    RafalD is offline Member
    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    Default Re: Colouration Image

    RGB i know. HSB it's HSV? And HSI? You mean HSL? Overall, I do not know too much about the graphics.
    Conversion and change of color I think might help. I had not thought about it, thanks.
    I try it on Monday.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Colouration Image

    Yup, HSL is also a good bet. (B=Brightness, I=Intensity, L=Luminance). A blog post by one of our members, camickr, should be useful: HSL Color Java Tips Weblog

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    RafalD is offline Member
    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    Default Re: Colouration Image

    Another problem.
    When I read a image with some transparent pixel I cann't read alfa. I use pixel.getAlpha() and always i get 255(inclusive pixel with real 0 alpha). In new image i can change alpha, but i don't know which pixels without information about their start alfa.
    For example:
    It:
    Colouration Image-s-arrow.gif
    is changed to:
    Colouration Image-s-arrow.gif

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Colouration Image

    Unless you show us the code that reads the images*, I don't see how anyone can even try to help.

    * preferably in the form of a SSCCE (Short, Self Contained, Correct (Compilable), Example) that downlads an image from the net and adequately demonstrates the problem.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    RafalD is offline Member
    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    Default Re: Colouration Image

    It is Code(shortened,cuted - program normaly make more, but it is not important):
    Java Code:
    import java.awt.Color;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    
    public class generator {
          public static void main(String[] args) {
                String infilename = "img/graphist.gif";
                String outfilename = "img/new_graphist.gif";
                int ccolor;
                Color color;
                int width=0;
                int height=0;
                File inputFile = new File(infilename);
                File outputFile = new File(outfilename);
                BufferedImage graph = null;
                try
                {
                      graph=ImageIO.read(inputFile);
                      width=graph.getWidth();
                      height=graph.getHeight();
                      BufferedImage new_graph = new BufferedImage(width,height,BufferedImage.TYPE_4BYTE_ABGR );
                      for(int x=0;x<width;x++)
                      {
                            for(int y=0;y<height;y++)
                            {
                                 ccolor=graph.getRGB(x,y);
                                 color=new Color(ccolor);
                                 new_graph.setRGB(x, y,(color.getRed() << 16)|(color.getGreen() << 8)|color.getBlue()|(color.getAlpha() << 24));
                            } 
                      }
                      ImageIO.write(new_graph,"gif",outputFile);
                } catch (IOException e) {
                      e.printStackTrace();
              }
          }
    }
    And there are example images.
    Oryginal: New image:
    Colouration Image-graphist.gif Colouration Image-new_graphist.gif

    Earlier I change Alpha to 0 where are Red==64, green=255 and Blue==64, but it is not in all images.

  10. #10
    RafalD is offline Member
    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    Default Re: Colouration Image

    Does anyone know, how to correctly load a picture with alpha?
    My method read in all pixels 100%(255) alpha. I don't know why.

Similar Threads

  1. Replies: 4
    Last Post: 12-07-2012, 12:44 PM
  2. Replies: 4
    Last Post: 08-09-2012, 07:18 PM
  3. Replies: 1
    Last Post: 07-28-2011, 09:48 AM
  4. Replies: 0
    Last Post: 01-08-2008, 06:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •