问题描述
我有泥的Tiger's Pugmark(足迹印象)的形象。我想检测的图标的边界,但图像的强度是均匀的,前景和背景不能根据强度变化区分。我可以做什么来区分pugmark和背景。
I have image of Tiger's Pugmark (footprint impression) in mud. I want to detect the boundary of the pugmark but the image is uniform in intensity that is foreground and background cannot be distinguished based on intensity variations. What can i do to distinguish between the pugmark and the background.!
推荐答案
如果您同时具有
- 良好的标记;
然后它可以直接由流域转变。当然,问题是获得这些标记,以及根据需要增强相关边缘。获取这些可能涉及特定于问题的知识,我没有为您的问题。
then it is directly solved by a Watershed Transform. The problem, of course, is obtaining these markers, as well enhancing relevant edges as needed. Obtaining these might involve problem-specific knowledge, which I don't have for your problem.
然而,有一些一般的方法可能是有用的。例如,来自数学形态学的连接算子用作合并和延伸平坦区域的方式。因此,也许它可以给我们相对好的标记为问题。在下面的图像中,在原始图像的灰度版本(左图像)中执行通过打开的形态学重建(一种连接的算子),并且剩余的区域最大值在右边示出。
Nevertheless, there are some general methods that might be useful. For instance, connected operators from Mathematical Morphology serve as a way to merge and extend flat zones. Thus, maybe it can give us relatively good markers for the problem. In the following image a morphological reconstruction by opening (a kind of connected operator) was performed in the grayscale version of the original image (left image), and the remaining regional maximum is shown at right.
现在,我们可以获得上面左图像的形态梯度。我们还可以在上面的右图像中进行孔填充和扩张以获得更平滑的轮廓 - 这定义了我们的标记图像。然后,使用我们的标记图像在渐变图像中应用流域变换,然后展开(侵蚀或膨胀,取决于你的看法)分水岭线,我们得到以下图像:
Now, we can obtain the morphological gradient of the left image above. We can also do hole filling and a dilation with a small disk in the right image above to obtain more smooth contours -- this defines our marker image. Then, applying a Watershed Transform in the gradient image using our marker image, and then expanding (erode or dilate, depends on how you see it) the watershed lines, we get the following image:
>
我怀疑你可以很容易地丢弃太大和太小的区域。然后,如果你有一些粗糙的预期尺寸的爪子,以及手掌,你可以丢弃不相关的地区。在这一点上,只需要扩大区域以形成单个分量,并在原始图像中显示生成的轮廓:
I suspect that you can discard too large and too small regions easily. Then, if you have some rough expected sizes for the claws, as well for the palm, you can discard the irrelevant regions. At this point it is only a matter of dilating the areas to form a single component and show the resulting contour in the original image:
执行每个步骤的示例代码(相关步骤也显示在注释的Matlab代码中):
Sample code for performing each step (the relevant steps are also shown in commented Matlab code):
f = Import["http://imageshack.us/a/img407/4636/p1060993g.jpg"]
g = ColorConvert[f, "Grayscale"] (* g = rgb2gray(f); *)
(* First image shown: *)
geo = GeodesicOpening[g, DiskMatrix[5]] (* geo = imreconstruct(imerode(g, ... *)
(* strel('disk', 6)), g); *)
(* Second image shown: *)
marker = MaxDetect[geo] (* marker = imregionalmax(geo); *)
(* Watershed on gradient with markers. *)
mgrad = ImageSubtract[Dilation[geo, 1], Erosion[geo, 1]]; (* mgrad = ... *)
(* imdilate(geo,strel('square',3)) - imerode(geo,strel('square',3)); *)
ws = Image[ (* ws = watershed(imimposemin(mgrad, bwmorph(imfill(... *)
WatershedComponents[mgrad, (* imregionalmax(geo),'holes'),'dilate')))); *)
Dilation[FillingTransform[marker], DiskMatrix[1]]]]
(* Third image shown: *)
wsthick = Erosion[ws // ImageAdjust, DiskMatrix[5]]
(* Connected component selection based on some supposed sizes. *)
ccs = SelectComponents[wsthick, "Count", 1000 < # < 3000 || 6000 < # < 10000 &]
(* Final image (thick border on binarized filled dilated ccs) *)
res = ImageAdd[f, Dilation[MorphologicalPerimeter[FillingTransform[
MorphologicalPerimeter[Dilation[ccs, DiskMatrix[9]]]]], 2]]
这篇关于检测均匀强度图像中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!