So, we finally started coding and tested some image input which will be essential for the project. After several attempts and through trial and error we finally succeded in running a code and receiving some information about the image received. We also learned how to create a new image and return it. We still have a long way to go, but if we keep it up like we have done so far we might finish it soon.
So this blog post is intended to work as an schedule for the last activities of the course. So, as I have finished most of the WSQ I intend to have them finished by the end of the week. So the schedule would be like:
Monday 16th
- Finish WSQ16.
- Start programming with Magick++ for the project.
- Calculate the number of missing Mastery points.
Tuesday 17th
- Install and play with scilab and do the blog post for the last WSQ.
Friday 20th
- Have a clear idea and several lines of code for the project
Saturday 21 and Sunday 22
- Do the last videos and texts for the missing Mastery points.
- Finish the project.
Image Source: https://www.pinterest.com/pin/405605510161486991/
During this week, we succesfully installed the Magick++ library and run a code without any warning or issue on a Mac. With the program properly working, we intend to start coding during the following weeks. Also, we did some research on several aspects of the library and read the gentle introduction to Magick++. Here’s the link for its PDF: http://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.pdf
Hi! This WSQ consisted on receiving a number and using it to set the decimal precision for the calculation of e. This one was one of the toughest since it required more tools than the previous WSQs. First, to do the infinite calculation for the value of e, I used two while loops and the formula of the sum of 1/n!. To limit the precision I did two things:
1. I created a loop that turned the input into a space in the decimal, so 2 would give 0.01.
2. I used that value to stop a calculation when an added number was bigger that the limit.
Finally, I searched on the web for functions to limit the precision of floats. I found one called setprecision(), which resulted to be useful for the output value. Here’s the page with the information of the function: http://www.cplusplus.com/reference/iomanip/setprecision/
And here’s the code: https://github.com/CarlosGallegosT/Codes007/blob/master/e.cpp
Image Source: http://www.gogeometry.com/software/word_cloud_sw_e_euler_number.html
Hi! During this week we did some research on the image processing tools. We installled ImageMagic for C++ in a computer but we still couldn’t create a file and make it run properly. We’ll be working on this during the week so by the end of it we expect to have a working platform and several lines of code.
We also found an awesome guide that explains the functions and their effect on a certain image.
Hi! This WSQ consisted on applying the babylonian method to obtain the square root of a given number. This seemed easy but I had to make some research to understand the concept and to apply it. First I watched this video to familiarize with the method: https://www.youtube.com/watch?v=jTWxFGmWoZg. So the first issue I had was to “guess” the number which square would get closer to the given number. After several attepts, I found a way to solve it by using a loop which increased a number until its square became bigger that the number, and then I substracted 1. Finally, I had to search for a way to make two floats have similar values. I found page that talked about precision by using the absolute value of the substraction, I tested it and it worked. Page: http://codereview.stackexchange.com/questions/17923/checking-if-two-floating-point-numbers-are-equal
Here’s the code on GitHub: https://github.com/CarlosGallegosT/Codes007/blob/master/Babylonian_Method.cpp
This concept refers to the fact of including if and else between other conditional statements.
Here’s a video explaining the concept:
https://www.youtube.com/watch?v=crjXT_x-sf0&feature=youtu.be&hd=1
Hi! Using Linux turns to be somehow different than Windows. For quizzes and exams the terminal used presents the intended directory in a simpler way, in my case just by typing cd Escritorio/. Also something different is that the file created after compiling the code is a .out instead of a .exe used by Windows. With that I could code and test my codes so it’s sufficient knowledge of the platform.
Thanks!
Vectors and Arrays are important tools to store a determined or undetermined quantity of values for further use. They will be developed during this post.
Vectors can store a determined set of values, initialize the values or assign them further in the code. Here are the several ways of using vectors.
First a vector could be initialized as:
vector Name (Number of values);
This will create a vector containing a certain type of data (which could be strings, integers, floating points, among others). The number of values will be the available spots within the vector. After the initialization each spot could be filled with a value by making reference to it. For example, in a vector which name is MyVector with 2 spots, values could be assigned by typing this:
MyVector[0]= 0;
MyVector[1]= 100;
Note: remember that the first spot within a vector is number 0.
Another way of initializing values would be:
vector Name (Number of values, 5);
This would give each spot within the vector a value of 5 or any number after the comma. Also it can be done as:
vector Name = {1,2,3,4,5};
which would create a vector with 5 spaces filled by the numbers written, in this case: 1,2,3,4,5.
A feature of the vectors is that you may obtain the number of spots within a vector by using the funtion size(), which would be used as: MyVector.size();
In case an additional space is required a new spot could be assigned by using the function push_back(), used as: MyVector.push_back(Value);
Finally, you may use the value within a vector for any task required, by calling them by typing the name of the vector and the spot. Which would be: MyVector[0], and would return the value in the first spot of the vector.
Here’s a code that uses a vector and its different functions to return the sum of the squares of given values:
Note: In order to use a vector and its commands, you should incude the vector library by starting the code with: #include
Arrays are simplier but with several disadvantages. The structure of an array might be:
type Name [Number];
Type would be any type of data such as strings, integers or floating points. Name any name you wish to assign to the array and finally the number of available spots within the array. A disadvantage of the arrays is that they have a fixed number of values that can not be modified as in the vectors. A direct initialization might also be possible by typing:
type Array [5] = {1,2,3,4,5};
Which creates an array called Array containing 5 values: 1,2,3,4,5. As in vectors, arrays can also be called and modified. For example:
Array[0]= Array[0]+2;
which changes the value of the array 0 which was 1 and turns it into 3.
An interesting feature of arrays is the possibility of using multiple dimensions of the array. For instance, if we want to create a bidimensional array of integers we have to type:
int Array [n][m];
n and m stand for any integer value.
In order to understand easier this concept, we might think it as a row and column arrangement with coordinates to call each value. This image might help you visualize the concept:
Image Source: http://www.findmemes.com/c-memset-2d-array
Both turn useful if you intend to use several values and interact with them. The one you use depends on the task requested and on your personal preference if its a limited number of values, else you should use a vector.
Hope this have helped you with this concepts. Thanks for browsing!