Friday, August 24, 2012

Programming Computer Vision with Python - Book Review

What a great book!!!!!

I know I'm not impartial because I like computer vision, but this book really is a big supplement to computer vision classes you can have in college. The choice of the language used is also great for both the amount of programmers that use it, that also for the fluency of the programs created. Has to be mentioned that this book is for intermediate students how wants to do some other advanced stuff of computer vision usually not covered by specific classes. If you are kind of a mathematical person who like formulas and demostrations and wants to know more about the theory behind some example, it would be preferable complement this book with others (I remember Multiple View Geometry for example) that explains much better details the theory used.

Below you can find a brief explaination of each chapter in the book:

Chapter 1 - Basic Image Handling and Processing
This chapter simply explains what functionality are available for handle images using python and the PIL library provided. It also explains the other libraries used as Numpy, Scipy, Matplotlib

Chapter 2 - Local Image Descriptors
After a brief explanation of what are local image descriptor, the chapter explains the Harris and the Sift descriptors. The example of this chapter is to create a graph of relation between geotagged information retrived on panoramio.

Chapter 3 - Image to Image Mappings
In this chapter, homographies and affine transformation are explained. The method of Direct Linear Transformation Algorithm to find the homography based on correspondent points is explained. In case of affine transformation, fasted way to find the matrix with less correspondencies are described. In this chapter the example guide the lecturer to create a panorama creation system based on multiple images. As contour of this example RANSAC and Delaunay triangulation algorithms are briefly explained.

Chapter 4 - Cameras and Augmented Reality
Really interesting chapter on modeling cameras through its projection properties and use this properties to create an augmented reality application. Camera Calibration is also explained in this chapter that is completed by an example of augmented reality using PyOpenGL to load a model in the image correctly aligned to a reference image.

Chapter 5 - Multiple View Geometry
Chapter about epipolar geometry and 3D recostruction using multiple images and different sets of matrices available to describe their relation. It also explain theory behind the stereo images system and concludes the chapter and example of 3D recostruction.

Chapter 6 - Clustering Images
This chapter introduces some clustering methods (as K-means) and explains how to use them to find relations between groups of images. Techniques as Hierarchical and Spectral clustering are explained and using to divide images into related  groups.

Chapter 7 - Searching Images
How to find an images in the fast way is a problem that has to be solved in application with an huge knowledge base and sometimes the only use of reduction techniques as PCA is not enough. In this chapter techniques derived from text mining are performed to find "visual" words inside images that can be easily search in a "vocabulary"

Chapter 8 - Classify Image Content
Classification is the process of deciding to which class a sample belongs based on some measurment executed on it. Starting explaing the K-nearest algorithm, the chapter continues describing a method to use Dense Sift feature as classification measure together with Bayes classifiers and SVM classifiers. The chapter ends with an interesting example on resolving sudoku's after have classified all the fixed numbers.

Chapter 9 - Image Segmentation
The segmentation of an image consist in separate regions of the image that are likely to have a similar mean (ex. Background vs Foreground). The techniques used are Graph Cuts, Segmentation with clustering and Variational methods

Chapter 10 - OpenCV
Very straightforward chapter about the functionality provided by the opencv library.

To conclude, this book is actually great. For me that I am interested in computer vision, this book explained the newest and coolest methods that can be used to build powerful and appealing application in the era of powerfull smartphones and huge images datasets freely available.

Wednesday, July 4, 2012

Safe C++ - Book Review

Everybody knows how is tricky to manage all the complexity and the feature that c++ provides. From memory allocation to copy constructor ending up with address manipulation, It's very easy to make a mistake and sometimes is difficult to find the reason of it.

Safe C++ is a book for intermediate C++ users who wants avoid common mistakes that usually happens. From memory leaks to comparison operator, the book explains how a simple macro definition can help you to remove problems. The book is easy to read for who is practical with C++ and the 140  pages that composes it flows very fast. The book is composed by 17 short chapters, each of which tackles a specific issue:


