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

问题描述

=== SOLVED ===



感谢您的建议和意见。通过使用书中提供的flood_fill算法(第9章 - 图像处理)我已经实现了我想要的。我可以计数对象,为每个对象获取包围矩形(因此高度和宽度),最后可以为每个对象构造NumPy数组或矩阵。



虽然这不是一个优化的方法,它做我想要的。我使用的源代码(lab2.py)和png文件(lab2-particles.png)已放在。



您需要安装NumPy和PIL,并使用matplotlib查看直方图。



进一步更新:



p> SciPy的也正是我想要的。



David-Warde Farley Zachary Pincus 来自NumPy和SciPy邮件列表,以便将它指向我的眼睛:)



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



您好,



我有一张包含冰面阴影的图片颗粒通过粒子光谱仪测量。我想要能够识别每个对象,以便我以后分类,并在我的计算中进一步使用它们。



实质上,我愿意做的是只需实现一个模糊选择工具,我可以简单地选择每个实体。



我如何轻松解决这个问题? (最好使用Python)



谢谢。



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

  import numpy as np 

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

数组([[1,1,1],
[1,1,1],
[0,0,1]])

这是我将使用的图片中的一个部分。



解决方案

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

  2. 当你点击一个蓝色方块,然后:



    a。将此正方形记录为新对象的位置



    b。查找所有其他连续的蓝色正方形(例如,查看此正方形的邻居以及这些邻居的邻居等),并将它们标记为同一对象的一部分


  3. 继续扫描


  4. 当您找到另一个蓝色正方形时,请在执行步骤2之前先测试其是否为已知物件的一部分;或者在步骤2b中,在将某个对象与某个对象关联之后,将其删除。



===SOLVED===

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.

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.

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.

One further update:

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

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

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

Hello,

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.

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

Thanks.

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.

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

  2. When you hit a blue square then:

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

    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

  3. Continue to scan

  4. 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

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

08-21 20:25