如何圈选/突出显示/矩形图像的某些区域? [英] How to circle/highlight/rectangle certain regions of an image?

查看:249
本文介绍了如何圈选/突出显示/矩形图像的某些区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个灰度图像,其中包含需要在WPF C#程序中圈出的各个区域。这种图像的一个例子是:

I have a grayscale image with various regions that need to be circled in a WPF C# program. An example of such an image would be this:

我想要圈出的区域是白色区域,这样:

The regions I'm looking to circle are the white ones, in this manner:

到目前为止我要做的是制作一个字节数组,由每个像素的强度组成(0为黑色和白色为40​​00及以上。)然后我通过阈值测试传递每个字节,看看它是否是一个像素的一部分它中的区域与否(例如,如果字节的长度超过3500,则将其视为区域的一部分,否则不是。)

So far what I'm trying to do is make an array of bytes, consisting of the intensity of each pixel (0 being black and white being 4000 and upwards.) I then pass each byte through a threshold test to see if its a pixel with part of the region in it or not (for example, if bytes have lengths beyond 3500, consider it as part of the region, else it's not.)

我感到难过在此之后做。到目前为止,我的一个想法是找到一行中某个区域的第一个像素,然后找到一个区域底部的行区域的最后一个像素(左上角和右下角。)然后我会找到两个像素之间的距离,并使用它来获得中心点(我可以用它来获得绘制圆圈所需的坐标。)这种方法的问题我认为是噪音会导致许多圆圈出现在图像上或误导了圈子。我想我可以使用阈值来消除小圆圈。

I am stumped as what to do after this. So far one of my ideas is to find the first pixel of a region within a row, then find the last pixel of a region of row on the bottom of a region (so top left and bottom right.) Then I'd find the distance in between both pixels and use that to get the center point (from which I could use to get the coordinates needed to draw circle.) Issues with this method I think would be noise that would either cause many circles to appear on the image or misinformed circles. I guess I could use thresholds to eliminate small circles though.

这些图像实际上是视频的帧(信息是作为字节数组获得然后写入WriteableBitmap) ,所以我不知道是否有太多的数据操作会落后于镜头。我也是C#,字节和CS的新手,但这个项目是我在冬歇期学习如何编程的。任何答案或资源都会受到高度赞赏,特别是在伪代码或C#中。

These images are actually frames of a video (information is obtained as a byte array and then written to a WriteableBitmap) , so I don't know if too many manipulations with the data would lag the footage. I'm also a newbie with C#, bytes and CS in general, but this project is something I took up during my winter break to learn how to program. Any answers or resources would be much appreciated, especially in pseudocode or C#.

推荐答案

从你所说的听起来像计算机视觉我的问题。我曾经开发过几个基于C#的CV问题应用程序。基本的想法是使用GDI +将 Bitmap.Lockbits()对象编组到 Byte [] 并进行操作,或者只是使用 Bitmap.SetPixel()Bitmap.GetPixel(),但它们的速度要慢得多。

From what you said it sounds like a Computer Vision problem to me. I used to develop couple of CV problem applications based on C#. Basic idea is using GDI+ to marshal Bitmap.Lockbits() object into Byte[] and do the manipulation, or simply use Bitmap.SetPixel() Bitmap.GetPixel(), but they are tolerably slower.

一个很好的选择是使用 EmguCV 。适用于.NET 2.0及更高版本的OpenCV包装器。因此,编写C#来解决CV问题更为明显。

A great choice is to use EmguCV. A OpenCV wrapper for .NET 2.0 and up. Thus making writing C# to solve CV problem much eaiser.

这篇关于如何圈选/突出显示/矩形图像的某些区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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