The first 3 chapters are sort of introduction to the specific issues treated later in the book:
 Chapter 1: Where does c++ bugs come from?
 Chapter 2: When to catch a bug?
 Chapter 3: What to do when we encounter an error at runtime.


The middle chapters are more specific and tackles a specific issue:
 Chapter 4: Index out of bounds
 Chapter 5: Pointer Arithmetic
 Chapter 6: Invalid Pointers, References and Iterators
 Chapter 7: Uninitialized Variables
 Chapter 8: Memory Leaks
 Chapter 9: Deferencing NULL pointers
 Chapter 10: Copy Constructors and Assignment operators
 Chapter 11: Avoid writing code in the destructors
 Chapter 12: How to write consistent comparison operators
 Chapter 13: Errors when using Standard C libraries

The last three chapters talks about testing and how to help the debugging process:
 Chapter 14: General testing principles
 Chapter 15: Debug-On-Error strategy
 Chapter 16: Making your code debugger-friendly   

 This book explains how to avoid most common mistakes and bad pratices when programming in C/C++. It's a good book for intermidiate and can help also beginners to understand some tricky behaviour of C++. Together with other more general books as the pragmatic programmers series and so on, can be a good reading to master a good coding style.

Thursday, June 21, 2012

Android Cookbook - Book Review

This book talks about the new mobile OS Android. This OS (even if Framework is more appropriate) is widespreading through mobile and embedded devices. As the title suggest, this book use a Cookbook style for explain the concepts. Each problem is treated as a Recipe and is composed by 3 parts:

  • Problem: few rows to describe the problem that needs to be solved. 
  • Solution: few rows that explains briefly what must be done for solve the problem. After reading the book, this is kind of a bookmark for future research in the book and allows the reader to remember how to solve a problem simply reading few lines. 
  • Discussion: Here is described the solution in all of its aspect. The code is widely described and everything is covered to let the reader understand the solution.


Because this book covers a lot of problems with their relative solution, I prefered to copy the description of the chapters as appears in the preface of the book instead of described them myself.
What’s in This Book?
  • Chapter 1, Getting Started, takes you through the steps of setting up the Android development environment and building several simple applications of the well-known Hello, World” type pioneered by Brian Kernighan.
  • Chapter 2, Designing a Successful Application, covers some of the differences in mobile computing that will hit developers coming from desktop and enterprise software environments, and talks about how mobile design (in particular, Android design) differs from those other environments.
  • Chapter 3, Testing. Not so that you’ll skip it, but so that you’ll read and heed. We talk about unit testing individual components as well as testing out your entire application in a well-controlled way. Android provides a variety of mechanisms for communicating within an application and across applications.

  • In Chapter 4, Inter-/Intra-Process Communication we discuss intents and broadcast receivers, services, AsyncTasks, and handlers. Another communication mechanism is about allowing controlled access to data that is usually in an SQL database. 
  • In Chapter 5, Content Providers, we show you how to make an application that can be used by other applications through something as simple but ubiquitous (in Android) as the URL.
  •  Chapter 6, Graphics, covers a range of topics related to graphics, including use of the graphical drawing and compositing facilities in Android as well as using desktop tools to develop graphical images, textures, icons, and so on that will be incorporated into your finished application.
  • Chapter 7, Graphical User Interface, covers the main ins and outs of GUI development for Android. Examples are given both in XML and, in a few cases, in Java-coded GUI development.
  • Chapter 8, GUI Alerts: Menus, Dialogs, Toasts, and Notifications, covers all the pop-up mechanisms—menus, dialogs, and toasts—and one that doesn’t pop up but is also for interaction outside your application’s window, Android’s notification mechanism.
  • Chapter 9, GUI: ListView, focuses on one of the most important GUI components in Android, the ListView. Android is rich in multimedia capabilities.

  • Chapter 10, Multimedia, shows how to use the most important of these.
  • Chapter 11, Data Persistence, shows how to save data into files, databases, and so on. And how to retrieve it later, of course. Android started out as an operating system for mobile telephones.

  • Chapter 12, Telephone Applications, shows how to control and react to the telephone device that is in most mobile devices nowadays.Mobile devices are, for the most part, always-on and always-connected. This has a major impact on how people use them and think about them.
  • Chapter 13, Networked Applications, shows the coding for traditional networked applications.

  • Chapter 14, Gaming and Animation.

  • Chapter 15, Social Networking.

  • Chapter 16, Location and Map Applications, discusses how to find your location, how to get map data from Google and OpenStreetMap, and how applications can be location-aware in ways that are just now being explored.

  • Chapter 17, Accelerometer, talks about the sensors built into most Android devices and allow to use them. 
  • Chapter 18, Bluetooth, talks about the low-energy very-local area networking that Bluetooth enables, going beyond connecting your Bluetooth headset to your phone.

  • Chapter 19, System and Device Control. Since Android is Linux-based, a few of the recipes in this chapter deal with traditional Unix/Linux commands and facilities. 
  • In Chapter 20, Other Programming Languages and Frameworks, we explore the use of other programming languages to write all or part of your Android application. Examplesinclude C, Perl, Python, Lisp, and other languages.
  • Chapter 21, Strings and Internationalization, goes over the
    issues of language and culture and how they relate to Android.

  • Chapter 22, Packaging, Deploying, and Distributing/
    Selling Your App, shows how to prepare your application for distribution via
    the Android Market, and to use that as well as other markets to get your application
    out to the people who will use it.

