Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

image processing - Circular neighborhood operations: matlab color histogram

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

EDIT:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...