Kernel decomposition 1.0 
Date Added: May 30, 2013  Visits: 181 


This function does the decomposition of a separable nD kernel intoits 1D components, such that a convolution with each of thesecomponents yields the same result as a convolution with the full nDkernel, at a drastic reduction in computational cost.SYNTAX:======= [K1,KN,ERR] = DECOMPOSE_KERNEL(H)computes a set of 1D kernels K1{1}, K1{2}, ... K1{N} such that theconvolution of an image with all of these in turn yields the sameresult as a convolution with the Ndimensional input kernel H: RES1 = CONVN(IMG,H); RES2 = IMG; FOR II=1:LENGTH(K1) RES2 = CONVN(RES2,K1{II}); ENDKN is the reconstruction of the original kernel H from the 1Dkernels K1, and ERR is the sum of absolute differences between Hand KN.The syntax mimics DirkJan Kroon's submission to the FileExchange(see below).EXPLANATION:============In general, for a 2D kernel H, the convolution with 2D image F: G = F * His identical to the convolution of the image with column vector H1and convolution of the result with row vector H2: G = ( F * H1 ) * H2 .In MATLAB speak, this means that> CONV2(F,H) == CONV2(CONV2(F,H1),H2)Because of the properties of the convolution, ( F * H1 ) * H2 = F * ( H1 * H2 ) ,meaning that the convolution of the two 1D filters with each otherresults in the original filter H. And because H1 is a column vectorand H2 a row vector, H = H1 * H2 = H1 H2 .Thus, we need to find two vectors whose product yields the matrix H.In MATLAB speak we need to solve the equation> H1*H2 == HThe function in the standard MATLAB toolbox, FILTER2, does justthis, and it does it using singular value decomposition: U S V' = H , H1(i) = U(i,1) S(1,1)^0.5 , H2(i) = V(i,1)* S(1,1)^0.5 . (the * here is the conjugate!)Note that, if the kernel H is separable, all values of S are zeroexcept S(1,1). Also note that this is an underdetermined problem,in the sense that H = H1 H2 = ( a H1 ) ( 1/a H2 ) ;that is, it is possible to multiply one 1D kernel with any valueand compensate by dividing the other kernel with the same value.Our solution will, in effect, just choose one of the infinite numberof (equivalent) solutions.To extend this concept to nD, what we need to understand is that itis possible to collapse all dimensions except one, obtaining a 2Dmatrix, and solve the above equation. This results in a 1D kerneland an (n1)D kernel. Repeat the process until all you have is aset of 1D kernels and you're done!This function is inspired by a solution to this problem thatDirkJan Kroon posted on the File Exchange recently:http://www.mathworks.com/matlabcentral/fil...lin1dkernelsHis solution does the whole decomposition in one go, by setting upone big set of equations. He noted a problem with negative values,which produce complex 1D kernels. The magnitude of the result iscorrect, but the sign is lost. He needs to resort to some heuristicto determine the sign of each element. What he didn't notice (ordidn't mention) is the problem that his solution has with 0 values.The SVD solution doesn't have this problem, although it sometimesdoes produce a slightly worse solution. For example, in the firstexample below, DirkJan Kroon's solution is exact, whereas this oneproduces a very small error. Where DirkJan Kroon's solution cannotfind the exact solution, this algorithm generally does better.EXAMPLES:=========Simplest 5D example: H = ones(5,7,4,1,5); [K1,~,err] = SeparateKernel(H); % D.Kroon's submission to FileEx. err [k1,~,err] = decompose_kernel(H); err2D example taken from DirkJan Kroon's submission: a = permute(rand(4,1),[1 2 3])0.5; b = permute(rand(4,1),[2 1 3])0.5; H = repmat(a,[1 4]).*repmat(b,[4 1]); [K1,~,err] = SeparateKernel(H); err [k1,~,err] = decompose_kernel(H); err2D example for which DirkJan Kroon's solution has problems: H = [1,2,3,2,1]'*[1,1,3,0,3,1,1]; [K1,~,err] = SeparateKernel(H); err [k1,~,err] = decompose_kernel(H); err3D example that's not separable: H = rand(5,5,3); [K1,~,err] = SeparateKernel(H); err [k1,~,err] = decompose_kernel(H);Example to apply a convolution using the decomposed kernel: img = randn(50,50,50); h = ones(7,7,7); tic; res1 = convn(img,h); toc k1 = decompose_kernel(h); tic; res2 = img; for ii=1:length(k1) res2 = convn(res2,k1{ii}); end toc rms_diff = sqrt(mean((res1(:)res2(:)).^2))

License: Shareware  Size: 10 KB 
Modules

Mess Letters Filter 6.x1.0
This module was created JUST FOR FUN and shouldn't be used at production servers :)This module mess letters in node text acording to The Significance of Letter Position in Word Recognition PhD Thesis, 1976, Nottingham University, by Graham... 
10 KB  
Modules

UC Multiprice 6.x1.0
A basic but powerfull module for Ubercart that allows to overide the product price based on a country.The module provides a block where the user can select a country/region. This selection is then used to select the correct price.If enabled, the... 
10 KB  
Audio Editors

PixelSpy 1.3.1
Pixel Spy is a simple utility which allows you to determine the magnitude of the various color components which make up a color on the screen. Specifically, you can select a pixel from the screen, and Pixel Spy will tell you the RGB, HSV, CMY,... 
273 KB  
Communication

Toolbox for MMSE estimators of DFT coefficients under the generalized Gamma density 1.0
Toolbox for MMSE estimators of DFT coefficients under the generalized Gamma densityThe toolbox can also be downloaded from: http://ict.ewi.tudelft.nl/~richard/The matlab files enclosed in this toolbox can be used to tabulate gain functionsfor... 
10 KB  
Development Tools

Project a planar polyline on another polyline 1.0
Compute the distances (crossranges) from a set of points% P on a plane to the planar polyline% V , and the distances (ranges) from the% projections of P on V to the first point of a segment containing% the projected point. Planar polyline V is... 
10 KB  
Games

Another Rule Based Sudoku Solver 1.0
If rules don't produce a solution, the program uses recursive method for the last resort.Usage:>> ARBSS('SDK1.txt') 
10 KB  
Education

SelfDriven Particle Model 2.1.3
Learn how simple ruledriven dynamical systems can produce complex dynamical behavior, like 2nd order phase transitions, criticality and clustering. This simulation will guide you through a tutorial that introduces the model incrementally and... 
1.74 MB  
Finance

Magic Forex Intuition 1.2.0.13
Magic Forex Intuition training software is designed to develop intuition to work at Forex (foreign exchange market). Everyday training will help you to correctly determine the correct currency exchange rate trend. With time, as you will see, you... 
4.4 MB  
Audio Tools

Zephyrus VSTi 1.1
ZEPHYRUS is a Hybrid Synthesizer that can combine the analog synthesis engine with a SoundFont oscillator in order to produce background sounds and complex pads. #SoundFont Oscillator: The SFO Uses the raw samples in a soundfont file (*.SF2) as... 
1.8 MB  
Communication

PeakFinder 1.0
This function quickly finds local peaks or valleys (local extrema) in a noisy vector using a user defined magnitude threshold to determine if each peak is significantly larger (or smaller) than the data around it. The problem with the strictly... 
10 KB 
Scripts

Freelancer Script 5.05
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Post projects. Featured projects. Private projects. Sealed projects. Edit/delete projects. Select freelancers.... 
5.49 MB  
Scripts

B2B Script 4.20
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Signup Account (Registration of account). Lead generation tools (for the sellers). Email verification to... 
5.49 MB  
Scripts

B2C Script 5.06
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). The script comes with totally editable site colors, icons and graphics Multilevel categories allows extensive browsing Admin can change Category ordering or... 
5.49 MB  
Scripts

