简单的物体识别 [英] Simple object recognition

查看:22
本文介绍了简单的物体识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

===已解决===

感谢您的建议和意见.通过研究 Beginning Python Visualization 一书(第 9 章 - 图像处理)中给出的 flood_fill 算法) 我已经实现了我想要的.我可以计算对象,获取每个对象的封闭矩形(因此是高度和宽度),最后可以为每个对象构造 NumPy 数组或矩阵.

Thanks for your suggestions and comments. By working on the flood_fill algorithm given in Beginning Python Visualization book (Chapter 9 - Image Processing) I have implemented what I have wanted. I can count the objects, get enclosing rectangles for each object (therefore height and widths), and lastly can construct NumPy arrays or matrices for each of them.

虽然它不是一种优化的方法,但它可以满足我的需求.我使用的源代码 (lab2.py) 和 png 文件 (lab2-particles.png) 已放在 http://code.google.com/p/ccnworks/source/browse/#svn/trunk/AtSc450.

Although it is not an optimized approach it does what I want. The source code (lab2.py) and the png file (lab2-particles.png) that I use have been put under http://code.google.com/p/ccnworks/source/browse/#svn/trunk/AtSc450.

您需要安装 NumPy 和 PIL,并使用 matplotlib 来查看直方图.代码的核心位于 objfind 函数中,主要的递归对象搜索动作发生在该函数中.

You need NumPy and PIL installed, and matplotlib to see the histogram. Core of the code lies within the objfind function where the main recursive object search action occurs.

进一步更新:

SciPy 的 ndimage.label() 也完全符合我的要求.

SciPy's ndimage.label() does exactly what I want, too.

为 NumPy 和 SciPy 邮件列表中的 David-Warde FarleyZachary Pincus 欢呼:)

Cheers for David-Warde Farley and Zachary Pincus from the NumPy and SciPy mailing-lists for pointing this right into my eyes :)

=============

你好,

我有一张图像,其中包含由粒子光谱仪测量的冰粒子的阴影.我希望能够识别每个对象,以便以后可以在计算中进一步分类和使用它们.

I have an image that contains the shadows of ice particles measured by a particle spectrometer. I want to be able to identify each object, so that I can later classify and use them further in my calculations.

本质上,我愿意做的是简单地实现一个模糊选择工具,在这里我可以简单地选择每个实体.

In essence, what I am willing to do is to simply implement a fuzzy selection tool where I can simply select each entity.

我怎样才能轻松解决这个问题?(最好使用 Python)

How could I easily solve this problem? (Preferably using Python)

谢谢.

注意:在我的问题中,我将每个特定的连接像素称为对象或实体.我打算提取它们并创建 NumPy 数组表示,如下所示.(这里我使用左上角的对象;如果存在像素,则使用 1,如果不使用 0.该对象的形状是 3 x 3,对应的 3 像素高 x 3 像素宽.这些是真实冰粒子在 2D 域上的投影, 假设它们是球形的,等效半径为 (height+width)/2,之后会进行一些缩放——从像素到实际大小和体积计算)

NOTE: In my question I am referring to each specific connected pixels as objects or entities. My intention to extract them and create NumPy array representations as shown below. (Here I am using the top-left object; if a pixel exist use 1's if not use 0's. This object's shape is 3 by 3 which correspondingly 3 pixel height by 3 pixel width. These are projections of real ice-particles onto 2D domain, under the assumption of their being spherical and equivalent radius is (height+width)/2, and later some scalings --from pixels to actual sizes and volume calculations will follow)

import numpy as np

np.array([[1,1,1], [1,1,1], [0,0,1]])

array([[1, 1, 1],
       [1, 1, 1],
       [0, 0, 1]])

这是我将要使用的图片中的一部​​分.

Here is a section from the image which I am going to use.

截图 http://img43.imageshack.us/img43/2327/particles.png

推荐答案

  1. 扫描每个方格(例如从左上角、从左到右、从上到下)

  1. Scan every square (e.g. from the top-left, left-to-right, top-to-bottom)

当你击中一个蓝色方块时:

When you hit a blue square then:

一个.将此方格记录为新对象的位置

a. Record this square as a location of a new object

b.找到所有其他相邻的蓝色方块(例如通过查看该方块的邻居以及这些邻居的邻居等)并将它们标记为同一对象的一部分

b. Find all the other contiguous blue squares (e.g. by looking at the neighbours of this square, and the neighbours of those neighbours, etc.) and mark them as being part of the same object

继续扫描

当你找到另一个蓝色方块时,在进行第 2 步之前测试它是否是已知对象的一部分;或者,在步骤 2b 中,将任何正方形与对象关联后擦除它

When you find another blue square, test to see whether it's part of a known object before going to step 2; alternatively in step 2b, erase any square after you've associated it with an object

这篇关于简单的物体识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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