[R] Centre of gravity of a mountain

Peter Langfelder peter.langfelder at gmail.com
Tue Nov 9 23:37:39 CET 2010


On Mon, Nov 8, 2010 at 11:31 PM, Ab Hu <master.rstat at yahoo.com> wrote:
>
> Thanks! Works great.
> I have more questions on this, so I'll continue here:
>
> Now that I have the weighted mean, is it possible to reduce the size of
> mountain based on this weighted mean such the original matrix remains 21x21
> while the mountain shrinks/converges.
> Step for my analysis:
> 1) Find centroid/weighted mean of the mountain -> DONE
> 2) Use centroid value and shrink the mountain to user specified size (half
> or quarter).
> 3) Keep the matrix size to 21x21 (or whatever the original size was).
> Basically make the area around the mountain flat (insert zeros using rbind,
> cbind?)
> 4) Compare this mountain with other 21x21 matrices, i.e. perform
> cross-correlation between them.

Sorry, I'm not sure what you want to do in points 2-4. Shrink the
mountain vertically or horizontally? You can for example look up image
resizing algorithms if you want to shrink the area under the mountain
but keep  the shape of the mountain (approximately) the same. For
cross correlation, simply do cor( c(mountainMatrix1),
c(mountainMatrix2)). The c() function takes values in a matrix and
"straightens" them out into a single vector.

Peter



More information about the R-help mailing list