• January 16th, 2010, 04:35 PM
eXcellion

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:

Code :

```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
• January 16th, 2010, 08:44 PM
copeg
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)
• January 17th, 2010, 06:06 AM
eXcellion
Quote:

Originally Posted by copeg
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
• January 17th, 2010, 11:13 AM
copeg
`BufferdImage image = ImageIO.read(new File("/local/path/to/your/image"));`