How many shapes are in this picture?
PHP – 355 bytes
The byte count doesn't include '&lt;image-url&gt;'.
&lt;?php
m('&lt;image-url&gt;');function m($f){$i=imagecreatefrompng($f);$r=f($i,17);$c=f($i,9);echo($c-$r).' '.$r.&quot;\n&quot;;}function f($i,$k){$w=imagesx($i);$h=imagesy($i);$r=0;for($y=0;$y&lt;$h;$y++)for($x=0;$x&lt;$w;$x++)if(!imagecolorat($i,$x,$y))$r+=g($i,$x,$y,$w,$k);return$r;}function g($i,&amp;$x,$y,$w,$k){$l=$x;while(!imagecolorat($i,$x,$y)&amp;&amp;$x&lt;$w)$x++;return($x-$l&gt;$k)?1/2:0;}

In the two test cases, the URLs I used are http://i.stack.imgur.com/qnIFk.png and http://i.stack.imgur.com/HV9k3.png.
Counts horizontal lines and divides by two to get the number of shapes. Relies on the observation that circles have shorter horizontal segments and rectangles have longer horizontal segments.
Admitted hack, not guaranteed to work for anything other than the test cases!
I tried rotating the images by ± 45° and detecting for horizontal lines. This would be equivalent to checking for diagonal lines and would pick up the circles better, but I couldn't find an interpolation algorithm which left clean enough edges to work with. For example, they might smudge a line into two rows of pixels and mess up the count.