aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Need Faster way to get RGB value for each Pixel of a Buffered Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need Faster way to get RGB value for each Pixel of a Buffered Image" Watch "Need Faster way to get RGB value for each Pixel of a Buffered Image" New topic
Author

Need Faster way to get RGB value for each Pixel of a Buffered Image

ashish donvir
Greenhorn

Joined: Mar 01, 2012
Posts: 25
What is the to get RGB value of each pixel of a Buffered Image?

Right now i am getting RGb value using two for loops as shown in code below but it took too much long time to get rgb values as loop runs 479999 times for my image and it can even rise when i will use 16 bit image.

SO i need some faster way to get pixel values

here is my code what i tried

Charles Burton
Ranch Hand

Joined: Jan 31, 2011
Posts: 39

Did you try this?

Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

What Charles said.
Depending on the console implementation of your output, the call to print and println might be very time consuming.
You should not use that in time critical loops or methods.
You should consider Charles answer anyway. It is better than your solution.


Please correct my English.
ashish donvir
Greenhorn

Joined: Mar 01, 2012
Posts: 25
yes right prinln is consuming time thanks...
Charles Burton
Ranch Hand

Joined: Jan 31, 2011
Posts: 39

If you're very concerned about time you may want to consider another language too, while fast java isn't really considered realtime. However, if it's fast enough and you want to test the amount of time it does take try getting the time in millis just before you start to process the image and another just after. Store them somewhere so you can use them for later analysis and then print that analysis to the console. Probably will be much faster for you.
 
jQuery in Action, 2nd edition
 
subject: Need Faster way to get RGB value for each Pixel of a Buffered Image