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
Re: Display DataBufferDouble as image
Quote:
Double that has an arbitrary range that I need to somehow map into RGB values.
The are about 16M RGB values to map to. How many double values do you have to map into those?
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.
Re: Display DataBufferDouble as image
It's probably an iterative process to get the colors you want.
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
Re: Display DataBufferDouble as image
Quote:
how do I tell Java that
Use the Color class's constructor to define colors.
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)
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.
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
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.
Re: Display DataBufferDouble as image
The A of ARGB is the transparency byte. For color you use the 24 lower bits.