I am new to plotting graphs in Visual C++. I want to use arrays as input for x- and y-axis coordinates. Please suggest some way of doing so. I have read the previous posts but I am finding gnuplot++ complex for plotting graphs.
check these out:
http://koolplot.codecutter.org/ >> its only 2d plotting but might help you as you want an easy one.
http://mathgl.sourceforge.net/mathgl_en/mathgl_en_7.html >> mathgl, if your'e familiar with opengl, this becomes easy for you to use
www.astro.caltech.edu/~tjp/pgplot >> fortan c-callable graph plotter (please bear with me as stack overflow is preventing me from posting more than two hyperlinks)
if you have a lot of data, i mean seriously large then it might be worth trying to learn opengl as you'll be direcly dealing with raster graphics.
one advantage is that you can set the viewport(how many pixels and how big) in common words you can deal with 100000*100000 points in your calculations but display it in a window of 500*500 pixels as a reduced image.
google opengl you'll go to the website, i believe edward angel's books are really good to learn and teach you only what you need.
Related
I am going to split this question in 3 parts
First, I've been given this problem, and I don't know where to start, if you have been solving related problem, would you give me some hints and keywords to help me do some more research?
I have done some research on my own
So here is some 2D chest CT scans (sorry due to reputation rule i can't implement images directly)
All photos are in the same angle. So I think I can simply read each photo to a vector of pixels, do some thresh holding to make all black and black-ish pixels going to be a non-colored pixel. Next, I'll create a vector called vector_of_photo of those vectors. Then the index of each vector in vector_of_photo are now the Z-index.
Now I can render a 3d photo from those vectors of pixels right?
In the second place, I got trouble understand raycasting algorithm,
I think the idea here is, when I already got a box of pixel then everytime I rotate the box, it cast straight-lines from that angle of the camera to the box, each line found a has-colored pixel going to stop casting and render that pixel (or more specific, copy the pixel to the exactly location on the plane).
Did I understand it correctly?
At last, the OPENGL/c++ part is just the option I think I'm going to use to solve this problem. And I'm not pretty sure it is a good idea or not, so give me some more hint about the programming language, library or module I should take a look at.
I happen to be working on the same problem in my spare time. Haha :)
Here is one approach to your problem:
Load the images into your application, such that you get the 3D volumetric dataset that you describe
Remove all points that don't fit within some range of values (e.g. 0.4/1.0 to 0.6/1.0 brightness). You may need to apply preprocessing and filtering.
Fit a mesh to the resulting point cloud with open-source software. Here is a good blog post about that
https://towardsdatascience.com/5-step-guide-to-generate-3d-meshes-from-point-clouds-with-python-36bad397d8ba
Take the resulting mesh (probably, an STL file) and visualize it in any software your want (Blender 3D, Unity 3D, Cinema 4D, a custom OpenGL application), anything really.
My own approach to this problem is very similar to the one you suggest in your question, and I have already made some headway. Therefore, I thought it would be good to suggest another route.
NOTE Please be aware that what you are working on is not a trivial problem. It's a large project, and there are many Commerical companies that put years into doing just this. This is a great project for learning OpenGL, rendering, and other concepts. It's perfectly doable, but you may be looking at several months of work, and lots of trial and error. Good luck!
Its not often that two people would happen to work on the same problem, so if you want to discuss further, feel free to contact me over linkedin and/or post a comment below. www.linkedin.com/in/michael-sohnen-a2454b1b2
I have some 3D data (xyz coordinates) that I am trying to represent as a 3D bar graph. What is the best way to visualize this in C++? I would also like to display different colors based on the z value. Any information about this would be great.
Thanks in advance.
I imagine you were hoping for a turn-key solution to your problem, but, although I have seen a lot of 3D bar charts over the years, I don't have a library which I can point to and say "just use this." I once watched as researchers virtually walked around on top of a huge 3D bar chart in Second Life, discussing the depth of data exploration only immersion can offer.
The problem is that you need a dynamic view, with mouse input as a minimum. There are some libraries for 3D graphing, but those are for visualizing surfaces, which isn't really what you're after. Here's one with an ActiveX control interface for starters.
So now I'm thinking about graphical APIs, such as OpenGL and DirectX, where you could just draw the geometry yourself. But I'm not sure you know anything about graphics programming, and so getting a single triangle on screen will be a task, let alone 2*5*w*h triangles. No offense - its an actual GD ordeal.
So short of explaining how to do that in any reasonable way, now I'm wondering if I can simply sidestep the issue. You could use any number of graphing libraries to draw a matrix of charts, one for each slice in the grid. Or a 2D color heat map, where the color matches the Z value, as you suggested.
But that's not helpful, because you wanted a 3D bar chart. So maybe I can talk you out of it? While its been shown that people prefer 3D bar charts, they don't perform as well using them, compared to 2D representations. And if you want a 3D representation to be effective, you may need to employ stereo 3D or linked physical models.
I hope my ramblings have at least been amusing.
Not free, but would this fit the bill? https://www.qt.io/blog/2013/11/07/qt-data-visualization-technology-preview-and-charts-1-3-1-release
Maybe: Use R, and a C++ binding library, like Rcpp.
Or perhaps: PLplot.
I'm wondering if anyone could point me to any resources that would deal in rotating one or several 2D textured planes in 3D space. Something like this but with openGL (preferably C++):
I'm attempting to do pretty much the exact same thing but no matter how I order my operations I'm getting right-screwy results. So I figure asking for some resources on the subject is better than posting tons of code and asking for people to fix my problems for me. :)
If you havent already, do a search for 'NeHe tutorials'. An excellent set of OpenGL tutorials.
Here is a link to the rotation tutorial, includes all the source code in downloadable format and the tutorial walks you through each relevant line.
http://nehe.gamedev.net/tutorial/rotation/14001/
I believe this is working in a 2D space, the step up to 3D probably involves a bit more matrix math but...doable
The NeHe tutorials are a very popular place to learn the basics of OpenGL. In particular, the tutorial about texture mapping should help you:
http://nehe.gamedev.net/tutorial/texture_mapping/12038/
Mind you though that these tutorials are written for older OpenGL versions which are more beginner friendly IMHO.
You should look into scene graphs. Basically it is a way to define a bunch of objects (2D textured planes) and their transforms in 3D space. This allows you to define transforms that work on multiple nodes (objects) as well as single nodes. You can make a pretty simple one in C++ with little effort, or use one such as OpenSG or OSG (slight learning curve needed).
Wikipedia - http://en.wikipedia.org/wiki/Scene_graph
I have a huge array of 2D points (about 3 millions of pairs), which I need to render with reasonable speed in a Qt-based application.
I've tried using QGraphicsScene, but its very slow even on 400000 primitives, so I was looking into the qwt library instead.
It has a scatter plot example screenshot on its sourceforge page, which looks like exactly what I need, but I cannot find neither any kind of actual code that can be used for this data, nor an according API in qwt docs - it mentions only different types of curves.
So it would be good to get some pointers for scatter plot examples and some advice on its performance.
Suggestions for other c++ qt-compatible plotting libraries which can cope with this amount of data are also welcome.
Scatter plot is contained in the "realtime" example: what you want is the IncrementalPlot class.
I'd also suggest that drawing all the 3 million points isn't reasonable, since modern screens have only about 2 million pixels :) Thus it seems better to simplify the plot beforehand by merging the adjacent points into one with a threshold dependent on the zoom factor.
As viens pointed out, generating scatter plots with 3 million points is probably not a good idea.
I have achieved good performance generating 3D scatter plots with 30.000 points using OpenGL.
OpenGL is fast and integrates well with Qt. However, it is a low level API that forces you to do a lot of tedious coding.
VTK may be another option.
MathGL is free (GPL) cross-platform plotting library. It was written in C++ and have Qt widget. Also it is rather fast, but 3 millions points ... it take about 30 seconds to plot in my laptop.
You'd suggest using OpenGL as #vines said, and in particular exploiting or display lists glGenList or vertex buffers. Some million points as primitives vertices shouldn't be that difficult.
I'm preparing for a project related to weather visualization. I have some .csv files (100 rows, 120 colums) that contain weather data measured in my country where each cell represents a point with some specific values e.g. temperature or wind speed. Those files may be perceived as sets of points of latitude and longitude that covers my whole country (in fact the values are measured every 5 miles). I'd like to transformed the data and put the values on maps to make some weather visualizations, both 2d and 3d, especially heatmaps or hightmaps. I'm wondering which technology is the best for that. I was thinking of openGL, but all the textures mapping and drawing operations seem a bit difficult to me (but maybe they're not). I'm also considering making Java applets but there are many Java graphics libraries and I don't know wich one is the best for my requirements. Maybe all those things are possible to do in XNA, whcih would be great, because I'm programming mainly in C#. I'd be glad if some more experienced programmers could recommend me an appropriate language and libraries. What would you use to make the work easy and efficient?
OpenGL is just the pencil and paper for program to draw things with. While it certainly is possible to use OpenGL for this, I strongly suggest using an off the shelf visualization tool, like Origin, Matlab Visualization, visualization modules of R, etc.
If you're more looking in the direction of a visualization programming toolkit, have a look at VTK http://www.vtk.org/
But naked OpenGL for that task: Only recommendable if you "speak OpenGL fluently".