检查图像中太薄的区域 [英] Check for areas that are too thin in an image

查看:94
本文介绍了检查图像中太薄的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试验证雕刻机的黑白图像(更多的剪贴画图像 - 而不是照片)。

我需要考虑的主要事项之一是区域的大小(或线宽),因为机器无法处理太薄的线 - 所以我需要找到比给定阈值更薄的区域。

I am trying to validate black and white images (more of a clipart images - not photos) for an engraving machine.
One of the major things I need to take into consideration is the size of areas (or width of lines) since the machine can't handle lines that are too thin - so I need to find areas that are thinner than a given threshold.

拿这个例如:

竖琴的琴弦可能太薄而无法雕刻。

The strings of the harp might be too thin to engrave.

我正在阅读关于Matlab和OpenCV但是图像处理是我第一次学习的领域。

I am reading about Matlab and OpenCV but image processing is an area I am learning about for the first time.

我是一名Java / C#开发人员,因此使用其中一种语言进行的实施对我来说是最好的,但任何方向都会受到高度赞赏。

I am a Java / C# developer so implementation done with one of those languages will be best for me but any direction will be greatly appreciated.

推荐答案

使用 matlab 利用图像形态操作

定义允许区域的最小厚度,例如 minThick = 4

Define the minimal thickness of allowed area, for example, minThick=4

BW = imread('http://i.stack.imgur.com/oXKep.jpg'); 
BW = BW(:,:,1) < 128; %// convert image to binary mask
se = strel('disk', minTick/2, 0); %// define a disk element   
eBW = imerode( BW, se ); %// "chop" half thickness from mask
deBW = imdilate( eBW, se ); %// dilate the eroded mask

侵蚀和扩张应该留下比<$ c $更厚的区域c> minThick 不变,但会删除细小区域

Eroding and dilating should leave regions that are thicker than minThick unchanged, but it will remove the thin areas

invalidArea = BW & ~deBW; %// pixels that are in BW but not in deBW

结果:

Resulting with:

您可以阅读更多关于 imdilate imerode

You can read more about imdilate and imerode in the linked documentation.

这篇关于检查图像中太薄的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