圆邻域运算:matlab颜色直方图 [英] Circular neighborhood operations: matlab color histogram

查看:243
本文介绍了圆邻域运算:matlab颜色直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个灰度图像。考虑每个像素周围的圆形邻域窗口。我需要在每个像素周围获得圆形邻域的颜色直方图。

Assume that I have a grayscale image. Consider a circular neighborhood window around each pixel. I need to get color histogram of circular neighbourhoods around each pixel.

如何在MatLab中有效地实现这个问题的循环邻域操作?

How can I efficiently implement circular neighborhood operations for this problem in MatLab?

推荐答案

我不想给你一切,但我认为这应该能帮你很多。

I don't want to give you everything, but I think this should help you out a lot.

你可以做一个圆圈做一些像

Well you can make a circle of ones doing something like

h = fspecial('disk',rad);
h = h>0;

然后,你可以把它放在一个更大的矩阵中执行

Then you can put that anywhere in a larger matrix doing something like

h2 = zeros(N,M);
h2(c_offset-rad:c_offset+rad,r_offset-rad:r_offset+rad) = h;

现在你有一个与你的图像大小相同您可以使用此作为从矩阵获取数据的参考表,大致相同的方式,您可以通过说

Now you have a matrix the same size (col/row size) as your image. You can use this as a reference table for getting data from a matrix, much in the same way you can return only the values above 0.5 by saying

r = rand(10);
d = r(r>0.5);

编辑

您还需要在某些地方使用数据类型,使MATLAB快乐。例如,h2将需要是一个逻辑,以使用它作为另一个矩阵的参考表。如果没有正确的类型,hist也不会工作。

You'll also need to play around with the data types in some places to make MATLAB happy. For example, h2 will need to be a logical to use it as a reference table for another matrix. And hist won't work without proper types either.

这篇关于圆邻域运算:matlab颜色直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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