[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to average to find 'circular' symmetry in a SQUARE matrix?
From: |
Paul Kienzle |
Subject: |
Re: How to average to find 'circular' symmetry in a SQUARE matrix? |
Date: |
Mon, 15 Jan 2007 22:46:18 -0500 |
Robert,
Here is a possible algorithm for computing a circular average:
1. For each pixel, compute the distance from the center
2. Round each distance to the nearest integer
3. Average all values associated with each distance
4. Assign the averages back to the corresponding pixels.
You can use sparse matrices to do this without loops:
% Find distances to each pixel
[nx,ny] = size(z);
cx = (nx+1)/2;
cy = (ny+1)/2;
[ii,jj] = meshgrid(1:nx,1:ny);
d = round(sqrt((ii-cx).^2 + (jj-cy).^2));
% Put each pixel in a new row and each distance in
% a separate column.
X = sparse(1:nx*ny,d,z);
% Sum and average the columns
avg = sum(X)./sum(X!=0);
% Assign the average back into the matrix.
z(:) = avg(d);
This does not do any anti-aliasing. To add support for that I would
break each pixel into three bands and approximate the intersection of a
1-pixel wide ring at three consecutive integer distances through the
pixel. The value should then be assigned proportionally to the three
distances, keeping track of the proportions for the final average.
When reconstructing the image, the proportions are again needed to
distribute the averages from the three distances back into the pixel.
- Paul
On Jan 15, 2007, at 9:01 PM, Robert A. Macy wrote:
Doug,
I have an x-y matrix of an axisymmetric structure.
It is true that I can create a new matrix, whose individual
values are determined by drawing a circle through EACH
point and filling in that specific data point with the
integrated average around each circle arc. Note there
would be duplicate values as each single arc should
coincide with 4 locations.
It seems possible to find the average around the arc by
using very small angle steps. and probably get away with
linear interpolation between any 4 data points closest to
each position along the arc. That means a lot of pieces as
I go around the arc and tiny angle steps along the arc to
make certain it's small enough. A lot of work.
I guess my question is after doing all that effort does it
come out about the same as if I had just averaged quadrants
together and mirror images of quadrants together?
Or, is there a gain in complexing up the solution?
To understand what I'm doing. picture the sombrero as
shown in x-y plane. Add noise to the image. Now, find the
sombrero again without the noise in it.
- Robert -
On Mon, 15 Jan 2007 20:45:37 -0500
Doug Stewart <address@hidden> wrote:
Obviously if you wanted the average of the array then
there would be no question: so what do you want the
average of?
If you want the average of a doughnut section then if
you do rectangular to polar conversion and select all the
point that have a radius between m and n you could
average them.
I'm not sure what you want.
Doug
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave