如何计数数字图像中的对象通过Matlab中的颜色标识 [英] How to Count number Objects in an Image identify by Color in Matlab

查看:575
本文介绍了如何计数数字图像中的对象通过Matlab中的颜色标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算每种颜色标识的图像中的对象数量。



例如:我想计算图像中的黄色色调或绿色色调。 p>

>



您能给我一些提示吗?

解决方案

大米示范 a>随附于MATLAB的图像处理工具箱。如果你通过演示阅读,你已经有一些代码,将单独隔离每个米粒 - 这是如何创建图像。



至于计数谷物的数量有一个特定的颜色,如黄色或绿色,再次透过演示:清楚的是,米粒没有着色一小组离散的颜色,如黄色或绿色(或橙色或粉红色)。而是,已经专门创建了稻粒颜色,以使它们在整个色彩图中均匀分布 spring



要继续执行您的任务,您将必须提供黄色或绿色的一些定义,也许是在特定范围的RGB值范围内。



完成后,您可以使用变量标记为(在演示中为您构建)以及 regionprops 命令,给你一个在每个稻粒边界内的像素的列表。只需将这些像素与您的黄色或绿色的定义进行比较,就可以了。


I want to count number of Objects in an Image identify by each color.

Example: I want to count yellow rices or green rices in the image.

Would you please give me some tip to do it?

解决方案

You've taken this image from the rice demonstration that ships with MATLAB's Image Processing Toolbox. If you read through the demo, you already have some code that will isolate each rice grain individually - that's how the image was created.

As for counting the number of grains that have a particular color such as yellow or green, again read through the demo: it's clear that the rice grains are not colored with a small set of discrete colors such as yellow or green (or orange or pink). Rather, the rice grain colors have been specifically created so that they are equally spaced throughout the colormap spring.

So to proceed with your task you're going to have to provide some definition of 'yellow' or 'green', perhaps in terms of being within a particular range of RGB values.

Having done this, you can then use the variable labeled (that is constructed for you in the demo) together with the regionprops command, to give you a list of the pixels that are within each rice grain boundary. Simply compare those pixels to your definitions of yellow or green, and you're there.

这篇关于如何计数数字图像中的对象通过Matlab中的颜色标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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