Object Detection Algorithms I'm a complete beginner to object recognition.

I need to identify and count how many of a certain type of Lego, in a picture full of different pieces of Lego, using MATLAB.

The pieces of Lego I need to identify, are of a certain shape, colour and size. 

I need suggestions for algorithms that can perform this task, and links to where I can find more information about them.

From the research I've done, so many are focused around facial recognition, and provide no help for me!

I followed a tutorial that used SURF points to identify points of interest, in the scene pictures and the picture of the Lego picture to find. But it wasn't able to pick up on all the aspects of the Lego piece, and therefore didn't have a chance of finding it in the scene.

If there aren't any algorithms that can perform this, how can I at least separate the pieces based on their colours? 

Any suggestions would be really handy! Thanks in advance.

Edit:

Sample picture where I will need to identify certain pieces:
SURF works well for objects with distinctive textures. Unfortunately, all lego blocks have essentially the same texture, so it is not a good cue for telling them apart.  The other difficulty is that your blocks can have different 3D orientations.

The good news is that they are brightly colored. The Color Thresholder app is a good way to segment out objects by color.  Once you have identified individual blocks, you can try to use other cues, such as size and shape to identify different blocks of the same color.  Try using the regionprops function.  For example Eccentricity can help you distinguish between a square block and an elongated block, assuming they are viewed from the top.

Unfortunately, I can only give you a starting point, not the complete solution. You are going to have to do some experimenting here.