Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Loading in images

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Loading in images

    I have 2 questions about loading in images..

    First of all is there a way to load images in 3 dimensional matrices ? As in matlab?
    Here is a piece of a matlab 'script' I made to make a puzzle from an images:

    function [] = puzzel(naam, N);
    afb = imread(naam);
    resolutie = size(afb);
    afm = resolutie(1);
     
    x = sqrt(N);
     
    for i = 1:3
        for j=1:afm/x
            for k=1:afm/x
                afb(afm-afm/x+j,afm-afm/x+k,i) = 0;
            end;
        end;
    end;
     
    randm = fix(rand(1)*40+10)
    for o = 1:randm
    hop1= floor(rand*(x))+1;
    hop2= floor(rand*(x))+1;
    hip1= floor(rand*(x))+1;
    hip2= floor(rand*(x))+1;
    for i = 1:3
        for j=1:afm/x
            for k=1:afm/x
            im1 = afb(afm-hop1*afm/x+j,afm-hop2*afm/x+k,i);
            im2 = afb(afm-hip1*afm/x+j,afm-hip2*afm/x+k,i);
            afb(afm-hop1*afm/x+j,afm-hop2*afm/x+k,i) = im2;
            afb(afm-hip1*afm/x+j,afm-hip2*afm/x+k,i) = im1;
            end;
        end;
    end;
    end;
    image(afb);

    Now as you can see, afb contains the image, and afb is a 3 dimensional matrix : ) x:y:1 -> red x:y:2 -> green, etc

    Is there a way to do the same with java?

    Another thing, if there is a way (of if there isn't, referring to the previous question).
    Is there a way to load the image that is currently in your clipboard ?


    Greetings,
    Pieter


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Loading in images

    Loading things from the Clipboard can sometimes be a pain, but look at the Clipboard (Java 2 Platform SE 5.0).If you are doing this through an applet you will most likely have security issues in which you must sign the applet for Clipboard access.

    As far is a 3D image, I don't think Java has a standard class, but you could create your own through either arrays representing the 3D architecture of the RGB values, or create an array of BufferedImage (Java 2 Platform SE v1.4.2)

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Loading in images

    Quote Originally Posted by copeg View Post
    Loading things from the Clipboard can sometimes be a pain, but look at the Clipboard (Java 2 Platform SE 5.0).If you are doing this through an applet you will most likely have security issues in which you must sign the applet for Clipboard access.

    As far is a 3D image, I don't think Java has a standard class, but you could create your own through either arrays representing the 3D architecture of the RGB values, or create an array of BufferedImage (Java 2 Platform SE v1.4.2)
    Since I have no experience with images in java I'll give that bufferedimages a try.

    Btw, 3d images? Are you sure you know what I meant..? The images are clearly just 2d, but they get represented by a 3d matrix, because every pixel get's represented by 3 colours, red green blue, anyway, I'll do some research on that

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Loading in images

    Quote Originally Posted by eXcellion View Post
    Btw, 3d images? Are you sure you know what I meant..?
    Nope, not sure at all I was thinking you had images as a "z-stack" of 2D images...BufferedImage is probably what you are looking for. For example, to read an image:

    BufferdImage image = ImageIO.read(new File("/local/path/to/your/image"));
    You can access all RGB pixel values via BufferedImage (it is more like a 2D matrix for each row/column pixel of the image), create a Graphics from the object for drawing or altering the image, or use it to draw directly to a graphics object for GUI drawing in swing.
    Last edited by copeg; January 17th, 2010 at 12:53 PM.

Similar Threads

  1. Prob in Loading Textures
    By sikriyogesh in forum Java Theory & Questions
    Replies: 0
    Last Post: December 15th, 2009, 05:59 AM
  2. Embedding images in a matrix.
    By Aims_ in forum Java Theory & Questions
    Replies: 1
    Last Post: September 11th, 2009, 02:37 PM
  3. Images not going in email
    By anjali09s in forum Java SE APIs
    Replies: 3
    Last Post: August 2nd, 2009, 06:06 PM
  4. Replies: 3
    Last Post: April 14th, 2009, 08:35 AM
  5. What are the best way of placing images in GUI?
    By Ciwan in forum AWT / Java Swing
    Replies: 5
    Last Post: February 26th, 2009, 05:19 PM