I've never read an Android book before this one and I was a little bit suspicious about how this book would be comprehensible compared to other books more focused on the whole framework instead of single problems. I remained surprise of how this book is clear even for new comers in the Android world, each problem is discussed perfectly and the discussion part of each problem covers also the paradigms of the Android framework. Has to be noticed that a strong Java background is needed, together with a basic knowledge of the Eclipse IDE. I suggest this book for both new Android developers and expert ones, the former can find in this book an explanation about the Android framework, how to use the framework with real problems and a lot of examples that can be reused for create the application they imagine. The latter can  improve their knowledge about topics not treated in their current developments and improve with new functionality their apps.

Friday, May 11, 2012

Machine Learning for Hackers - Book Review

I was following the courses in Machine Learning through the Coursera website when i had the chance to review this book. For me it's difficult to start programming without a real motivation or pressure of a deadline and I hate myself for that. Reading or follow only theorical lectures is, of course, useful to improve your knowledge and find similar patterns in different problems but only when you start to practically use what you have learned that your mind stores the information in a more solid way.


This book tries to be less mathematical as possible, diving directly into practice with the R language functionality.
After explain the functionality of the R language, the author explains the main categories of machine learning algorithms as Supervised and Unsupervised learning.
  • Categorization: using a Bayesian Classifier wrote using R, we will be able to categorize Spam messages from good messages
  • Priority Ranking: in this chapter the author describes what features are used by google to define a priority in the received emails and provides the code for write your own ranker based on this features.
  • Linear Regression: this chapter explains one of the powerful tools of Machine Learning, Linear Regression. Using Linear Regression the case of study explains how to create a system that predicts page views of the 1000 top websites. This chapter explains also different measures of error that can be performed to test how our model works.
  • Nonlinear Regression and Regularization: the first part of the chapter explains Nonlinear regression that means when the prediction can't be mapped in the linear formula:                                       Prediction= Constant + X+Y+Z.  The second part of the chapter talks about Regularization that explains how to prevent the overfitting, that means our model fits so good the training data but is no able to fit the test data in the long run.This is due to the fitting of the training data that is so precise that starts to model also the noise (outliers) in the training data.
  • Optimization: After we define a measure of error for the model, we can tune it, optimizing some parameter. This parameters are the result of the minimization of the error measure for example. The case of study of this chapter is to build a Code breaking system. 
  • PCA: This technique allows to reduce the complexity of the data reducing the dimension of the problem and is useful to extract a vectore that resumes all the data set.
  • MDS: Sometimes is difficult to see the relations between different features without a graphical help. The MDS algorithm allows to create a clustering of all the data and is able to plot this clusters in a meaningful way.
  • K-nn nearest neighborhood: Sometimes isn't possible to define a model general for the whole dataset so, we can make a prediction using the nearest possible choices and give a score for each one. This system is used in the case study to realize a recommandations system that suggests packages based on the installed packages.
  • Social Graph: this chapter explains how social website define their connectivity model and explains how to study the relationships realizing a "Who to follow" system for twitter.
  • SVM: the support vector machine is another powerful tool for machine learning and is widely used when isn't possible to define a linear decision boundary. The case of study of this chapter is a comparison of the prediction algorithms used in the previous chapters.