Social Networking Script 2.86
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Registration with name, email, password, date of birth etc. User can add multiple school, college, university with start... 
5.49 MB  
Scripts

Business Networking Script 8.04
Main Features: 100% Secured. Email Support (3 Years). FREE Updates (3 Years). Ajax based interface. Profile creation. Different types of profile. Profile for jobseekers, employers and employed... 
5.49 MB  
Development Tools

VMP Viewer 1.0
This is a very rudimentary tool to visualize the VMP files generated by BrainVoyager. Useful to share files with people who do not have BV. 
10 KB  
Development Tools

Sending reports and timestamped file by emailing 1.0
main executing reference usage:[1] usage_send_mail.mIllustrates email sending with multiple separate files or single timestamped tar file. Attachment failure is properly handled, with continuation of report emailing without the attachment.[2]... 
768 KB  
Development Tools

IrisMVC 2.0 rc1
IrisMVC is an OOP PHP framework that developers can use as a strong and secure foundation to build on various web applications following the ModelViewController (MVC) pattern. It provides the basic functionality developers need, without... 
51.2 KB  
Development Tools

7Zip for Script 4.42
7Zip is a file archiver with a high compression ratio.Features: High compression ratio in new 7z format with LZMA compression Supported formats: Packing / unpacking: 7z, ZIP, GZIP, BZIP2 and TAR Unpacking only: RAR, CAB, ISO, ARJ, LZH, CHM,... 
624.64 KB  
Development Tools

Barnardextest 1.0
This file, as the Fisher's exact test, performs the exact probability test for a table of frequency data crossclassified according to two categorical variables, each of which has two levels or subcategories (2x2). It is a nonparametric... 
10 KB 