Redundant title is redundant. After much work, tears, sweat and a couple of sleep-deprivation sessions at the Biblioteca, we did it. Messily, and with two codes worth of work, but we did it. Montse had a lot of trouble simply getting the Magick++ library to cooperate with us and it just did not work in my computer. I really have to check it sometime… Anyway, the “good” code is the one titled Final Project.cpp, while the others are alternates with discrepancies (see Week #3). All we have left to do is wait for the reckoning to come.
Here’s the alternate (code for “sucky”) code:
Aaaand finally the good and final GitHub code link.
]]>My buddy and I finally acomplish our project for our TC101 class.
Well, basically, our program had to do the following:
“You will create a command-line program that uses two-dimensional arrays or matrices to process images. You cannot simply call graphics libraries to manipulate the images directly but must implement the functions with your own algorithms. The input to each operation is an image (you choose to support any of JPEG, PNG) and the output is the modified image. The idea is to have a final project which shows your mastery of the topics in this course”.
I was really hard to acomplish but Eduardo and I worked together and we made it!
The user is able to type in the name of the file (a picture) and the program will process the image outputting a different file than the first one.
There is a huge code!
It looks like this:
#include <Magick++.h> #include <iostream> #include <cmath> using namespace std; using namespace Magick; void grayscale (string in, string out){ Image image; image.read( in ); int x = image.rows(); int y = image.columns(); Color image_array [x] [y]; Color original; Color graysc; int col; for (int i=0; i < x; i++){ for (int u = 0; u < y; u++){ original = image.pixelColor(u,i); image_array [i][u] = original; col = (original.redQuantum() + original.greenQuantum() + original.blueQuantum()) / 3; graysc.redQuantum(col); graysc.greenQuantum(col); graysc.blueQuantum(col); image_array [i] [u] = graysc; image.pixelColor(u, i, graysc); } } image.write( out ); } void scale(string in, string out){ Image image; image.read( in ); int x = image.rows(); int y = image.columns(); int xf = x/2; int yf = y/2; Image image2( Geometry(yf, xf), Color(MaxRGB, MaxRGB, MaxRGB, 0)); Color image_array [x] [y]; Color image_array2 [xf] [yf]; Color pixel1, pixel2, pixel3, pixel4, pixel5; int red,blue,green; Color newRGB, newRGB2; for (int i=0; i < x; i++){ for (int u = 0; u < y; u++){ pixel1 = image.pixelColor(u,i); image_array [i][u] = pixel1; } } for (int i=0; i < x; i = i+2){ for (int u = 0; u < y; u = u+2){ int x2 = i/2; int y2 = u/2; pixel2 = image_array [i] [u]; pixel3 = image_array [i+1] [u]; pixel4 = image_array [i] [u+1]; pixel5 = image_array [i+1] [u+1]; red = (pixel2.redQuantum() + pixel3.redQuantum() + pixel4.redQuantum() + pixel5.redQuantum())/4; blue = (pixel2.blueQuantum() + pixel3.blueQuantum() + pixel4.blueQuantum() + pixel5.blueQuantum())/4; green = (pixel2.greenQuantum() + pixel3.greenQuantum() + pixel4.greenQuantum() + pixel5.greenQuantum())/4; newRGB.redQuantum(red); newRGB.greenQuantum(green); newRGB.blueQuantum(blue); image_array2 [x2] [y2] = newRGB; } } for (int i=0; i < xf; i++){ for (int u = 0; u < yf; u++){ newRGB2 =image_array2 [i] [u]; image2.pixelColor(u, i, newRGB2); } } image2.write( out ); } int main(int argc,char **argv) { InitializeMagick(*argv); try { string im; string out; int ans; cout << "Write your file name: "; cin >> im; cout<< "Write the name of your output file: "; cin>>out; cout<<"What do you wanna do?"<<endl<<"1. Grayscale."<<endl<<"2. Scale (1/2)."<<endl; cin>>ans; while (ans != 1 && ans != 2){ cout<<"Try again please: "; cin>>ans;} if(ans == 1){ grayscale(im, out);} if (ans == 2){ scale(im, out); } } catch( Exception &error_ ) { cout << "Caught exception: " << error_.what() << endl; return 1; } return 0; //// c++ -O2 -o prog prog.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs` }
There is also a Repository made it in Github and that’s were our teacher is going to check it out.
Any question feel completely free to ask.
Thank you guys for everything.
-The Admin.
]]>
I want to thank Ken and all the people who helped me with this one.
We made a video for this, is over here:
An image of the Final Project:
The code: https://github.com/kenwbauer/TC101F15_Team21/blob/master/FinalProject
See you next time!!
]]>I have done all the masteries and all the WSQ’s. So I have to do:
-The video for extra points about Ken’s course.
-The Final Project, I’m working on it and I already have one part completed, but I still fighting with the resizing part.
This is the last day, so I won’t give up until midnight.
]]>That document literally saved my life, now I have done the first part:
I just have to finish the other thing about resize it and this course will be over. I have until Wednesday, so let’s work harder.
Good luck for everyone.
]]>https://github.com/kenwbauer/TC101F15_Team22/blob/master/FinishedProject
This was a complicate project because we had to use a library that we have never used before, and also we had to manipulate each single pixel to change the color to a gray scale. But finally we could end this in the correct form.
]]>The first step was to be able to ask the user for the name os the file, so he could type in the name and our program will look for it and process the image in order to change it.
That’s what we got so far and we are now working on the conversion of the pixels from color to B&W.
Hopefully everything will be ready before the deadline of November 25 at midnight.
Goodnight!
-The Admin.
]]>https://github.com/kenwbauer/TC101F15_Team22/commit/215a6c037b51a7467dc0ff2dced473dbeed6ce11
But we couldn’t make it work, we think that it is because we didn’t get correctly installed the library, so we will still working on this.
This is what happens when we try to compile the code.
]]>I JUST DO NOT HAVE IMAGES FOR THIS POST, AND AS YOU CAN SEE I AM WRITING USING JUST CAPITAL LETTERS. THAT IS BECAUSE I AM TRYING TO EXPRESS ALL THE STRESS I AM DEALING WITH.
AND I KNOW YOU ARE IN THE SAME POSITION. THE FACT THAT THE SEMESTER IS ALMOST OVER DOES NOT MATTER, ACTUALLY I WISH I COULD HAVE MORE TIME FOR ALL THIS S!!T.
BUT WELL, THAT IS NOT THE PURPOSE OF THIS POST, LET’S TRY TO CALM DOWN.
As I said, no images this time, just information, you can trust me or not:
-We have actually researched a lot about Magick.
-We have installed the Magick++ libraries.
-We have the demo program, but the truth is we do not even tried to run it.
-I’m having a meeting with Ken next week to solve some answers.
WELL THAT IS ALL, I DO HAVE A LOT OF HOMEWORK AND I HAVE TO DONE IT. I AM ON IT.
SEE YOU! AND BEST REGARDS AND WISHES FOR EVERYONE!
]]>We started by making sure we knew just what ImageMagick was, and the functionalities it will provide for the project.
Then we came across a tutorial which helped us understand the functions of Magick++.
And the last step was to simply download the whole thing, making absolutely sure the components and library for C++ were installed correctly. Now we are ready to work full-on with this project, with a nice, working environment at our disposal.
Next week we will try to write and run some actual code to start tweaking things and seeing possibilities to make sure we get the best out of the library.
]]>