Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ashish donvir
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try this?

 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ashish donvir
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes right prinln is consuming time thanks...
 
Charles Burton
Ranch Hand
Posts: 39
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic