Counting the number of objects intersected by the image border in MATLAB I have an RGB image with various signs. My main goal is to count the signs that are in contact with the image borders.
Approach and problem
I started by loading the image [Fig. 1], then converted it to grayscale and applied a median filter to get rid of some noise [Fig. 2]. Then I binarized it with a threshold of 0.2, which resulted in Figure 3. At this time I got my binarized image, but the problem is that some parts that belong to the same sign are appearing in various regions, instead of only one. Now my goal is to merge the regions that belong to the same object , so then I could use bwlabel to count how many signs are in the image, and use imclearborder to get rid of the ones in the border, and use bwlabel again to get the difference between the two.
My approach was to use bwmorph, Dilate to dilate the objects and then try to fill them with imfill, holes. But the problem is that if I dilate them in a small amount[Fig. 4], the imfill doesn't seem to fill them, if I dilate them by a big amount[Fig 5] all the objects start to merge :(
Code
img=im2double(imread('image.png')); figure, imshow(img) 
img_gray=rgb2gray(img); imshow(img_gray);                                 
img_mediana=medfilt2(img_gray, [3 3]); figure, imshow(img_mediana);       
img_bin=im2bw(img_mediana, 0.2); imshow(img_bin)
img_dilate=bwmorph(img_bin, 'Dilate', 10); imshow(img_dilate)
img_fill=imfill(img_dilate, 'Holes'); figure, imshow(img_fill)

Figures
Fig 1:
Fig 1 http://dl.dropbox.com/u/5272012/1.png
Fig 2:
fig 2 http://dl.dropbox.com/u/5272012/2.png
Fig 3:
fig 3 http://dl.dropbox.com/u/5272012/3.png
Fig 4:
fig 4 http://dl.dropbox.com/u/5272012/4.png
Fig 5:
fig 5 http://dl.dropbox.com/u/5272012/5.png
In my opinion, dilation erosion are very basic tools. You have a very strong information base and quite a decent input image to make such decisions. 

Here is my view: 


Given a reasonable success you have shown to go from Fig 1 to 3, you can identify and segment individual signs. 
Assuming that you have known signs a prior, you can apply a decent fast algorithms to do pattern matching. In case if the exact patterns are not known- you can just identify the outer shape of the pattern. 
Based on the classification, you can always define the centroid of each matched pattern and its respective width and height. If the centroid X,Y position is too close to the border - i.e. $centroid(x) &lt; 0$ or $centroid(x) &gt; imagewidth - shapewidth $ it is outside the edge, similarly you can apply for Y axis as well. 
Given that you are only concerned about what falls on the edge - you should start with each edge only and start pattern matching there. Start matching the partial pattern/shape and if the partial pattern/shape does match that object IS being cut on the edge. 


Here are some references that might help you formulate the problem well. 

This paper is a very good to understand lot of basics about Signs/tokens you are dealing with.

Anil K. Jain and Aditya Vailaya Shape-Based Retrieval: A Case Study with Trademark Image Databases  Pattern recognition 1998, vol. 31, no9, pp. 1369-1390

There are many research elements which deals with partial or occluded shape/pattern matching. 

Eli Saber,Yaowu Xu, A. Murat Tekalp Partial shape recognition by sub-matrix matching for partial matching guided image labeling Pattern Recognition 38 (2005) 1560 – 1573

Will expand this answer for more specific queries if you take this approach.