Results 1 to 10 of 10
- 01-04-2012, 02:45 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 27
- Rep Power
- 0
Display DataBufferDouble as image
Hello, I was hoping someone knew best practices concerning displaying data of type Double as an image through a BufferedReader. I have topography data that I would to show as an image. So the data is type Double that has an arbitrary range that I need to somehow map into RGB values. I feel there should be a way to create a ColorModel that will take care of this but am having trouble sorting through the API and have been unsuccessful trying to find an example. I was hoping to avoid manually mapping the topography data to RGB values since the data array may get very large and it seems inappropriate having two arrays floating around that have the exact same information.
Any help would be appreciated
- 01-04-2012, 03:01 AM #2
Re: Display DataBufferDouble as image
Double that has an arbitrary range that I need to somehow map into RGB values.
- 01-04-2012, 03:13 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 27
- Rep Power
- 0
Re: Display DataBufferDouble as image
Well I was hoping to create at most a mapping array. For example lets say I want to represent the topography with 256 colors. I some how create a colormap that say value 1 through 10 are RGB(0,0,0), 11 through 20 are RGB(0,0,20), etc. I haven't exactly figured out how I was going to pick the colors, and was going to just start off at grayscale first or use HSV and discretize the hue over a certain number of levels.
- 01-04-2012, 03:19 AM #4
Re: Display DataBufferDouble as image
It's probably an iterative process to get the colors you want.
- 01-04-2012, 03:27 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 27
- Rep Power
- 0
Re: Display DataBufferDouble as image
Could you expand on that? Choosing the colors isn't a big deal really. For example lets say the range of the typography are arbitrary doubles between 0 to 100. I say I want to represent this with 200 colors where values within the first 25 feet is represented by 50 shades of gray, second 25 feet is represented by shades of red, then green and so on. The problem is how do I tell Java that? The indexColorModel seems to do something similar, but this doesn't seem to work.
Thanks for any help
- 01-04-2012, 03:34 AM #6
Re: Display DataBufferDouble as image
how do I tell Java that
new Color(0xFF, 0, 0) would be red. Changing the values of the other args could generate other reds.
Try using the JColorChooser to see the values. There is a section in the tutorial:
How to Use Color Choosers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
- 01-04-2012, 03:39 AM #7
Member
- Join Date
- Feb 2011
- Posts
- 27
- Rep Power
- 0
Re: Display DataBufferDouble as image
Thanks for the help. The problem I am having though is how to place my object of DataBufferDouble into a BufferedImage using an appropriate color model. I understand the Color object, but this doesn't provide a means of mapping my double values into RGB values for displaying as image.
- 01-04-2012, 03:44 AM #8
Re: Display DataBufferDouble as image
What is a DataBufferDouble?
Is it two dimensional and the same size as the image you want to create? IE one double value to one pixel's color
- 01-04-2012, 03:51 AM #9
Member
- Join Date
- Feb 2011
- Posts
- 27
- Rep Power
- 0
Re: Display DataBufferDouble as image
DataBufferDouble is a subclass of DataBuffer which is commonly used in WritableRaster objects used to create BufferedImages. Creating images with DataBufferInt for example isn't trivial, but I can do it. In that case the Integer in the DataBufferInt array is what they call a packed value. Since ARGB is 32 bits and an Integer is 32 bits each value represents an ARGB value. It looks like I'm going to have to manually map my double array to an integer array an then create a buffered image from there. I was hoping to avoid that, but it looks to be the only way.
- 01-04-2012, 04:09 AM #10
Similar Threads
-
Display Image (png)
By vimalaranjan in forum Java GamingReplies: 2Last Post: 05-04-2011, 01:23 AM -
to display image
By asmitarnd in forum AWT / SwingReplies: 6Last Post: 04-07-2011, 12:17 PM -
image display
By asmitarnd in forum AWT / SwingReplies: 3Last Post: 04-07-2011, 12:17 PM -
How to display image ?
By Birkoff in forum AWT / SwingReplies: 7Last Post: 06-09-2008, 08:58 AM
Bookmarks