matlab 形态学 颗粒,使用Matlab进行形态学操作

Here is the problem:

A camera takes an image I of a penny, a dime, and a quarter lying on a white

background and the coins do not overlap. Suppose that thresholding creates a binary image B successfully

with 1 for the coin regions and 0 for the background.

You are given the known diameters the coins d_p, d_d, and d_q in pixels (note that d_d < d_p < d_q). How do I use morphology operations (dilation, erosion, opening, and

closing) and logical and set operations (AND, OR, NOT, and set difference), to produce three binary output images P, D, and Q, where P should contain just the penny, D should contain just the dime, and Q should contain just the quarter?

Can anyone give the codes or some hints? Thanks in advance!

解决方案

This obviously looks like homework so I won't write any code for you, but I'll give you some hints to push you in the right direction. The situation you described is highly idealized and not reflective of real-world situations.... which is actually great as it makes coding a lot more simpler. I'm going to assume that the picture was taken directly above the surface with the coins and not on an angle.

You already know the diameters of each of the coins, and because the diameters are in pixels, this makes this problem a whole lot easier. As such, you would specify three structuring elements that are circular that have the same diameters for each of the coins.

First do a morphological opening on B using the largest structuring element, which is the quarter. Opening is an erosion, followed by a dilation. One thing you should know about erosion is that any objects that are smaller than the structuring element will disappear while those that are larger will have pixels in the object that remain. As such, by doing a closing, you would remove the penny and dime, while the quarter will be fully reconstructed. One good thing about opening is that if your structuring element is smaller than the object itself, doing an opening should keep the object the same, provided that the structuring element and object follow more or less the same characteristics. Because your structuring element is circular and so are the coins, we're good to go. As such, this is your first image Q.

Next, use the second largest structuring element, which is the penny, and do an opening on the image B. What will happen now is that the dime should disappear while the quarter and the penny should still remain. As such, do a set difference between this image and Q. Our result is just the dime that is left, and so this is P.

Finally for the dime, you actually don't even need to do any morphology. Do a logical OR operation to combine the quarter Q and penny P to get a combined image. After, do a set difference between the original image B and this combined image. You'll then isolate the dime, which is now D.

This should be enough to get you started. Good luck!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值