For my point of view, this is a good book for who wants to dive into machine learning without know anything about math, statistic and probability. Honestly I think that this approach doesn't work well, at least for me, because some algorithms are difficult to use correctly or find a relation with our problems without the abstraction that math gives. Also, theory is useful to understand better how some parameters affect the prediction. Sometimes in the book there are notions that needs theory but instead there are explained as "change the value and see what happens" method.
Even if this is not a R programming book, the language is not clearly explain in the text and a previous study of the language is probably necessary or translating the code in a more common language as Python will help understand the problems. I've also notice some incoherence between the text and the code, in fact I've faced some errors using the code in the text while the code in the CD-Rom work perfectly.

As conclusion, I will suggest this book to someone who wants to learn autonomously concepts of machine learning but, I suggest to use the online courses for study the theory behind these algorithms.

Monday, April 23, 2012

Machine Learning Class

Hi everybody,

it's online the new Machine Learning class of Standford University through the Coursera website.

http://www.coursera.org/course/ml

Refresh your linear algebra....


This link contains an useful pdf regarding linear algebra. It's a good reading if you want to refresh your knowledge. Probably for the newbies the relations between the arguments are not so explicit and i suggest to use this pdf as complement to another book.

HTML:
http://www.numbertheory.org/book/

PDF:
http://www.numbertheory.org/book/mp103.pdf

Thursday, April 19, 2012

Hi-Tech websites

Hi folks,

I don't like to copy piece of articles from other website. So, I share with you two very famous website I use to visit. Usually they provide a lot of news and podcast about new technologies. If you know some other website, feel free to share it with everybody just commenting the post.

http://www.engadget.com/

http://www.tomshardware.com/

Friday, April 13, 2012

Pragmatic Debug IT - Book Review

I went through this book because I was interested to learn something more about debugging, not as a simple research of a bug, but as a set of methodologies and pragmatic tips that can help to write robust, clear and self-explaining software. The book is splitted into two main topics, the former is a microscopic journey through four step the author has identified as the principal operations to be executed when facing a bug; the latter is a macroscopic vision of the whole system and the author provides tips and especially tools to deal with the debugging process inside a company.

The first 5 chapter belongs to the microscopic description.
The first chapter is an introduction of the empirical approach used to remove a bug. This chapter introduces the reader to the main step of debugging:
  • Reproduce
  • Diagnose
  • Fix
  • Reflect
The other four chapter deals with each of this steps. The "Reproduce" chapter explains that reproduce a bug is the most important and sometimes difficult step to do during debugging and provides a series of suggestions as logging or control the inputs.
The "Diagnose" chapter explain what happen next the reproduction. In this phase, the programmer must define hypothesis and experiments to find the real cause of the problem. The experiments he/she conducts are aimed to verify or not his/her hypothesis. Typically the experiments:
  • Tries to examine the internal state of the software  (as example using a debugger)
  • Modify the environment the software runs in (input files, OS. variables)
  • Change the logic of the code and see the effect.
