Dear all,

I have a set of matrix and I need to compute several measures on source image and to generate other matrices, in a moving window way. My input images have integer and double precision values, and also NAs.

I need to compute some measures that I will define as functions (like the sample below). As a tentative way of to do so, I made two for() looping, but I feel that the spear is so slow. For the sample below the time is not so big, but in fact I will neet about 1.000 matrices, and for several windows sizes (like 3=3x3.... up to 17x17).

Any idea?


window.size<-7 # 7x7
window.offset<-(window.size-1)/2
vin<-matrix(runif(10000)*20,nc=100)
vin[sample(1:length(vin),1000)]<-NA
x11(1024,768)
image(vin)

vin.range<-vin; vin.range[]<-NA
vin.range<-vin; vin.range[]<-NA
vin.sde<-vin; vin.sde[]<-NA
vin.min<-vin; vin.min[]<-NA

for (ll in (window.offset+1):(dim(vin)[1]-window.offset))
{
for (cc in (window.offset+1):(dim(vin)[2]-window.offset))
{
 windows.tmp<-vin[(ll-window.offset):(ll+window.offset),(cc-window.offset):(cc+window.offset)]
 if (length(windows.tmp[!is.na(windows.tmp)])>0) {
  vin.range[ll,cc]<-range(windows.tmp[!is.na(windows.tmp)])[2]-range(windows.tmp[!is.na(windows.tmp)])[1]
  vin.sde[ll,cc]<-sd(windows.tmp[!is.na(windows.tmp)])
  vin.min[ll,cc]<-min(windows.tmp[!is.na(windows.tmp)])
  }
} #ll
} #cc

par(mfrow=c(2,2))
image(vin,main=paste("VIN - ws =",window.size,"\n",var.desc),col=rainbow(20),panel.first = grid(8,8))
image(vin.range,main="VIN.RANGE",col=rainbow(20),panel.first = grid(8,8))
image(vin.sde,main="VIN.SD",col=rainbow(20),panel.first = grid(8,8))
image(vin.min,main="VIN.MIN",col=rainbow(20),panel.first = grid(8,8))


Thanks,

Miltinho
Brazil.



 para armazenamento!

	[[alternative HTML version deleted]]

