Scripts Index
Tools and Utilities Development Tools  

Kernel decomposition

download download home home   report broken
important script information
company name:
Cris Luengo
license: Shareware
minimum requirements: MATLAB 7.10 (2010a)
functional limitations:
Kernel decomposition description
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 N-dimensional 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 Dirk-Jan 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 under-determined 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 (n-1)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 thatDirk-Jan Kroon posted on the File Exchange recently:http://www.mathworks.com/matlabcentral/fil...l-in-1d-kernelsHis 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, Dirk-Jan Kroon's solution is exact, whereas this oneproduces a very small error. Where Dirk-Jan 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 Dirk-Jan 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 Dirk-Jan 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))
Similar scripts
Rob Keyboard (Popularity: ) : This plugin is produced for holding on keyboard when pairing program. You can type "shift ctrl K" to lock intellJ by a Dialog with amusing words. You can lock intellJ by password, with configging password enabled.At first, you should add ...
CIE Coordinate Calculator (Popularity: ) : This software is for calculating the CIE chromaticity co-ordinates of phosphor materials using the photo luminescence data. The software also shows the position of the co-ordinates in chromaticity diagram and expected color of the material. Please note that the color ...
New Dream Coder for Oracle (Popularity: ) : This tool is an code generator for Oracle. While fetching large tables this tool reduces usage of memory. Some features of this tool are, it has new password ecryption, procedure builder, session monitor, SQL templates etc., It increases execution times ...
Foreign Exchange Options (Popularity: ) : fxoptions( S0, X, rd, rf, T, vol, style)Valuation of European and American call and put options on foreign exchange using Garman-Kohlhagen model.European option prices are given by an exact formula (Garman-Kohlhagen).American option prices are approximated using both binomial and trinomial ...
Anti Cut and Paste (Popularity: ) : This utility is helpful for programmers that allows them to search programming language source code's text fragments which have been copied and pasted. Some key features of this tool are, this tool supports both command line and Graphical User Interface ...
AC Protect Standard (Popularity: ) : This utility is used for avoiding hackers from cracking your software using special techniques called anti crack. It works with all windows platforms. Some features of this tool are, this tool compresses ocx, scr, exe, dll and more, dynamic encrypt ...
Bokai Barcode Image generator (Popularity: ) : This tool is used for barcode generator and which has an ActiveX control for printing barcodes. This tool contains more than twenty five barcode types. This tool supports only ActiveX control programs. Users can customize barcode parameters and design of ...
VBcodePrint (Popularity: ) : This Add-In to Microsoft Visual Basic 6 significantly enhances its source code printing capabilities. You can print any part of your VB project's source code from within the VB's development environment. / You can create and save your own output ...
Use Matlab Editor to Write and Run Ansys Program. (Popularity: ) : You don't have to switch your screen between Matlab, Ansys and UltraEdit or PSPad anymore, when you doing FEM-Analysis.You can use MEditor to write your Ansys APDL program and use the excellent feature of MEditor to structure your Code: Cell-Function, ...
VBAcodePrint (Popularity: ) : This add-in enables you to print Microsoft VBA source code in color of your applications across the entire Microsoft Office 2000 suite of applications: Word, Excel, Outlook, Access, PowerPoint, and FrontPage and any other VBA enabled software. / You can ...
User reviews

Write a review:
1 2 3 4 5 6 7 8 9 10
1=poor 10=excellent
Write review*
Your name*
Email*
  (Comments are moderated, and will not appear on this site until the editor has approved them)
 
Similar Software
Kernel for NTFS - Data Recovery Software (Popularity: ) : Kernel for NTFS recovers deleted files and data from deleted, formatted, damaged, or corrupted partitions where NTFS based operating systems, such as Windows 95, Windows 98, Windows ME, Windows 2000, Windows XP, Windows 2003 are installed on the hard disk ...
Kernel Word - Repair Corrupted Word Documents (Popularity: ) : Kernel for Word - recovers corrupted word document files corrupted due to unexpected system shutdown, virus attacks. During repairing process a complete scan of the all the damaged documents is performed to locate and extract the recoverable information. After the ...
Kernel Access - Repair Corrupt Access Databases (Popularity: ) : Kernel for access - recovers corrupted access database files corrupted due to unexpected system shutdown, virus attacks. During repairing process a complete scan of the all the damaged files is performed to locate and extract the recoverable information. After the ...
Kernel Novell NSS Data Recovery Software (Popularity: ) : Nucleus Kernel Novell NSS recovers data from corrupted or deleted Novell NSS Volumes. Nucleus Kernel Novell NSS - Netware Data Recovery Software recovers and restores data from corrupt volume(s) of a crashed Novell Server. Nucleus Kernel Novell NSS Data Recovery ...
Nucleus Kernel Digital Media Recovery Software (Popularity: ) : Nucleus Kernel Digital Image recovery software is helpful in the following cases of data loss: Provides Image Recovery after corruption due to the card being pulled out while the camera is on. Provides Photo Recovery after corruption due to turning ...
Kernel Undelete - Deleted File Recovery Software (Popularity: ) : Nucleus Kernel Undelete recovers deleted data and files from FAT and NTFS partitions on Windows 95, Windows 98, Windows ME, Windows NT, Windows 2000, Windows XP, Windows 2003. During recovery process a complete scan of the damaged hard drive or ...
Nucleus Kernel for CD-DVD Data Recovery Software (Popularity: ) : Kernel for CD-DVD has got explorer like interface which allows easy access, to all the files and folders per file-system. Easily access data from older sessions, access data that your OS (e.g. Windows) does not see or hides from you ...
RootKit Hook Analyzer (Popularity: ) : RootKit Hook Analyzer is a security tool which will check if there are any rootkits installed on your computer which hook the kernel system services. Kernel RootKit Hooks are installed modules which intercept the principal system services that all programs ...
Nucleus Kernel - Formatted Drive Recovery Software (Popularity: ) : Kernel for NTFS recovers deleted files and data from deleted, formatted, damaged, or corrupted partitions where NTFS based operating systems, such as Windows 2000, Windows XP, Windows 2003 are installed on the hard disk or data storage media.During recovery process ...
Kernel for DBF - Repair corrupted DBF files (Popularity: ) : Kernel for DBF - corrupted database recovery software supports Microsoft Visual FoxPro (.dbf) databases. Kernel for DBF - recovers corrupted DBF database files corrupted due to unexpected system shutdown, virus attacks or error reading media where documents are stored. Kernel ...
ad


Rate me
supported os
Linux
Mac OSX
Macintosh
Win All, BSD, Solaris
stats
downloads 2
version 1.0
size in Kb 10
popularity   
709/370724
user rating 5/10
New Scripts
Popular Scripts
Latest Reviews