The "Fix" chapter helps to understand better the implication of your changes in the code and how to avoid regression. Finally, the "Reflect" chapter describes how the knowledge acquired fixing a bug can be shared with the others and make think about other possible errors.

The next 2 chapters gives a whole vision of bug management inside a software company. Topics of this chapters are how a company should manage bugs and bug reports,how give priorities to the bugs such as none of them is left behind before continue the development, how to deal with the customers and so on.

The last 3 chapters that completes the book gives some useful tips to how avoid bugs or simply make it easy find them. Chapter 8 explains special cases where the normal empirical approach can't be used rigorously. Chapter 9  instead explains how Automatic Testing, Automatic Builds, Source Control, Continuos integration system and so on can be a blessing for debugging. The last chapter close the book explaining ways of how our code can be "prepared" to be debugged in a more easy way and how our software can give us useful information without effort.

I found this book very helpful and even if doesn't teach you to found a bug in 2 seconds It gives you a method to debug your software more efficiently and make the software debug itself. Also provides some clues about set of tools that can be used for the process. The "experiences" paragraphs through the book helps to understand better how to apply the tips of the book and also clarified which are the errors I used to do while debugging.

Tuesday, April 10, 2012

R - Scripting language for statistics


I'm actually reading the book "Machine Learning for Hacker" and I hope to review it as soon as possible together with other books as "Pragmatic Thinking and Learning" and "Pragmatic Debug it". In the first book, the author uses the language R for the examples. R is a scripting language made from staticians for staticians that helps providing a set of functions and data structures to help with the job.

Here is the website: http://cran.us.r-project.org/

Thursday, April 5, 2012

GDB: Debugging old style

 With the rise of IDE and RAD tools as Eclipse or Visual Studio, tools that made the history of computer science tends to disappear. Probably this is cause by senior programmers prefer to address young programmers toward this IDE tools, more usable and easy. Sometimes, you don't have an IDE, or you don't want to create a project for some simple exercises but, you will need a debugger in either way.

GDB is the debugger. You can do everything you do in a IDE debugger using the command line and GDB. In fact, often IDE maps debugger buttons into GDB instructions and format the outcome properly.

Below you can find two link, the former is a short tutorial while the latter is the official guide to GDB.


http://www.cs.cmu.edu/~gilpin/tutorial/

The official Guide can be found @

http://sourceware.org/gdb/current/onlinedocs/gdb.pdf.gz

P.s. Yesterday i was traveling and a guy next to me was programming an IPhone APP. He was stucked on an error, trying to resolve it using print instruction or logging. Because XCode uses GDB for debugging, I said to him to run a backtrace command in the GDB to see what's going on and I gave him the guide you can find here. I told him to read just the Sample session chapter (around 5-6 pages) to understand how to use minimally GDB.
He doesn't have listen my advice and, for not read 5-6 pages, he spend more than an hour on that bug using his method and probably he will continue to use it.

Sometimes you have to put aside proud and listen other people because anyone can teach you something because everyone have a different view of  the same problem.

Tuesday, April 3, 2012

Decision trees

Today I propose a good paper about random decision tree suggested by my professor. This kind of tree are used in the kinect system to track the skeleton of the player categorizing each pixel of the depth-map.

http://research.microsoft.com/apps/pubs/default.aspx?id=155552

Monday, April 2, 2012

Unity 3D mobile licenses




 Until the 8th of April is possible obtain a iOS and Android license of UNITY 3D for FREE!!!

Unity 3D is a powerful and easy game editor that allows to create complete videogames for multiple platforms.

http://unity3d.com/unity/

Think Complexity - Book Review


If like me you think this book will explain you the complexity theory of algorithms and teach you how to write faster code you are out of the road.
Instead, this book shows various models that allows to simulate experimentally the behavious of real complex system.
Another aspect who the author try to explain through all the book, is the validity and the robustness of explanations of complex system behaviours given with computational models compared to the "old science" approach, based on formulas and mathematically explainable relations .

