visualizing data arrays

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
egor7
Posts: 5
Joined: 2012-05-28T22:06:27-07:00
Authentication code: 13

visualizing data arrays

Post by egor7 »

I have some 2D arrays of type integer and want to visualize it.
I dump it to file:

Code: Select all

fileHandle = fopen( "2dplot.raw", "wb" );
fwrite(myArray, WIDTH*HEIGHT, sizeof(int), fileHandle);
The next code displays black-white data only (without bw gradients):

Code: Select all

display -depth 32 -size ${WIDTH}x${HEIGHT} gray:2dplot.raw
How to visualize it properly?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: visualizing data arrays

Post by fmw42 »

convert your 2D array into a 1D array, specify the number of rows and columns and max graylevel value while putting the string of values into pgm format from NetPBM. You can display the pgm image or convert it to some other more easily viewed format.

see
http://www.imagemagick.org/Usage/formats/#pbmplus
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: visualizing data arrays

Post by anthony »

Their are many ways to visuallize a 'height field' as these images are called.

You can '-shade' the image to generate shadow effects caused by the height.
http://www.imagemagick.org/Usage/transform/#shade

You can psuedo-color the image by height, using either a gradient, or 'iso-colors' to show various levels.
See Color Lookup Tables
http://www.imagemagick.org/Usage/color_mods/#clut
Also see Ordered Dither which has a 'threshold map' that can be used to add a power of two levels
http://www.imagemagick.org/Usage/quanti ... red-dither

Also see DIY ordered dither to tile patterns based on level
http://www.imagemagick.org/Usage/quantize/#diy_symbols

Finally someone wrote a PHP script than generates a 3-D view of the heigh field in a very rough way.
I know I have that link, but can't seem to find it!

If you are serious and what to generate actual graphs of the 3-D data. Perhaps Gunplot is a better option. It has facilities to deal with raw data as well, but can also be a steep learning curve.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Jessica1
Posts: 1
Joined: 2012-05-30T01:43:21-07:00
Authentication code: 13

Re: visualizing data arrays

Post by Jessica1 »

normally you have the data in a two-dimensional array.

i tried it with GL_QUADS and GL_TRIANGLE_STRIPS but the outcome is a little strange as you can see in this screenshot:

http://www.embege.com/misc/bad_hf.jpg

the problem is that there is a certain orientation of the polygons which shouldnt be there.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: visualizing data arrays

Post by anthony »

Example JPG has a "404 Not Found Error"

Also those symbols is for OpenGL 3D display library, which is unrelated to ImageMagick.

Additional, you can also look at Ray tracing the heigh field, using something like PovRay.
ImageMagick is good for preparing inputs into such programs.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply