PDA

View Full Version : JAI


Isengard
07-19-2002, 05:40 AM
I`m doing some programming with the JAI, Java Advanced Imaging, API.
I`ve used the classes already there, but what I would like to do is get an image represented as a matrix. I know this is possible .. is there any easy command to get "imagex.jpg" into int[] [] ? I need this for some edge detection classes I`ve written.

Dru Lee Parsec
07-19-2002, 02:08 PM
I did some work almost 2 years ago where I had to translate a jpeg or gif into a wbmp for use on a WAP enabled phone. I have the code at home, but off hand I don't remember how I did it.

I'm pretty sure that I was able to get a 2D array out of the jpeg or gif. I just don't remember how. If I can find the code at home tonight or this weekend I'll send it to you.

Isengard
07-22-2002, 03:59 AM
That would be great!
I`ve seen some examples where people are using 2d arrays. On http://www.dai.ed.ac.uk/HIPR2/ they have loads of java code samples, but none show the convertion to the array itself.

Dru Lee Parsec
07-22-2002, 12:09 PM
Aarrggh! Sorry Isengard. I totally forgot about the code this weekend. I'll try to remember tonight

/me emails myself at home to remember

Dru Lee Parsec
07-23-2002, 10:27 PM
Isengard :

I think I may have found it:


ImageIcon imgIcon = new ImageIcon(url);
Image image = imgIcon.getImage();
if(width <= 0) {
width = imgIcon.getIconWidth();
}
if(height <= 0){
height = imgIcon.getIconHeight();
}
int factor = 30;
int buffer[] = new int[width*height];

PixelGrabber grabber = new PixelGrabber(image.getScaledInstance(width,height,Image.SCALE_DEFAULT),0,0,width,height,buffer,0,wid th);





After the Pixel Grabber line the contents of the array called "buffer" should be your image as an array.

Isengard
07-24-2002, 03:30 AM
GREAT! Tnx!
It even worked ;)

kmj
07-24-2002, 10:12 AM
Originally posted by Isengard
GREAT! Tnx!
It even worked ;)

heh; it's good to know dru is giving out good info; not trying to screw us over or something

<evil java guru audience=himself>Heheheh... Only I possess the power of Java!!!!</evil java guru>
<evil java guru audience=cf.net>Yesss, Yesss; you mussst firssst cassst all valuesss to boolean; and never use try/catch blocksss!
</evil java guru>

Dru Lee Parsec
07-24-2002, 03:50 PM
<Dr. Evil voice>

But now, my friend Isengard, you must ask yourself this question:

Shall I use my new found Java knowledge for good?

Or EVIL?

</Dr. Evil voice>

KMJ:

What doesss itsss have in it'ssss pocketssssss?