私はあなたがやりたいことの基本的な骨組みとなるはずのいくつかのコードを下に置きます。しかし、私は重要な機能を実装せずに残しました。それは、あなたがそれを実行できるようになり、このプロセスをよりよく理解するのに役立つと思うからです。
% I assume that data_points is an M-by-2 array, where each row corresponds
% to an (x,y) coordinate pair, and M is the number of data points.
data_points = ... ;
% I assume this array stores the intensities at each data point.
intensities = ... ;
% I assume that this stores the total number of gridded polar regions you want
% to find the max intensity in (i.e. 4*(number of cells) in your picture above).
total_num_bins = ... ;
% This will store the max intensities. For places that have no nearby
% data points, the max intensity will remain zero.
max_intensities = zeros(total_num_bins);
% I assume these store the values of the center point.
x = ... ; y = ... ;
% The number of different data points.
num_data_points = length(intensities); % also equals size(data_points,1)
% Now, loop through the data points, decide which polar bin they fall in, and
% update the max intensity of that area if needed.
for ii = 1:num_data_points
% Grab the current point coordinates.
cur_x = data_points[ii,1];
cur_y = data_points[ii,2];
% Convert the current data point to polar coordinates,
% keeping in mind that we are treating (x,y) like the center.
cur_radius = sqrt( (cur_x - x)^2 + (cur_y - y)^2 );
cur_angle = atan2(cur_y - y, cur_x - x)
% You have to write this yourself, but it
% will return an index for the bin that this
% data point falls into, i.e. which of the 4 segments
% of one of the radial cells it falls into.
cur_bin = get_bin_number(cur_radius, cur_angle);
% Check if this data point intensity is larger than
% the current max value for its bin.
if ( intensities(ii) >= max_intensities(cur_bin))
max_intensities(cur_bin) = intensities(ii);
end
end
get_bin_number()
ここで、中心点から離れたデータポイントの角度と半径を入力として受け取る関数を作成する必要があります。線形配列で最大強度を維持するため、1
との間のインデックスのみを返す必要があります。total_num_bins
したがって、たとえば、インデックス番号1は、右上の象限にある最も近い放射状セルの最初の1/4ピースに対応し、インデックス2は、同じセルの次の1/4に対応し、反時計回りに移動するなどです。このような。ビンを追跡するための独自の規則を考案する必要があります。