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

查看:22
本文介绍了圆形邻域运算: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;

现在您有了一个与图像大小(列/行大小)相同的矩阵.您可以将其用作从矩阵中获取数据的参考表,就像您可以通过说仅返回 0.5 以上的值一样

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天全站免登陆