Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

RGB representation of an image

Thread view: 
Marcelo - 14 Nov 2005 22:54 GMT
Dear all,

It has been at most one hour that I look for a RGB representation of an
image. I have found BufferedImage, but this class doesn't really do what
I need.

I would like to get something like

int [][][] matrixRGB;
matrixRGB = image.getRGB_Representation();

do you have an idea where to get something like that? (a class for
exemple?? )

thanks a lot,

Marcelo
Thomas Fritsch - 14 Nov 2005 23:54 GMT
> It has been at most one hour that I look for a RGB representation of an
> image. I have found BufferedImage, but this class doesn't really do what I
[quoted text clipped - 7 lines]
> do you have an idea where to get something like that? (a class for
> exemple?? )
To get the RGB pixels of a BufferedImage into one or more int arrays you can
use method
 public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray,
int offset, int scansize)
of class BufferedImage. (see the javadoc)
For example, to get all the pixels into one large array:
   BufferedImage image = ...;
   int w = image.getWidth();
   int h = image.getHeight();
   int rgbArray[] = new int[w * h];
   image.getRGB(0, 0, w, h, rgbArray, 0, w);
If instead you want to get the pixels into several subarrays, you would need
to call image.getRGB(...) several times.

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

Marcelo - 15 Nov 2005 00:22 GMT
Thanks a lot,

I have just another remaining question. So, for having a 3D matrix for
the RGB representation, I should call the function several times, but
how is the return type? Do I get first all the R values, then the G
values and at last the B values?

RRRRRRRRRRRGGGGGGGGGGGGGGBBBBBBBBBBB

or is it different ?

thanks a lot,

Marcelo

int r
> To get the RGB pixels of a BufferedImage into one or more int arrays you can
> use method
[quoted text clipped - 9 lines]
> If instead you want to get the pixels into several subarrays, you would need
> to call image.getRGB(...) several times.
Thomas Fritsch - 15 Nov 2005 02:26 GMT
> I have just another remaining question. So, for having a 3D matrix for the
> RGB representation, I should call the function several times, but how is
[quoted text clipped - 4 lines]
>
> or is it different ?
It is different (something like  ARGBARGBARGB...).
When calling BufferedImage.getRGB(..., rgbArray, ...) you get an ARGB value
in each array element of your int[] array. The first int contains the ARGB
value of the first pixel, the second int the ARGB value of the second pixel,
...
Each int contains a packed ARGB value: 8 bits for A (the opacity), 8 bits
for R, 8 bits for G, 8 bits for B.

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

Roedy Green - 15 Nov 2005 06:36 GMT
>I would like to get something like
>
>int [][][] matrixRGB;
>matrixRGB = image.getRGB_Representation();

PixelGrabber is used for extracting rgb bits from rectangles in an
image.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.