help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: colfilt() funtion analog for Octave?


From: Williams, Timothy J Mr CECOM RDEC NVESD
Subject: RE: colfilt() funtion analog for Octave?
Date: Mon, 29 Apr 2002 15:44:31 -0400

Thanks for the location of the functions. I don't much about MatLab or
Octave, but I know a few people here that know MatLab that can help me with
the colfilt function. I hope I can get this code to work. It's only a
handful of small files, so it should be manageable. 

----
Tim Williams                                                 COM: (703)
704-1685
Night Vision & Electronic Sensors Directorate  DSN: 654-1685
10221 Burbeck Road, Suite 430                      FAX: (703) 704-1753
Ft. Belvoir, VA 22060-5806                             EMAIL:
address@hidden


-----Original Message-----
From: Paul Kienzle [mailto:address@hidden
Sent: Monday, April 29, 2002 2:43 PM
To: Williams, Timothy J Mr CECOM RDEC NVESD
Subject: Re: colfilt() funtion analog for Octave?


BTW, I have a roughed in version of colfilt you can try.  Please correct it
and make
it compatible so that I can add it to octave-forge.

## colfilt(A,[r c],'sliding',f,...)
##   For each r x c overlapping subblock of A, add a column in matrix C
##   f(C,...) should return a row vector which is then reshaped into a
##   a matrix of size A and returned.
## colfilt(A,[r c],'distinct',f,...)
##   For each r x c non-overlapping subblock of A, add a column in matrix C
##   f(C,...) should return a matrix of size C each column of which is
##   placed back into the subblock from whence it came.

## This software is granted to the public domain

function B = colfilt(A,blksize,blktype,f,...)

   [m,n]=size(A);
   r = blksize(1);
   c = blksize(2);

   switch blktype
   case 'sliding'
     # pad with zeros
     padA = zeros(m+r-1,n+c-1);
     padA([1:m]+floor(r/2),[1:n]+floor(c/2)) = A;
     [padm,padn] = size(padA);
     colidx = [0:r-1]'*ones(1,c) + padm*ones(r,1)*[0:c-1];
     offset = [1:m]'*ones(1,n) + padm*ones(m,1)*[0:n-1];
     idx = colidx(:)*ones(1,m*n) + ones(r*c,1)*offset(:)';
     idxA = zeros(r*c,m*n);
     idxA(:) = padA(:)(idx);
     B = zeros(size(A));
     B(:) = feval(f,idxA,all_va_args);
   case 'distinct'
     if (r*floor(m/r) != m || c*floor(n/c) != n)
        error("colfilt expected blocks to exactly fill A");
     endif
     colidx = [0:r-1]'*ones(1,c) + m*ones(r,1)*[0:c-1];
     offset = [1:r:m]'*ones(1,n/c) + m*ones(m/r,1)*[0:c:n-1];
     idx =colidx(:)*ones(1,m*n/r/c) + ones(r*c,1)*offset(:)';
     idxA = zeros(r*c,m*n/r/c);
     idxA(:) = A(:)(idx);
     B = zeros(prod(size(A)),1);
     B(idx) = feval(f,idxA,all_va_args);
     B = reshape(B,size(A));
   endswitch
endfunction


Paul Kienzle
address@hidden
On Mon, Apr 29, 2002 at 10:49:26AM -0400, Williams, Timothy J Mr CECOM RDEC
NVESD wrote:
> Is there a function out there for Octave that is analagous to the colfilt
> function from the Image Processing Toolbox in MatLab. For that matter,
what
> about other functions in the Image Processing Toolbox?
> 
> Also, what about repmat()? This replicates and tiles an array,
> prctile - Staticics Toolbox
> 
> Thanks
> 
> ----
> Tim Williams                                                 COM: (703)
> 704-1685
> Night Vision & Electronic Sensors Directorate  DSN: 654-1685
> 10221 Burbeck Road, Suite 430                      FAX: (703) 704-1753
> Ft. Belvoir, VA 22060-5806                             EMAIL:
> address@hidden
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]