フィルターのクリア

Image segmentation problem, need help

2 ビュー (過去 30 日間)
Rui
Rui 2012 年 5 月 16 日
Hi Guys! I'm having a big trouble to solve this one. I have an RGB image with various signs. My main goal is to count the signs that are in contact with the image borders. 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've 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, insthead 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 diference between the two.
My aproach 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' doesnt seem to fill them, if I dilate them by a big amount[Fig 5] all the objects start to merge =(
Anyone have a sugestion to solve this one? There is a simpler way to do this? Any suggestions will be much appreciated!
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)

回答 (2 件)

Image Analyst
Image Analyst 2012 年 5 月 16 日
You might use imclose() to close up small gaps in the boundaries, but then it will join some signs that are close together. So then you fill the blobs (now that their boundaries are sealed) and then use watershed to split them apart again.

Geoff
Geoff 2012 年 5 月 16 日
That's a cool problem. I would tend towards a solution that involved filling the 'empty' region from your thresholded 3rd image with white, and then (starting from a white pixel) counting the number of contiguous black regions you get around the edge.
The only issue you'll have with this is that sign on the left that has its white border eaten away by the thresholding, and the recycle sign.
So you need a final filtering step that examines each detected 'edge' blob and either tries to determine whether to merge it with adjacent blobs or discards it based on some heuristics that could involve size, shape, closeness, overlap, colour, or any combination. But it looks to me like a simple locality tolerance of 10 pixels would be sufficient.
  6 件のコメント
Rui
Rui 2012 年 5 月 16 日
I tried this one: I made a structural element, diamond of size 10, then I applied imclose(img_bin, se).
se = strel('diamond',11);
closeBW = imclose(img_bin,se); figure, imshow(closeBW) [Fig 6]
fill=imfill(closeBW, 'Holes'); figure, imshow(fill) [Fig 7]
Now i just need to break the intersections of the signs that have been merged. Could watershed work in this case?
Fig 6: http://dl.dropbox.com/u/5272012/6.png
Fig 7: http://dl.dropbox.com/u/5272012/7.png
I thought this would be a simpler aproach but I dont know if its possible..
Geoff
Geoff 2012 年 5 月 16 日
Why do any processing that requires more complicated algorithms to be useful? Don't you want to apply a series of filters that simplify the problem, rather than shifting the problem elsewhere? By flood-filling the background, you clean up just about all the image noise that is going on inside the signs. Then it's just a matter of working out whether two individual blobs belong to the same sign. I don't see how making your blobs less distinct will help you here.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by