Drawing a graph may be useful for checking numerical data. If you're a Python user, you're probably being introduced to a library called matplotlib.
However, when using C ++, it seems that it is not common to use a graph library that can draw like MATLAB or matplotlib as standard. [Note](I think that there are many people who use a graph library that can draw like MATLAB or matplotlib even if they use C ++. However, it is empirical if it is not common know-how for all C ++ users. I feel it.)
Therefore, this time, I will introduce to C ++ users to handle numerical data using the Spyder integrated environment. (For those who are familiar with tools such as MATLAB and R, this is an option. Only one will be added)
In a numerical calculation program Program development does not end just because it compiles, builds, and runs. The task of confirming that the value of the result of execution is appropriate is, so to speak, the beginning of the task. Calculate using the input that tells you what value should be returned.
There are many ways to verify the validity of a numerical calculation program, no matter how trivial it may be. Solving many problems for which you know the answer will help you find the problem. Makes the matrix of calculation results easier to see. Display Python's Spyder integrated environment using numpy, matplotlib, etc. At the trial and error stage, use an interactive environment to verify validity.
(Addition required)
(Addition required)
Checking these tasks without a tool like Matplotlib is a hassle. No matter how good you are at coding C ++, you should master tools other than C ++. Those who can make that much graph in C ++ should spend their effort in more recognized areas.
See many examples of Matplotlib. Then there should be something similar to what you want to draw.
If you receive an image file cv2.imread() Is used.
Replacing the input data in this way is the first step in strengthening the power of data analysis.
Apply the graph-creating ability you have acquired in this way to your problem.
May you proceed with your numerical calculations and get good results.
There is an example of handling numerical data with OpenCV imshow () and imwrite () and graphing it. However, there are various challenges. ・ You have to write the code to make it in the range of 0-255. -There is no colorbar that indicates the value. -There is no way to make it easier to understand the difference between 100 and 110 and the difference between 200 and 210. ・ It is troublesome to make it easy to see the difference between 0 and 1. ・ Every time you add a function to create a nice graph You end up carrying your own library that you have to maintain. One of the techniques I often use when I have to create a graph from C / C ++ If you give an argument with a python script, create a graph and save it. It system("python myscript.py datafile.txt") And so on. By doing so, you will not have to forcibly write the array data in the grayscale image of 0-225 with the C / C ++ source code.
[note] When using C ++, it seems that common libraries that everyone cares about are not very popular due to different operating systems in the development environment and problems such as licensing. You can see that C ++ supports any type of CPU and OS from embedded to high-end, and there are unavoidable circumstances because the GUI library is also different. For some C ++ users, it can be seen that they are having trouble checking the data and validity without knowing the useful functions of other software languages.
MATLAB is very useful as long as you can maintain your license. However, once you move a department within your organization, the license becomes unavailable immediately.
Recommended Posts