In the preface the author indicates three major topics the book will cover: Python programming, Computational Modeling and Philosophy of science. While the last two topics are covered deeply, trough the book and in the references, the Python programming (one of the reasons i choose this book) is very basic and the references to other libraries doesn't makes the code more complex. So, this book is not for pure practical programmers who want to learn advanced features of python, which are covered better in books like "Dive into Python" and "Think Python".

Computational modeling is explained widely thanks to exercises, references and case studies. Starting from systems describable through graphs, the book continues explaining systems that present a specific distribution of events and how to model these distributions and extract the relations between the parameter of the model. Cellular automata is explained and used to generate some behaviors like randomness or other models as fractals, percolation. Other models are described to show the behaviors of some critical systems, systems in transition between to states, as freezing waters and pink noise. The last models described are the Agent-based models and examples as traffic jams and bird flocks are used to explain them.

For what concern the Philosophy of Science, the author tries to induce into the reader what "Thomas Kuhn" introduced as "Paradigm shift", a shift from old science to complexity science, where complex models gives the same satisfaction of equations.
To better explain this concept, I report an example of the book:
"The development of complexity science is not the replacement of an older model, but (in my opinion) a gradual shift in the criteria by which models are judged and in the kinds of models that are considered acceptable.For example, classical models tend to be law-based, expressed in the form of equations, and solved by mathematical derivation.Instead, models that fall under the umbrella of complexity are often rule-based, expressed as computations, and simulated rather than analyzed. Not everyone finds these models satisfactory. For example, in Sync, Steven Strogatz writes about his model of spontaneous synchronization in some species of fireflies. He presents a simulation that demonstrates the phenomenon, but then writes:
I repeated the simulation dozens of times, for other random initial conditions and for
other numbers of oscillators. Sync every time. The challenge now was to prove it. Only
an ironclad proof would demonstrate, in a way that no computer ever could, that sync
was inevitable; and the best kind of proof would clarify why it was inevitable."
Pros of the book are the exercises and the presence of case studies at the end of the it with which the reader can practice. Also, each chapter contains both sections where models and implementations are explained and sections where papers shows real-system with their derived model.
One of the cons of this book is the huge presence of external references to papers and wiki pages. Of course is practically impossible fill a single book with all the topics related to the models explained but, the continuous "goto" and come back impact on the readability.

This book is a good reading for Computer scientist who wants to learn about complex systems and the data-structures related. For who is interested on the philosophy aspect of complexity, the book proposes in each chapter the validity of this method and how can be applied to study complex system where a clear definition of laws and equations is impossible. The author stimulate the curiosity of the reader through the book, asking to implement and critically analyze models looking for analogies and differences. Even if I consider myself a pure practical programmer, this book interested me because describes the behavior of real-system through models that I can reassemble to apply them to other problems, providing also methods and tools to analyze the results of the tests compared to the real system behavior.

Free Machine Learning Lectures

Hi guys,

i want to share with you this link to the Standford Lectures Videos about Machine Learning. There are also other topics, from programming to physics. 
http://www.ml-class.org/course/auth/welcome

Here the youtube link:
http://www.youtube.com/watch?v=UzxYlbK2c7E&feature=BFa&list=SPA89DCFA6ADACE599&lf=list_related

In the description of the videos you can find the link to the class website and download the pdfs of the lecture and other useful files.

The MIT does the same with the OpenCourseWare project
http://ocw.mit.edu/index.htm

Sunday, April 1, 2012

Google Summer of Code 2012

From now until the 6 of April is possible to register to the Google Summer of Code 2012!!!! More than 100 companies gives their support for beautiful open-source projects.

Google Summer of Code 2012

Hello World!!!

Hi Everybody,

yes, this is another blog about coding and computer science. I'm going to publish some reviews about books and videos and share some useful or funny link.