opezaimd-blog
opezaimd-blog
Omar Peza
46 posts
Don't wanna be here? Send us removal request.
opezaimd-blog · 10 years ago
Text
Final Project
We. Are. Done. Finally, our program works like a charm, after several days of research and hardwork, our project is capable of resizing an image and changing the color to black and white. 
We kinda did it in two parts, the first one being the black and white, that you can check out here.
For the “second part”, we researched and found out how to resize the source image using math and arrays. These links were reaaaaaally useful:
http://stackoverflow.com/questions/27351737/c-how-to-shrink-an-image-using-a-pointer-array http://stackoverflow.com/questions/299267/image-scaling-and-rotating-in-c-c http://doc.gnu-darwin.org/ImageMagick/www/ImageMagickObject.html http://www.cplusplus.com/forum/general/2615/
Basically, what resizing does is to take 4 RGB pixels (2 width, 2 height) get an average of every color (red, green, and blue) like it did on the B&W part, and add this to a new pixel, creating a new resized image which is half the size of the original.
We worked together with Eduardo and we mutually helped each other. And, of course, we did check out some other codes because we couldn’t simply start. So we appreciate Miguel Ángel’s work, as well as the help provided by Eduardo. 
Now, we had a lot of errors during the process about syntax but the one we dealt with the most was an error called “segmentation fault”. After battling with it, Eduardo and us found out that our program wasn’t the problem, but the source image was. We looked and tried several images until we found one that worked, which was the golden retriever puppy on the English Wikipedia page of “Puppy”. We then found out other images that didn’t throw us the error as well.
We are really happy about the outcome of the project.
Here are some screenshots:
Tumblr media Tumblr media Tumblr media
You can check out our final code here.
0 notes
opezaimd-blog · 10 years ago
Text
Mastery 25
On this mastery I’ll show you what are strings and how to use them in C++.
String are things that are represented by a sequence of characters.
We will create a function that works as a palindrome and tells the user if the word he input is a palindrome or not. Do as follows:
Create a main program and leave a space before it for the function
Create a function of type string called palindrome
Condition the user input with VARIABLE.rbegin and VARIABLE.rend. This iterators make the string return reversed to the beginning and end. This is the Palindrome “function”
In main(), ask the user for the input and call for the function.
Your program should look something like this:
Tumblr media
Now let’s test it:
Tumblr media
Great! Now you know how to do a basic program using string. If you want to learn more about strings, go to this webpage:
http://www.cplusplus.com/reference/string/string/
0 notes
opezaimd-blog · 10 years ago
Text
Mastery 2
On this mastery I’ll show you how to program in an online compiler and how to run your program in the same online tool.
There’s an online compiler and debugging tool called Ideone, which allows us to code online and then test it right there. So, go ahead and open ideone.com
Tumblr media
Once you opened the webpage, something similar to this will appear on your screen. On the centre of the webpage is where our programs are written, On the bottom left , we have the language of the source code (which can be changed) and on the bottom right we have the run button.
Let’s create a “Hello World” program and run it:
Tumblr media
As you can observe, our program was successful and it did output the desired outcome. 
Now, just to have fun, let’s see what happens if our program has a mistake:
Tumblr media
This online tool is great, and now you know how to use it. Congrats!
0 notes
opezaimd-blog · 10 years ago
Text
Mastery 22
On this mastery I’ll show you when to use what type of repetition in a program. 
For the purpose of this mastery, we’ll focus on while and for loops because they are the easiest and most used ones.
On mastery 19 we learned how to use a while loop. The while loop consists of something that will happen WHILE a condition is given. For example: WHILE x is greater or equal than 0, something will happen, and this process will continue to happen WHILE this condition is true.
On mastery 20 we learned how to use a for loop. A FOR loop is a type of loop which allows you to give specific conditions to it, and then repeat when this conditions are true.
Now, while and for may be seem like they are the same, but they certainly ain’t. The main difference between them is that FOR loops will continue happening for a given number of iterations. 
Tumblr media
As you may recall, functions often use a for loop because of the iteration part. In someway, FOR loops are “better” when dealing with functions, while WHILE loops are great to work with inside main().
Picture and more information from this webpage.
0 notes
opezaimd-blog · 10 years ago
Text
Mastery 17
On this mastery I’ll show you what and how to use the conditional switch in C++.
Switch is a statement that tests a variable for equality in a list of given conditions. It is somehow a summarized version of IF when you have a lot of conditions. 
This flow chart may help you understand better, and this webpage too:
Tumblr media
The default syntax of switch goes like this:
switch (expression) case “condition” : outcome [default:statement] //This is used when the variable input isn’t a valid option.
So, for the purpose of this mastery, lets create a program were the user can input his points on masteries so far and tell him if his good or screwed. Do as follows:
Create our “basic” program.
Inside the int, declare a char variable with an assigned value.
Use switch to condition the outcome and tell the user if his good or screwed.
Your program should look something like this:
Tumblr media
Now let’s test it:
Tumblr media
Let’s just play with another value:
Tumblr media
Great! Now you know what and how to use switch conditional.
0 notes
opezaimd-blog · 10 years ago
Text
Mastery 8
On this mastery I’ll talk about coding conventions on C++. 
Coding conventions are just a set of “guidelines” that talk about the style to format a code. For example, how to correctly use braces, commas, comments, capitalization, etc. You can read a lot more of these “rules” in these webpages:
https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Style_Conventions
https://gcc.gnu.org/wiki/CppConventions
Since masteries 1 and 7 we’ve been using the correct style and format. If we weren’t, we could’ve just written all our codes in one line instead of multiple lines, for example, tell me how do you prefer to read a code, like this? ->
Tumblr media
Or like this? ->
Tumblr media
Which one is easier to read?
And know you now why there are coding conventions: to make everything look nice and easy to read.
0 notes
opezaimd-blog · 10 years ago
Text
Survival guide for TC101
Here’s a brief video of me talking about my experience with the class and some tips and tricks to it.
Video.
0 notes
opezaimd-blog · 10 years ago
Video
This isn’t a clever title
This WSQ was not as hard as I thought, but it required research and a full understanding of what was inside the text file. I checked these webpages, I think they are useful: http://www.cplusplus.com/doc/tutorial/files/ http://www.cplusplus.com/forum/beginner/8388/
And you can check out my code here.
0 notes
opezaimd-blog · 10 years ago
Text
1as7 one
Tumblr media
Last WSQ of the semester, I can’t explain how fast it went!
I found Scilab as a very useful tool since it can do many things simultaneously. You have a text editor and it also graphs! It is indeed amazing and I know it may be useful in the near future for the career. 
0 notes
opezaimd-blog · 10 years ago
Text
Project
Today Ale and I finally did some serious advance in the fina project. We did a lot of research and we were able to run one part of the project, modifying the image to black and white. Here are some of the webpages we used:
Basic command-lines: http://www.imagemagick.org/script/command-line-tools.php http://www.imagemagick.org/script/command-line-processing.php
Convert input image to b&w/grayscale:  http://www.imagemagick.org/script/color.php http://www.imagemagick.org/script/color-management.php http://stackoverflow.com/questions/13317753/convert-rgb-to-grayscale-in-imagemagick-command-line 
Basically, what converting the image to balck and white does, is to take the RGB property of every pixel in the image. Then it takes the average or every color (red, green, and blue) inside the RGB to then replace it in a new pixel, “creating” a new color.
And that’s pretty much it. We will try to finish the project by doing the “second part” about resizing the image tomorrow. In the meantime, you can check our code here.
P.S. Here is how it’s shown in Ubuntu:
Tumblr media Tumblr media
0 notes
opezaimd-blog · 10 years ago
Text
Project
After battling with a fatal error (we did google it) we couldn’t figure out, we asked Ken how we could solve it. Ken found out that we didn’t have a developer library installed (libwebp dev), which was pretty rare. Ken did his magic on the terminal and helped us with the installation of this librarty. After this, we had no more errors and we were finally able to run a test program, and it worked! 
Here’s a proof:
Tumblr media Tumblr media
Awesome, right?
0 notes
opezaimd-blog · 10 years ago
Text
Quiz 11
Tumblr media
I tried Quiz 11 before doing WSQ14 and I had no idea what to do. After kinda completing WSQ14, the first part of the quiz was easy (assuming what I did on WSQ14 was correct.)
For the second part of the quiz, I did some research and found this webpage, this one, and this other one that had useful information.
Here are my programs: Euler’s Number, Banana.
0 notes
opezaimd-blog · 10 years ago
Video
Barely Visible Milky Way
flickr
Tumblr media
Kan lahun
I have many doubts about this WSQ, and to be completely honest, I don’t even know if I did what was required. Anyway, Euler’s number is complicated.
I found information in this webpage and used it as a guide.
You can check out my code here.
0 notes
opezaimd-blog · 10 years ago
Video
Jason Voorhees
The calculation of square roots with the Babylonian Method is quite interesting and demonstrates the awesomeness of math. You can check out how this method works here. 
For this WSQ, I used this webpage as a guide.
And you can check out my code here.
0 notes
opezaimd-blog · 10 years ago
Video
GCD(36,24)= 12
This WSQ was easier than I thought.
You can check out my code here.
0 notes
opezaimd-blog · 10 years ago
Text
Almost there
Tumblr media
This weekend and the next days will be full of programming. I plan to finish WSQs between Saturday and Sunday, Quiz 11 on Saturday, Masteries on Sunday, and final touches to the project between Monday and Tuesday. 
Wish me luck!
0 notes
opezaimd-blog · 10 years ago
Text
Project
Tumblr media
After unnecessarily battling with Windows and Mac for a whole week, we were finally able to install Ubuntu on Mac. We are installing the libraries and making some progress. We’ll update later today after we can compile and run a sample project.
0 notes