├── .gitignore ├── README.md ├── articles ├── 09-d-normalized-cuts.pdf ├── 2014_blind_image.pdf └── SM-ncut.pdf ├── docs ├── abstract.tex ├── article.tex ├── clustering.tex ├── conclusions.tex ├── cvpr.sty ├── cvpr_eso.sty ├── egbib.bib ├── eso-pic.sty ├── fingerprint.tex ├── ieee.bst ├── images │ ├── confusion_matrix_fb_highres_4.png │ ├── confusion_matrix_fb_highres_4_bis.png │ ├── confusion_matrix_fb_highres_5.png │ ├── confusion_matrix_fb_highres_5_bis.png │ ├── confusion_matrix_fb_highres_6.png │ ├── confusion_matrix_fb_highres_6_bis.png │ ├── confusionmatrix_fb_4.png │ ├── confusionmatrix_fb_5.png │ ├── confusionmatrix_fb_6.png │ ├── confusionmatrix_nat_4.png │ ├── confusionmatrix_nat_5.png │ ├── confusionmatrix_nat_6.png │ ├── prnu_extraction.jpg │ ├── prnu_extraction_2.jpg │ ├── soglia_imgnat_AC.png │ ├── soglia_imgnat_NC.png │ ├── soglia_imgnat_fb_AC.png │ ├── soglia_imgnat_fb_NC.png │ ├── validation.jpg │ └── validation_2.jpg ├── introduction.tex ├── prnu.tex ├── results.tex ├── slides │ ├── beamercolorthemetorinoth.sty │ ├── beamerfontthemetorinoth.sty │ ├── beamerinnerthemetorinoth.sty │ ├── beamerouterthemetorinoth.sty │ ├── beamerthemeTorinoTh.sty │ ├── conclusions.tex │ ├── firenze.jpg │ ├── hf-tikz.sty │ ├── intro.log │ ├── intro.tex │ ├── metodo.tex │ ├── proof.sty │ ├── references.log │ ├── references.tex │ ├── results.log │ ├── results.tex │ ├── slides.dvi │ ├── slides.out │ ├── slides.tex │ ├── slides.vrb │ ├── texput.log │ └── validation.tex └── validation.tex └── matlab ├── CameraIdentification.m ├── CameraValidation.m ├── Example.m ├── Filter ├── MakeONFilter.m ├── Makefile ├── NoiseExtract.m ├── Threshold.m ├── WaveFilter.m ├── WaveNoise.asv ├── WaveNoise.m ├── compile.m ├── mdwt.c ├── mdwt.cpp ├── mdwt.dll ├── mdwt_r.h ├── midwt.c ├── midwt.cpp ├── midwt.dll ├── midwt_r.h ├── mirdwt.c ├── mrdwt.c └── quadlength.m ├── Functions ├── IntenScale.m ├── LinearPattern.m ├── NoiseExtract.m ├── Qfunction.m ├── Saturation.m ├── SeeProgress.m ├── WienerInDFT.m ├── ZeroMean.m ├── ZeroMeanTotal.m ├── crosscorr.m ├── imcropmiddle.m └── rgb2gray1.m ├── NoiseExtractFromImage.m ├── PCE.m ├── PRNUtest.m ├── PRNUtraining.m ├── Validation.m ├── camera_extraction_14_06_2016.log ├── camera_extraction_validation_fb_27_06_2016.log ├── getFingerprint.m ├── main.m ├── ncuts ├── Ncut.m ├── NcutPartition.m ├── NcutPartitionAggregationCoefficient.m ├── aggregationCoefficient.m ├── bipartition.m ├── computeBestThresholdValue.m ├── crossvalidateThreshold.m ├── getDegreeMatrix.m └── normalizedCuts.m ├── rwt-master ├── AUTHORS ├── CMakeLists.txt ├── HACKING ├── INSTALL ├── LICENSE ├── README ├── bin │ ├── HardTh.m │ ├── SoftTh.m │ ├── compile.m │ ├── daubcqf.m │ ├── denoise.m │ ├── makesig.m │ ├── mdwt.m │ ├── mdwt.mexmaci64 │ ├── midwt.m │ ├── midwt.mexmaci64 │ ├── mirdwt.m │ ├── mirdwt.mexmaci64 │ ├── mrdwt.m │ ├── mrdwt.mexmaci64 │ └── setopt.m ├── dist │ ├── 2.01 │ │ ├── INSTALL │ │ ├── README │ │ ├── RWT-2.01.tar.Z │ │ └── doc │ │ │ └── index.html │ ├── 2.3 │ │ ├── INSTALL │ │ ├── INSTALL_PRECOMPILED │ │ ├── LICENSE │ │ ├── README │ │ ├── rwt-lnx.tar.gz │ │ ├── rwt-sol.tar.gz │ │ ├── rwt.tar.gz │ │ ├── rwt.zip │ │ ├── rwt_logo.jpg │ │ ├── rwtwin98.zip │ │ └── rwtwinnt.zip │ └── 2.4 │ │ ├── rwt-linux7.2.tar.gz │ │ ├── rwt-osx.tar.gz │ │ ├── rwt.tar.gz │ │ ├── rwt.zip │ │ ├── rwtwin98.zip │ │ └── rwtwinxp.zip ├── doc │ ├── CMakeLists.txt │ └── Doxyfile.in ├── lib │ ├── inc │ │ ├── rwt_init.h │ │ ├── rwt_platform.h │ │ └── rwt_transforms.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── dwt.c │ │ ├── idwt.c │ │ ├── init.c │ │ ├── irdwt.c │ │ ├── platform.c │ │ └── rdwt.c ├── mex │ ├── mdwt.c │ ├── midwt.c │ ├── mirdwt.c │ └── mrdwt.c ├── python │ ├── CMakeLists.txt │ ├── LICENSE.numpy │ ├── numpy.i │ ├── rwt.i │ └── test_rwt.py └── tests │ ├── lena.bmp │ ├── lena512.mat │ ├── matlab_xunit │ ├── Readme.html │ ├── architecture │ │ ├── class_diagram_a.vsd │ │ ├── class_diagram_b.vsd │ │ ├── class_diagram_c.vsd │ │ ├── html │ │ │ ├── class_diagram_a.gif │ │ │ ├── class_diagram_b.gif │ │ │ ├── class_diagram_c.gif │ │ │ └── matlab_xunit_architecture.html │ │ ├── matlab_xunit_architecture.m │ │ └── testSample.m │ ├── doc │ │ ├── +abc │ │ │ └── +tests │ │ │ │ ├── test_that.m │ │ │ │ └── test_this.m │ │ ├── +abc_tests │ │ │ ├── test_that.m │ │ │ └── test_this.m │ │ ├── exException.m │ │ ├── exQuickStart.m │ │ ├── exRunSpecificTest.m │ │ ├── exRunTestsInADirectory.m │ │ ├── exRunTestsInPackage.m │ │ ├── exSilentRunning.m │ │ ├── exSubfunctionTests.m │ │ ├── exTestCase.m │ │ ├── exTestCaseSearching.m │ │ ├── exTestFixtures.m │ │ ├── exTolerance.m │ │ ├── example_quick_start │ │ │ ├── testFliplrMatrix.m │ │ │ └── testFliplrVector.m │ │ ├── example_subfunction_tests │ │ │ └── testFliplr.m │ │ ├── examples_general │ │ │ ├── TestUsingTestCase.m │ │ │ ├── testBadSinTest.m │ │ │ ├── testCos.m │ │ │ ├── testSetupExample.m │ │ │ ├── testSin.m │ │ │ └── testWithSetupError.m │ │ ├── file_exchange_description.txt │ │ ├── helptoc.xml │ │ ├── html │ │ │ ├── exException.html │ │ │ ├── exQuickStart.html │ │ │ ├── exRunSpecificTest.html │ │ │ ├── exRunTestsInADirectory.html │ │ │ ├── exRunTestsInPackage.html │ │ │ ├── exSilentRunning.html │ │ │ ├── exSubfunctionTests.html │ │ │ ├── exTestCase.html │ │ │ ├── exTestCaseSearching.html │ │ │ ├── exTestFixtures.html │ │ │ ├── exTolerance.html │ │ │ ├── exTolerance_eq28823.png │ │ │ └── exTolerance_eq55725.png │ │ ├── index.html │ │ ├── release-history.html │ │ ├── screen-shot.png │ │ └── xunit_product_page.html │ ├── license.txt │ ├── obsolete │ │ ├── +mtest │ │ │ └── +utils │ │ │ │ ├── Contents.m │ │ │ │ ├── compareFloats.m │ │ │ │ ├── containsRegexp.m │ │ │ │ ├── generateDoc.m │ │ │ │ ├── isAlmostEqual.m │ │ │ │ ├── isSetUpString.m │ │ │ │ ├── isTearDownString.m │ │ │ │ ├── isTestCaseSubclass.m │ │ │ │ ├── isTestString.m │ │ │ │ └── parseFloatAssertInputs.m │ │ ├── assertAlmostEqual.m │ │ ├── mtest.m │ │ └── tests │ │ │ ├── MtestTest.m │ │ │ ├── cwd_test │ │ │ ├── TestCaseSubclass.m │ │ │ ├── testFoobar.m │ │ │ └── testSubfunctions.m │ │ │ ├── testAssertAlmostEqual.m │ │ │ └── testIsAlmostEqual.m │ ├── tests │ │ ├── +xunit │ │ │ └── +mocktests │ │ │ │ ├── +subpkg │ │ │ │ └── test_a_bit.m │ │ │ │ ├── A.m │ │ │ │ ├── B.m │ │ │ │ ├── FooTest.m │ │ │ │ ├── helper_that.m │ │ │ │ ├── test_that.m │ │ │ │ └── test_this.m │ │ ├── Readme.m │ │ ├── RuntestsTest.m │ │ ├── TestCaseTest.m │ │ ├── TestCaseWithAddPathTest.m │ │ ├── TestFuncHandleTests.m │ │ ├── TestRunLoggerTest.m │ │ ├── TestSuiteTest.m │ │ ├── ThrowsExceptionTest.m │ │ ├── almost_black.tif │ │ ├── black.png │ │ ├── black.tif │ │ ├── cwd_test │ │ │ ├── TestCaseSubclass.m │ │ │ ├── testFoobar.m │ │ │ └── testSubfunctions.m │ │ ├── dir1 │ │ │ └── test_thatPasses.m │ │ ├── dir2 │ │ │ └── test_thatFails.m │ │ ├── empty_file │ │ ├── helper_classes │ │ │ ├── BadFixture.m │ │ │ ├── Contents.m │ │ │ ├── ExceptionNotThrownTest.m │ │ │ ├── FailingTestCase.m │ │ │ ├── LoggingTestCase.m │ │ │ ├── NoTestMethods.m │ │ │ ├── PassingExceptionTest.m │ │ │ ├── TestsToBeDiscovered.m │ │ │ ├── TwoPassingTests.m │ │ │ ├── WrongExceptionThrownTest.m │ │ │ ├── notTestString.m │ │ │ ├── testFunctionHandlesA.m │ │ │ ├── testFunctionHandlesB.m │ │ │ ├── testFunctionHandlesC.m │ │ │ ├── testFunctionHandlesD.m │ │ │ ├── testFunctionHandlesE.m │ │ │ ├── testFunctionHandlesTeardownNoSetup.m │ │ │ └── testSimple.m │ │ ├── testAssertEqual.m │ │ ├── testAssertExceptionThrown.m │ │ ├── testAssertFalse.m │ │ ├── testAssertTrue.m │ │ ├── testContainsRegexp.m │ │ ├── testIsSetUpString.m │ │ ├── testIsTearDownString.m │ │ ├── testIsTestCaseSubclass.m │ │ ├── testIsTestString.m │ │ ├── testRuntestsWithDirectoryName.m │ │ ├── test_TestSuiteInDir.m │ │ ├── test_arrayToString.m │ │ ├── test_assertElementsAlmostEqual.m │ │ ├── test_assertFilesEqual.m │ │ ├── test_assertVectorsAlmostEqual.m │ │ ├── test_compareFloats.m │ │ ├── test_comparisonMessage.m │ │ ├── test_packageName.m │ │ ├── test_parseFloatAssertInputs.m │ │ └── test_stringToCellArray.m │ └── xunit │ │ ├── +xunit │ │ └── +utils │ │ │ ├── Contents.m │ │ │ ├── arrayToString.m │ │ │ ├── compareFloats.m │ │ │ ├── comparisonMessage.m │ │ │ ├── containsRegexp.m │ │ │ ├── generateDoc.m │ │ │ ├── isAlmostEqual.m │ │ │ ├── isSetUpString.m │ │ │ ├── isTearDownString.m │ │ │ ├── isTestCaseSubclass.m │ │ │ ├── isTestString.m │ │ │ ├── parseFloatAssertInputs.m │ │ │ └── stringToCellArray.m │ │ ├── CommandWindowTestRunDisplay.m │ │ ├── Contents.m │ │ ├── FunctionHandleTestCase.m │ │ ├── TestCase.m │ │ ├── TestCaseInDir.m │ │ ├── TestCaseWithAddPath.m │ │ ├── TestComponent.m │ │ ├── TestComponentInDir.m │ │ ├── TestRunDisplay.m │ │ ├── TestRunLogger.m │ │ ├── TestRunMonitor.m │ │ ├── TestSuite.m │ │ ├── TestSuiteInDir.m │ │ ├── VerboseTestRunDisplay.m │ │ ├── assertElementsAlmostEqual.m │ │ ├── assertEqual.m │ │ ├── assertExceptionThrown.m │ │ ├── assertFalse.m │ │ ├── assertFilesEqual.m │ │ ├── assertTrue.m │ │ ├── assertVectorsAlmostEqual.m │ │ ├── info.xml │ │ ├── initTestSuite.m │ │ └── runtests.m │ ├── octave │ ├── assertEqual.m │ ├── assertVectorsAlmostEqual.m │ ├── runtests.m │ ├── test_denoise.m │ ├── test_makesig.m │ ├── test_mdwt.m │ ├── test_midwt.m │ ├── test_mirdwt.m │ ├── test_mrdwt.m │ └── test_setopt.m │ ├── runtests.m │ ├── test_daubcqf.m │ ├── test_denoise.m │ ├── test_makesig.m │ ├── test_mdwt.m │ ├── test_midwt.m │ ├── test_mirdwt.m │ ├── test_mrdwt.m │ └── test_setopt.m ├── temp ├── temp_FAR.m ├── temp_FAfromPCE.m ├── temp_astroprnu.m └── temp_test.m └── utils ├── PCEdistance.m ├── detectOrientation.m ├── double2range.m ├── evaluateClusterFingerprint.m ├── getImagesPath.m ├── plotConfusionMatrix.m ├── remap.m ├── storeEvaluatedClusters.m └── validateClusterResults.m /.gitignore: -------------------------------------------------------------------------------- 1 | mat/* 2 | matlab/mat/* 3 | matlab/Images/* 4 | dataset/* 5 | *.m~ 6 | .gitignore~ 7 | matlab/rwt-master/bin/* 8 | dataset 9 | 10 | matlab/mat/images_noises.mat 11 | 12 | matlab/mat/images_weights.mat 13 | 14 | matlab/clusters.txt 15 | 16 | docs/*.aux 17 | 18 | docs/*.log 19 | 20 | docs/*.pdf 21 | 22 | docs/*.synctex.gz 23 | 24 | articles/04451084.pdf 25 | 26 | articles/10.1.1.353.1482.pdf 27 | 28 | docs/article.bbl 29 | 30 | docs/article.blg 31 | 32 | docs/slides/slides.synctex.gz 33 | 34 | docs/slides/slides.aux 35 | 36 | docs/slides/slides.nav 37 | 38 | docs/slides/slides.nav 39 | 40 | docs/slides/slides.log 41 | 42 | docs/slides/slides.aux 43 | 44 | docs/slides/slides.pdf 45 | 46 | docs/slides/slides.snm 47 | 48 | docs/slides/slides.synctex.gz 49 | 50 | docs/slides/slides.toc 51 | 52 | docs/slides/metodo.log 53 | 54 | docs/slides/slides.toc 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Camera Identification 2 | 3 | Source Camera Identification system in Matlab. Based on http://dde.binghamton.edu/download/camera_fingerprint/ implementation. 4 | 5 | For further details, read the comments inside the main script. 6 | -------------------------------------------------------------------------------- /articles/09-d-normalized-cuts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/articles/09-d-normalized-cuts.pdf -------------------------------------------------------------------------------- /articles/2014_blind_image.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/articles/2014_blind_image.pdf -------------------------------------------------------------------------------- /articles/SM-ncut.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/articles/SM-ncut.pdf -------------------------------------------------------------------------------- /docs/abstract.tex: -------------------------------------------------------------------------------- 1 | \begin{abstract} 2 | 3 | L'obiettivo di questo elaborato è di implementare un sistema di identificazione di camera (Source Camera Identification, SCI) basato sul clustering di immagini in gruppi eterogenei, utilizzando come distanza la PCE, peaks-to-correlation energy ratio, tra i PRNU delle immagini. L'algoritmo di clustering implementato è Normalized Cuts. 4 | Una volta creati i gruppi di immagini, per ciascuno di essi verrà estratta la PRNU di camera e sarà dunque possibile comparare una nuova immagine per stabilire a quale camera appartiene. 5 | Per validare il metodo implementato sono proposti diversi risultati sperimentali basati su dataset differenti. 6 | Ulteriore analisi è stata effettuata utilizzando immagini caricate sui social network, in particolare con immagini provenienti da Facebook. 7 | \end{abstract} 8 | 9 | -------------------------------------------------------------------------------- /docs/article.tex: -------------------------------------------------------------------------------- 1 | \documentclass[10pt,twocolumn,letterpaper]{article} 2 | \usepackage[italian]{babel} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage{cvpr} 5 | \usepackage{times} 6 | \usepackage{epsfig} 7 | \usepackage{graphicx} 8 | \usepackage{amsmath} 9 | \usepackage{amssymb} 10 | \usepackage{url} 11 | 12 | % Include other packages here, before hyperref. 13 | 14 | % If you comment hyperref and then uncomment it, you should delete 15 | % egpaper.aux before re-running latex. (Or just hit 'q' on the first latex 16 | % run, let it finish, and you should be clear). 17 | %\usepackage[pagebackref=true,breaklinks=true,letterpaper=true,colorlinks,bookmarks=false]{hyperref} 18 | 19 | \cvprfinalcopy % *** Uncomment this line for the final submission 20 | 21 | \def\cvprPaperID{****} % *** Enter the CVPR Paper ID here 22 | \def\httilde{\mbox{\tt\raisebox{-.5ex}{\symbol{126}}}} 23 | 24 | % Pages are numbered in submission mode, and unnumbered in camera-ready 25 | \ifcvprfinal\pagestyle{empty}\fi 26 | \begin{document} 27 | 28 | %%%%%%%%% TITLE 29 | \title{Clustering di immagini basato su Normalized Cuts per l'identificazione di camera} 30 | 31 | \author{Lorenzo Cioni\\ 32 | {\tt\small lore.cioni@gmail.com} 33 | % For a paper whose authors are all at the same institution, 34 | % omit the following lines up until the closing ``}''. 35 | % Additional authors and addresses can be added with ``\and'', 36 | % just like the second author. 37 | % To save space, use either the email address or home page, not both 38 | \and 39 | Saverio Meucci\\ 40 | {\tt\small s.meucci91@gmail.com} 41 | } 42 | 43 | \maketitle 44 | \thispagestyle{empty} 45 | 46 | %%%%%%%%% ABSTRACT 47 | \input{abstract} 48 | 49 | %------------------------------------------------------------------------- 50 | \input{introduction} 51 | \input{prnu} 52 | \input{clustering} 53 | \input{fingerprint} 54 | \input{validation} 55 | \input{results} 56 | \input{conclusions} 57 | 58 | %------------------------------------------------------------------------- 59 | 60 | {\small 61 | \bibliographystyle{ieee} 62 | \bibliography{egbib} 63 | } 64 | 65 | \end{document} 66 | -------------------------------------------------------------------------------- /docs/fingerprint.tex: -------------------------------------------------------------------------------- 1 | \section{Estrazione delle \emph{fingerprints}} 2 | 3 | Al fine di generare il \emph{reference pattern}, il rumore caratteristico di una sorgente, è necessario disporre di una serie di immagini provenienti dalla stessa camera; per ottenere buoni risultati è consigliato utilizzare dalle 20 alle 50 immagini. 4 | 5 | Le immagini utilizzate sono dunque processate per la rimozione del rumore, \emph{denoising}. Per questa operazione è possibile utilizzare una qualsiasi tecnica presente in letteratura. Nell'implementazione utilizzata viene usato il filtro di \emph{Daubechies}\cite{Daubechies:1992:TLW:130655}, un filtro a fase minima che genera \emph{wavelets} che hanno supporto minimo. 6 | 7 | Il PRNU stimato è trovato tramite la media dei residui di rumore delle immagini. 8 | 9 | \begin{figure}[h] 10 | \begin{center} 11 | \includegraphics[width=0.45\textwidth]{images/prnu_extraction.jpg} 12 | \end{center} 13 | \caption{La fase di estrazione del \emph{reference pattern} di una sorgente\cite{figprnu}} 14 | \label{fig:extraction} 15 | \end{figure} 16 | 17 | L'implementazione delle funzioni per l'estrazione del PRNU da una singola immagine e per l'estrazione della \emph{fingerprint} da un'insieme di immagini è presa da \cite{goljan2016effect}\footnote{\emph{Effect of Compression on Sensor-Fingerprint Based Camera Identification}}. -------------------------------------------------------------------------------- /docs/images/confusion_matrix_fb_highres_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusion_matrix_fb_highres_4.png -------------------------------------------------------------------------------- /docs/images/confusion_matrix_fb_highres_4_bis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusion_matrix_fb_highres_4_bis.png -------------------------------------------------------------------------------- /docs/images/confusion_matrix_fb_highres_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusion_matrix_fb_highres_5.png -------------------------------------------------------------------------------- /docs/images/confusion_matrix_fb_highres_5_bis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusion_matrix_fb_highres_5_bis.png -------------------------------------------------------------------------------- /docs/images/confusion_matrix_fb_highres_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusion_matrix_fb_highres_6.png -------------------------------------------------------------------------------- /docs/images/confusion_matrix_fb_highres_6_bis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusion_matrix_fb_highres_6_bis.png -------------------------------------------------------------------------------- /docs/images/confusionmatrix_fb_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusionmatrix_fb_4.png -------------------------------------------------------------------------------- /docs/images/confusionmatrix_fb_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusionmatrix_fb_5.png -------------------------------------------------------------------------------- /docs/images/confusionmatrix_fb_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusionmatrix_fb_6.png -------------------------------------------------------------------------------- /docs/images/confusionmatrix_nat_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusionmatrix_nat_4.png -------------------------------------------------------------------------------- /docs/images/confusionmatrix_nat_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusionmatrix_nat_5.png -------------------------------------------------------------------------------- /docs/images/confusionmatrix_nat_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/confusionmatrix_nat_6.png -------------------------------------------------------------------------------- /docs/images/prnu_extraction.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/prnu_extraction.jpg -------------------------------------------------------------------------------- /docs/images/prnu_extraction_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/prnu_extraction_2.jpg -------------------------------------------------------------------------------- /docs/images/soglia_imgnat_AC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/soglia_imgnat_AC.png -------------------------------------------------------------------------------- /docs/images/soglia_imgnat_NC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/soglia_imgnat_NC.png -------------------------------------------------------------------------------- /docs/images/soglia_imgnat_fb_AC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/soglia_imgnat_fb_AC.png -------------------------------------------------------------------------------- /docs/images/soglia_imgnat_fb_NC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/soglia_imgnat_fb_NC.png -------------------------------------------------------------------------------- /docs/images/validation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/validation.jpg -------------------------------------------------------------------------------- /docs/images/validation_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/images/validation_2.jpg -------------------------------------------------------------------------------- /docs/slides/beamerfontthemetorinoth.sty: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % 3 | % Copyright 2011-2012 by Fiandrino Claudio 4 | % 5 | % This file may be distributed and/or modified 6 | % 7 | % 1. under the LaTeX Project Public License and/or 8 | % 2. under the GNU Public License. 9 | % 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | 12 | \mode 13 | 14 | % Fonts 15 | \setbeamerfont{title}{size=\Large} 16 | \setbeamerfont{ateneo}{size=\large,shape=\scshape} 17 | \setbeamerfont{person}{size=\footnotesize} 18 | \setbeamerfont{definition}{size=\normalsize,shape=\itshape} 19 | \setbeamerfont{frame number}{series=\bfseries} 20 | \setbeamerfont{footnote}{size=\tiny,family=\sffamily,series=\bfseries} 21 | \setbeamerfont{date}{family=\sffamily,size=\small} 22 | 23 | \mode 24 | 25 | -------------------------------------------------------------------------------- /docs/slides/conclusions.tex: -------------------------------------------------------------------------------- 1 | \begin{tframe}{Conclusioni} 2 | 3 | Il metodo per l'identificazione automatica di dispositivi implementato utilizza la PRNU per descrivere le immagini e la PCE come misura di similarità fra PRNU. L'algoritmo Normalized Cuts partiziona le immagini in clusters. Tali clusters rappresentano gruppi di immagini simili a partire dalle quali le fingerprints di camera verranno calcolate. 4 | 5 | \vspace{0.1in} 6 | 7 | La fase di validazione ha permesso di trarre alcune conclusioni: 8 | \begin{itemize} 9 | \item Per quanto riguarda le immagini naturali, i risultati ottenuti sono ottimi. Infatti il metodo è perfettamente in grado di associare una generica immagine alla fingerprint di camera corretta. 10 | \item Il caso delle immagini scaricate da Facebook presenta risultati altalenanti. La compressione subita dalle immagini incide negativamente sull'accuratezza della predizione, a causa di una minore qualità delle PRNU estratte che si riflette sulla PCE. 11 | \end{itemize} 12 | 13 | \end{tframe} -------------------------------------------------------------------------------- /docs/slides/firenze.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/slides/firenze.jpg -------------------------------------------------------------------------------- /docs/slides/intro.tex: -------------------------------------------------------------------------------- 1 | %-- Introduzione --% 2 | 3 | \begin{tframe}{Introduzione} 4 | 5 | \vspace{0.5cm} 6 | 7 | \textbf{Obiettivo}: implementare un sistema di identificazione di camera (\emph{Source Camera Identification, SCI}) basato sul clustering di immagini in gruppi eterogenei, utilizzando come distanza la PCE, peaks-to-correlation energy ratio, tra i PRNU delle immagini. 8 | 9 | \vspace{1cm} 10 | Analisi dell'efficacia del metodo su immagini caricate e scaricate da \textbf{Facebook} 11 | 12 | \end{tframe} -------------------------------------------------------------------------------- /docs/slides/references.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/slides/references.log -------------------------------------------------------------------------------- /docs/slides/references.tex: -------------------------------------------------------------------------------- 1 | \begin{tframe}{Riferimenti bibliografici} 2 | 3 | [1] I. Amerini, R. Caldelli, P. Crescenzi, A. D. Mastio, and A. Marino. Blind image clustering based on the normalized cuts criterion for camera identification. Signal Processing: Image Communication, 29(8):831 – 843, 2014. 4 | 5 | \vspace{0.1in} 6 | 7 | [2] I. Daubechies. Ten Lectures on Wavelets. Society for Industrial and Applied Mathematics, Philadelphia, PA, USA, 1992. 8 | 9 | \vspace{0.1in} 10 | 11 | [3] M. Goljan, M. Chen, P. Comesana, and J. Fridrich. Effect of compression on sensor-fingerprint based camera identification. Electronic Imaging, 2016(8):1–10, 2016. 12 | 13 | \vspace{0.1in} 14 | 15 | [4] H. Muammar. Source camera identification using image sensor prnu pattern. Department of Electrical and Electronic Engineering, Imperial College, London. 16 | 17 | \end{tframe} -------------------------------------------------------------------------------- /docs/slides/results.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/slides/results.log -------------------------------------------------------------------------------- /docs/slides/slides.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/slides/slides.dvi -------------------------------------------------------------------------------- /docs/slides/slides.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/docs/slides/slides.out -------------------------------------------------------------------------------- /docs/slides/slides.tex: -------------------------------------------------------------------------------- 1 | \documentclass{beamer} 2 | \usepackage{graphicx} 3 | \usepackage{xcolor} 4 | \usepackage{mathtools} 5 | \usetheme[titlepagelogo=firenze,% Logo for the first page 6 | language=italian, 7 | bullet=circle, 8 | color=blue, 9 | ]{TorinoTh} 10 | \usepackage[beamer,customcolors]{hf-tikz} 11 | \definecolor{UniBlue}{RGB}{83,121,170} 12 | \uselanguage{italian} 13 | \languagepath{italian} 14 | \setbeamercolor{block title}{use=structure,fg=white,bg=UniBlue} 15 | \setbeamercolor{block body}{use=structure,fg=black,bg=white} 16 | 17 | \author{} 18 | \rel{{\normalsize \emph{Elaborazione e Protezione delle Immagini}}\\\vspace{0.3cm}Lorenzo Cioni e Saverio Meucci} 19 | \title{\huge Clustering di immagini basato su Normalized Cuts per l’identificazione di camera} 20 | \date{7 Luglio 2016} 21 | 22 | \begin{document} 23 | 24 | \titlepageframe 25 | 26 | \input{intro} 27 | \input{metodo} 28 | \input{validation} 29 | \input{results} 30 | \input{conclusions} 31 | \input{references} 32 | 33 | \end{document} -------------------------------------------------------------------------------- /docs/slides/slides.vrb: -------------------------------------------------------------------------------- 1 | \frametitle {Block: codice (II)}Più in generale, Beamer offre la possibilità di utilizzare tre ambienti \emph{block}: 2 | \begin{itemize} 3 | \item \highlight{block} 4 | \item \highlight{alertblock} 5 | \item \highlight{exampleblock} 6 | \end{itemize} 7 | Per avere più dettagli, e non solo su questo argomento, suggerisco di leggere la \href{http://mirrors.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf}{beameruserguide}. 8 | -------------------------------------------------------------------------------- /docs/slides/texput.log: -------------------------------------------------------------------------------- 1 | This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013) (format=pdflatex 2014.4.22) 10 NOV 2014 18:39 2 | entering extended mode 3 | restricted \write18 enabled. 4 | %&-line parsing enabled. 5 | **beamerinnerthemetorinoth.tex 6 | 7 | ! Emergency stop. 8 | <*> beamerinnerthemetorinoth.tex 9 | 10 | *** (job aborted, file error in nonstop mode) 11 | 12 | 13 | Here is how much of TeX's memory you used: 14 | 3 strings out of 493315 15 | 118 string characters out of 6137904 16 | 52158 words of memory out of 5000000 17 | 3557 multiletter control sequences out of 15000+600000 18 | 3640 words of font info for 14 fonts, out of 8000000 for 9000 19 | 957 hyphenation exceptions out of 8191 20 | 0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,80000s 21 | ! ==> Fatal error occurred, no output PDF file produced! 22 | -------------------------------------------------------------------------------- /docs/slides/validation.tex: -------------------------------------------------------------------------------- 1 | \begin{tframe}{Validazione} 2 | 3 | Data una generica immagine $I$ ed un insieme $F_1, \ldots, F_m$ di \emph{fingerprints}, l'obiettivo è di stabilire da quale sorgente è stata scattata. 4 | 5 | \begin{figure}[h] 6 | \begin{center} 7 | \includegraphics[width=0.8\textwidth]{../images/validation_2} 8 | \end{center} 9 | \caption{Validazione delle immagini} 10 | \label{fig:validation} 11 | \end{figure} 12 | \end{tframe} -------------------------------------------------------------------------------- /docs/validation.tex: -------------------------------------------------------------------------------- 1 | \section{Validazione} 2 | 3 | Il problema principale della SCI consiste, data una generica immagine $I$ ed un insieme $R_1, \ldots, R_m$ di \emph{reference patterns}, nello stabilire da quale sorgente è stata scattata. 4 | 5 | Per ciascuna immagine in ingresso viene dunque estratta la PRNU stimata e comparata con le \emph{fingerprints} ottenute mediante le operazioni di clustering. Il confronto viene effettuato mediante il calcolo della PCE. Il valore della PCE ottenuto ci fornisce una stima della confidenza della relazione tra \emph{fingerprint} e PRNU dell'immagine di partenza, consentendo di scegliere la camera con la confidenza più alta. 6 | 7 | \begin{figure}[h] 8 | \begin{center} 9 | \includegraphics[width=0.45\textwidth]{images/validation.jpg} 10 | \end{center} 11 | \caption{La fase di validazione di una immagine campione} 12 | \label{fig:validation} 13 | \end{figure} 14 | 15 | L'operazione sopra descritta viene ripetuta su un'insieme di immagini prese dal dataset di riferimento così da poter valutare le performance del sistema implementato semplicemente andando a comparare la predizione ottenuta per ciascuna immagine con il \emph{ground-truth} posseduto. -------------------------------------------------------------------------------- /matlab/CameraValidation.m: -------------------------------------------------------------------------------- 1 | function [camera, affinity] = CameraValidation(image, outputPath) 2 | %CAMERAVALIDATION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | addpath('utils'); 6 | addpath('Functions'); 7 | addpath('Filter'); 8 | addpath('rwt-master/bin'); 9 | 10 | fprintf(' -Image %s\n', image); 11 | 12 | camera_folder = dir(['mat/' outputPath 'cameras/']); 13 | n_cameras = length(camera_folder) - 2; 14 | 15 | pce = zeros(length(n_cameras), 1); 16 | cameras = cell(length(n_cameras), 1); 17 | 18 | I = double(rgb2gray(imread(image))); 19 | %Resize image if different size from fingerprint 20 | 21 | 22 | PRNU = NoiseExtractFromImage(image, 2); 23 | PRNU = WienerInDFT(PRNU, std2(PRNU)); 24 | 25 | for i = 1:n_cameras 26 | load(['mat/' outputPath 'cameras/camera_' num2str(i) '.mat'], 'camera'); 27 | height = size(camera.fingerprint, 1); 28 | width = size(camera.fingerprint, 2); 29 | 30 | tmpImg = I; 31 | tmpPRNU = PRNU; 32 | 33 | if(size(I, 1) ~= height || size(I, 2) ~= width) 34 | tmpImg = imresize(I, [height width]); 35 | end 36 | 37 | %Resize prnu if different size from fingerprint 38 | if(size(PRNU, 1) ~= height || size(PRNU, 2) ~= width) 39 | tmpPRNU = imresize(PRNU, [height width]); 40 | end 41 | 42 | C = crosscorr(tmpPRNU, tmpImg .* camera.fingerprint); 43 | detection = PCE(C); 44 | pce(i) = detection.PCE; 45 | cameras{i}.pce = pce(i); 46 | cameras{i}.folder = camera.folder; 47 | fprintf(' -Compared with camera: %d\n', i); 48 | end 49 | 50 | cameras = cell2mat(cameras); 51 | [affinity, index] = max(pce); 52 | camera = cameras(index).folder; 53 | 54 | fprintf(' -Choosen cluster: %s\n', camera); 55 | end 56 | 57 | -------------------------------------------------------------------------------- /matlab/Example.m: -------------------------------------------------------------------------------- 1 | % Example 2 | 3 | addpath('utils'); 4 | addpath('Functions'); 5 | addpath('Filter'); 6 | addpath('rwt-master/bin'); 7 | addpath('ncuts'); 8 | 9 | fprintf('CameraIdentification main script\n\n'); 10 | 11 | imgpath = '../dataset/images/'; %dataset path 12 | validationPath = '../dataset/validation'; %validation path 13 | 14 | sourcePath = 'source/'; %where prnu data are stored (inside mat folder) 15 | outputPath = 'output/'; %where reference pattern are store (inside mat folder) 16 | 17 | numFolders = 3; %number of folders 18 | numImages = 3; %number of images from each folder 19 | imgtype = 'imgs_nat'; 20 | 21 | 22 | %% Reference patterns extraction %% 23 | 24 | % Script for extracting and saving camera reference patters 25 | 26 | % 1) Extracts images PRNU and store them in source path directory 27 | % 2) Resizes PRNU to the same dimensions (for further processing) 28 | % 3) Computes weights matrix with PCE distances between each PRNU 29 | % 4) Clustering of images wrt weight matrix usign normalized cuts 30 | % 5) Reference pattern for each camera evaluation 31 | % 6) Store reference patterns in output path, cameras subfolder 32 | 33 | %If called with ExtractNoise set to false, PRNU and weight matrix are not 34 | %exracted and proceed to the reference patterns generation using weight 35 | %matrix found in source path 36 | 37 | 38 | CameraIdentification(imgpath, imgtype, 'NumFolders', numFolders, 'NumImages', ... 39 | numImages, 'ExtractNoise', true, 'SourcePath', ... 40 | sourcePath, 'OutputPath', outputPath, 'Threshold', 4*10^-5); 41 | 42 | 43 | %% Validation %% 44 | % Predict and evaluate results for prediction on a validation set 45 | 46 | % 1) Calls CameraValidation for each images in validation path (given num 47 | % folders and number of images from each folder) 48 | % 2) Plot confusion matrix of the results 49 | 50 | Validation(validationPath, imgtype, 'NumFolders', numFolders, ... 51 | 'NumImages', 2, 'OutputPath', outputPath); 52 | 53 | -------------------------------------------------------------------------------- /matlab/Filter/Makefile: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | MEXT=mexa64 3 | MATLABPATH=/matlab/r2006a 4 | MATLABLIBDIR=glnxa64 5 | #-------------------------------------------------------------------- 6 | COMPILEFLAGS=-fPIC -fno-omit-frame-pointer -ansi -D_GNU_SOURCE 7 | OPTIMFLAGS=-O3 -DNDEBUG 8 | DEBUGFLAGS=-g -DDEBUG 9 | #-------------------------------------------------------------------- 10 | LINKFLAGS=-pthread -shared -Wl,--version-script,$(MATLABPATH)/extern/lib/$(MATLABLIBDIR)/mexFunction.map -Wl,-rpath-link,$(MATLABPATH)/bin/$(MATLABLIBDIR) 11 | LIBDIRS=-L$(MATLABPATH)/bin/$(MATLABLIBDIR) 12 | LIBS=-lmx -lmex -lmat -lm 13 | INCLUDE=-I$(MATLABPATH)/extern/include 14 | #-------------------------------------------------------------------- 15 | all: 16 | clear 17 | icpc $(COMPILEFLAGS) $(LINKFLAGS) $(OPTIMFLAGS) $(LIBDIRS) $(LIBS) $(INCLUDE) -DMATLAB_MEX_FILE -o mdwt.$(MEXT) mdwt.cpp mdwt_r.cpp 18 | icpc $(COMPILEFLAGS) $(LINKFLAGS) $(OPTIMFLAGS) $(LIBDIRS) $(LIBS) $(INCLUDE) -DMATLAB_MEX_FILE -o midwt.$(MEXT) midwt.cpp midwt_r.cpp 19 | icpc $(COMPILEFLAGS) $(LINKFLAGS) $(OPTIMFLAGS) $(LIBDIRS) $(LIBS) $(INCLUDE) -DMATLAB_MEX_FILE -o mrdwt.$(MEXT) mrdwt.cpp mrdwt_r.cpp 20 | icpc $(COMPILEFLAGS) $(LINKFLAGS) $(OPTIMFLAGS) $(LIBDIRS) $(LIBS) $(INCLUDE) -DMATLAB_MEX_FILE -o mirdwt.$(MEXT) mirdwt.cpp mirdwt_r.cpp 21 | 22 | clean: 23 | -------------------------------------------------------------------------------- /matlab/Filter/Threshold.m: -------------------------------------------------------------------------------- 1 | function x = Threshold(y,t) 2 | % Threshold -- Apply max(0,y-t) 3 | 4 | res = (y - t); 5 | x = (res + abs(res))/2; 6 | 7 | 8 | -------------------------------------------------------------------------------- /matlab/Filter/WaveFilter.m: -------------------------------------------------------------------------------- 1 | function [tc, coefVar]=WaveFilter(coef,NoiseVar); 2 | % Model each detail wavelet coefficient as conditional Gaussian random 3 | % variable and use several two-dimensional moving window to estimate the 4 | % variance of each wavelet coefficient in conjunction with a Wiener-type 5 | % denoising filter 6 | %Input: 7 | % coef: Wavelet detailed coefficient at certain level 8 | % NoiseVar: Variance of the additive noise 9 | %Output: 10 | % tc: Attenuated wavelet coefficient 11 | % coefVar: Finall estimated variances of each coefficient 12 | 13 | % Estimate the variance of original noise-free image for each wavelet 14 | % coefficients using the MAP estimation for 4 sizes of square NxN 15 | % neighborhood for N=[3,5,7,9] 16 | tc = coef.^2; 17 | coefVar = Threshold(filter2(ones(3,3)/(3*3), tc), NoiseVar); 18 | 19 | for w = 5:2:9 20 | EstVar = Threshold(filter2(ones(w,w)/(w*w), tc), NoiseVar); 21 | coefVar = min(coefVar, EstVar); 22 | end 23 | 24 | % Wiener filter like attenuation 25 | tc = coef.*coefVar./(coefVar+NoiseVar); 26 | 27 | 28 | -------------------------------------------------------------------------------- /matlab/Filter/WaveNoise.asv: -------------------------------------------------------------------------------- 1 | function [tc, coefVar]=WaveNoise(coef,NoiseVar); 2 | % Model each detail wavelet coefficient as conditional Gaussian random 3 | % variable and use several two-dimensional moving windows to estimate the 4 | % variance of each wavelet coefficient in conjunction with a Wiener-type 5 | % denoising filter 6 | %Input: 7 | % coef: Wavelet detailed coefficient at certain level 8 | % NoiseVar: Variance of the additive noise 9 | %Output: 10 | % tc: Extracted noise coefficient 11 | 12 | % Estimate the variance of original noise-free image for each wavelet 13 | % coefficients using the MAP estimation for 4 sizes of square NxN 14 | % neighborhood for N=[3,5,7,9] 15 | 16 | tc = coef.^2; 17 | coefVar = Threshold(filter2(ones(3,3)/(3*3), tc), NoiseVar); 18 | 19 | for w = 5:2:9 20 | EstVar = Threshold(filter2(ones(w,w)/(w*w), tc), NoiseVar); 21 | coefVar = min(coefVar, EstVar); 22 | end 23 | 24 | % Wiener filter like attenuation 25 | tc = coef.*NoiseVar./(coefVar+NoiseVar); 26 | -------------------------------------------------------------------------------- /matlab/Filter/WaveNoise.m: -------------------------------------------------------------------------------- 1 | function [tc, coefVar]=WaveNoise(coef,NoiseVar); 2 | % Model each detail wavelet coefficient as conditional Gaussian random 3 | % variable and use several two-dimensional moving windows to estimate the 4 | % variance of each wavelet coefficient in conjunction with a Wiener-type 5 | % denoising filter 6 | %Input: 7 | % coef: Wavelet detailed coefficient at certain level 8 | % NoiseVar: Variance of the additive noise 9 | %Output: 10 | % tc: Extracted noise coefficient 11 | 12 | % Estimate the variance of original noise-free image for each wavelet 13 | % coefficients using the MAP estimation for 4 sizes of square NxN 14 | % neighborhood for N=[3,5,7,9] 15 | 16 | tc = coef.^2; 17 | coefVar = Threshold(filter2(ones(3,3)/(3*3), tc), NoiseVar); 18 | 19 | for w = 5:2:9 20 | EstVar = Threshold(filter2(ones(w,w)/(w*w), tc), NoiseVar); 21 | coefVar = min(coefVar, EstVar); 22 | end 23 | 24 | % Wiener filter like attenuation 25 | tc = coef.*NoiseVar./(coefVar+NoiseVar); 26 | -------------------------------------------------------------------------------- /matlab/Filter/mdwt.c: -------------------------------------------------------------------------------- 1 | /*! \file mdwt.c 2 | \brief MATLAB gateway for the discrete wavelet transform 3 | 4 | This file is used to produce a MATLAB MEX binary for the discrete wavelet transform 5 | 6 | %y = mdwt(x,h,L); 7 | % 8 | % function computes the discrete wavelet transform y for a 1D or 2D input 9 | % signal x. 10 | % 11 | % Input: 12 | % x : finite length 1D or 2D signal (implicitely periodized) 13 | % h : scaling filter 14 | % L : number of levels. in case of a 1D signal length(x) must be 15 | % divisible by 2^L; in case of a 2D signal the row and the 16 | % column dimension must be divisible by 2^L. 17 | % 18 | % see also: midwt, mrdwt, mirdwt 19 | */ 20 | 21 | #include "mex.h" 22 | #include "rwt_init.h" 23 | #include "rwt_transforms.h" 24 | 25 | /*! 26 | * Matlab MEX definition for the discrete wavelet transform. 27 | * 28 | * @param nlhs number of items on left hand side of matlab call 29 | * @param plhs pointer to left hand side data structure 30 | * @param nrhs number of items on right hand side of matlab call 31 | * @param prhs pointer to right hand side data structure 32 | * 33 | */ 34 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 35 | rwt_init_params params = rwt_matlab_init(nlhs, plhs, nrhs, prhs, NORMAL_DWT); /*! Check input and determine the parameters for dwt() */ 36 | plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL); /*! Create the output matrix */ 37 | *mxGetPr(plhs[1]) = params.levels; /*! The second returned item is the number of levels */ 38 | dwt(mxGetPr(prhs[0]), params.nrows, params.ncols, params.scalings, params.ncoeff, params.levels, mxGetPr(plhs[0])); /*! Perform the DWT */ 39 | } 40 | 41 | -------------------------------------------------------------------------------- /matlab/Filter/mdwt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/Filter/mdwt.dll -------------------------------------------------------------------------------- /matlab/Filter/mdwt_r.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void MDWT(double *x, int m, int n, double *h, int lh, int L, double *y); 5 | void fpsconv(double *x_in, int lx, double *h0, double *h1, int lhm1, double *x_outl, double *x_outh); 6 | -------------------------------------------------------------------------------- /matlab/Filter/midwt.c: -------------------------------------------------------------------------------- 1 | /*! \file midwt.c 2 | \brief MATLAB gateway for the inverse discrete wavelet transform 3 | 4 | This file is used to produce a MATLAB MEX binary for the inverse discrete wavelet transform 5 | 6 | %y = midwt(x,h,L); 7 | % 8 | % function computes the inverse discrete wavelet transform y for a 1D or 2D 9 | % input signal x. 10 | % 11 | % Input: 12 | % x : finite length 1D or 2D input signal (implicitely periodized) 13 | % h : scaling filter 14 | % L : number of levels. in case of a 1D signal length(x) must be 15 | % divisible by 2^L; in case of a 2D signal the row and the 16 | % column dimension must be divisible by 2^L. 17 | % 18 | % see also: mdwt, mrdwt, mirdwt 19 | */ 20 | 21 | #include "mex.h" 22 | #include "rwt_init.h" 23 | #include "rwt_transforms.h" 24 | 25 | /*! 26 | * Matlab MEX definition for the inverse discrete wavelet transform. 27 | * 28 | * @param nlhs number of items on left hand side of matlab call 29 | * @param plhs pointer to left hand side data structure 30 | * @param nrhs number of items on right hand side of matlab call 31 | * @param prhs pointer to right hand side data structure 32 | * 33 | */ 34 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 35 | double *x, *y; 36 | rwt_init_params params = rwt_matlab_init(nlhs, plhs, nrhs, prhs, INVERSE_DWT); 37 | y = mxGetPr(prhs[0]); 38 | x = mxGetPr(plhs[0]); 39 | plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL); 40 | *mxGetPr(plhs[1]) = params.levels; 41 | idwt(x, params.nrows, params.ncols, params.scalings, params.ncoeff, params.levels, y); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /matlab/Filter/midwt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/Filter/midwt.dll -------------------------------------------------------------------------------- /matlab/Filter/midwt_r.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void MIDWT(double *x, int m, int n, double *h, int lh, int L, double *y); 5 | void bpsconv(double *x_out, int lx, double *g0, double *g1, int lhm1, int lhhm1, double *x_inl, double *x_inh); 6 | -------------------------------------------------------------------------------- /matlab/Filter/quadlength.m: -------------------------------------------------------------------------------- 1 | function [n,J] = quadlength(x) 2 | % quadlength -- Find length and dyadic length of square matrix 3 | % Usage 4 | % [n,J] = quadlength(x) 5 | % Inputs 6 | % x 2-d image; size(n,n), n = 2^J (hopefully) 7 | % Outputs 8 | % n length(x) 9 | % J least power of two greater than n 10 | % 11 | % Side Effects 12 | % A warning message is issue if n is not a power of 2, 13 | % or if x is not a square matrix. 14 | % 15 | s = size(x); 16 | n = s(1); 17 | if s(2) ~= s(1), 18 | disp('Warning in quadlength: nr != nc') 19 | end 20 | k = 1 ; J = 0; while k < n , k=2*k; J = 1+J ; end ; 21 | if k ~= n , 22 | disp('Warning in quadlength: n != 2^J') 23 | end 24 | 25 | % 26 | % Copyright (c) 1993. David L. Donoho 27 | % 28 | 29 | 30 | % 31 | % Part of WaveLab Version 802 32 | % Built Sunday, October 3, 1999 8:52:27 AM 33 | % This is Copyrighted Material 34 | % For Copying permissions see COPYING.m 35 | % Comments? e-mail wavelab@stat.stanford.edu 36 | % 37 | 38 | -------------------------------------------------------------------------------- /matlab/Functions/IntenScale.m: -------------------------------------------------------------------------------- 1 | function out = IntenScale(in) 2 | % in are pixel intensities 0<=in<=1 3 | % out 0250; 28 | SaturMap(:,:,j) = ~((X(:,:,j)==maxX(j)) & ~SaturMap(:,:,j)); 29 | end 30 | end 31 | elseif size(X,3)==1, 32 | maxX = max(max(X)); 33 | SaturMap = ~((X==maxX) & ~SaturMap); 34 | else error('Invalid matrix dimensions)'); 35 | end 36 | 37 | switch gray 38 | case 'gray' 39 | if size(X,3)==3, 40 | SaturMap = SaturMap(:,:,1)+SaturMap(:,:,3)+SaturMap(:,:,3); 41 | SaturMap(SaturMap>1) = 1; 42 | end 43 | otherwise 'do nothing'; 44 | end -------------------------------------------------------------------------------- /matlab/Functions/SeeProgress.m: -------------------------------------------------------------------------------- 1 | function SeeProgress(i) 2 | % SeeProgress(i) outputs i without performing carriage return 3 | % This function is designed to be used in slow for-loops to show how the calculations progress 4 | % If the first call in the loop is not with i=1, it's convenient to call SeeProgress(1) before the loop. 5 | 6 | if i==1 | i==0, fprintf('\n '); end 7 | de='\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b'; 8 | b=num2str(i,8); 9 | le=length(b); 10 | fprintf([de(1:2*(le+9)),'* %d *\n'],i); 11 | -------------------------------------------------------------------------------- /matlab/Functions/WienerInDFT.m: -------------------------------------------------------------------------------- 1 | function NoiseClean = WienerInDFT(ImNoise,sigma) 2 | % function g = WienerInDFT(ImNoise,sigma) removes periodical patterns (like the blockness) from input noise in frequency domain 3 | % Used to remove blockness and other artefacts from noise extracted from JPEG images 4 | % INPUT: 5 | % ImNoise noise extracted from one images or a camera reference pattern 6 | % sigma standard deviation of the noise that we want not to exceed even locally if DFT domain 7 | % OUTPUT: 8 | % NoiseClean filtered image noise (or camera reference pattern) - estimate of PRNU 9 | 10 | [M,N] = size(ImNoise); 11 | 12 | F = fft2(ImNoise); clear ImNoise, 13 | Fmag = abs(F/sqrt(M*N)); % normalized magnitude 14 | 15 | NoiseVar = sigma^2; 16 | Fmag1 = WaveNoise(Fmag,NoiseVar); 17 | 18 | fzero = find(Fmag==0); Fmag(fzero)=1; Fmag1(fzero)=0; clear fzero, 19 | F = F.*Fmag1./Fmag; 20 | 21 | % inverse FFT transform 22 | NoiseClean = real(ifft2(F)); 23 | -------------------------------------------------------------------------------- /matlab/Functions/ZeroMean.m: -------------------------------------------------------------------------------- 1 | function [Y,LP]=ZeroMean(X,type) 2 | % function Y=ZeroMeanCol(X,type) subtracts mean from all subsignals of the given type 3 | % X 2-D or 3-D matrix 4 | % type One of 4 options: 'col', 'row', 'both', 'CFA' 5 | % Usage: Y=ZeroMean(X,'col') ... Y will have all columns with mean 0. 6 | % Y=ZeroMean(X,'CFA') ... Y will have all columns, rows, and 4 types of odd/even pixels zero mean. 7 | 8 | if nargin<2, type='CFA'; end % default 9 | 10 | [M,N,K] = size(X); 11 | % initialize the output matrix and vectors 12 | % X = single(X); Y = zeros(size(X),'single'); row = zeros(M,K,'single'); col = zeros(K,N,'single'); % if working in single precision 13 | Y = zeros(size(X)); row = zeros(M,K); col = zeros(K,N); cm=0; 14 | 15 | % subtract mean from each color channel 16 | for j=1:K, 17 | mu(j) = mean2(X(:,:,j)); 18 | X(:,:,j) = X(:,:,j)-mu(j); 19 | end 20 | for j=1:K, 21 | row(:,j) = mean(X(:,:,j)')'; 22 | col(j,:) = mean(X(:,:,j)); 23 | end 24 | 25 | switch type 26 | case 'col' 27 | for j=1:K, Y(:,:,j)=X(:,:,j)-ones(M,1)*col(j,:); end 28 | case 'row' 29 | for j=1:K, Y(:,:,j)=X(:,:,j)-row(:,j)*ones(1,N); end 30 | case 'both' 31 | for j=1:K, Y(:,:,j)=X(:,:,j)-ones(M,1)*col(j,:); end 32 | for j=1:K, Y(:,:,j)=Y(:,:,j)-row(:,j)*ones(1,N); end % equal to Y = ZeroMean(X,'row'); Y = ZeroMean(Y,'col'); 33 | case 'CFA' 34 | for j=1:K, Y(:,:,j)=X(:,:,j)-ones(M,1)*col(j,:); end 35 | for j=1:K, Y(:,:,j)=Y(:,:,j)-row(:,j)*ones(1,N); end % equal to Y = ZeroMean(X,'both'); 36 | for j=1:K, 37 | cm = mean2(Y(1:2:end,1:2:end,j)); 38 | Y(1:2:end,1:2:end,j) = Y(1:2:end,1:2:end,j)-cm; 39 | Y(2:2:end,2:2:end,j) = Y(2:2:end,2:2:end,j)-cm; 40 | Y(1:2:end,2:2:end,j) = Y(1:2:end,2:2:end,j)+cm; 41 | Y(2:2:end,1:2:end,j) = Y(2:2:end,1:2:end,j)+cm; 42 | end 43 | otherwise 44 | error('Unknown type'); 45 | end 46 | % Linear pattern data: 47 | LP.row=row; LP.col=col; LP.mu=mu; LP.checkerboard_mean=cm; -------------------------------------------------------------------------------- /matlab/Functions/ZeroMeanTotal.m: -------------------------------------------------------------------------------- 1 | function [Y,LP]=ZeroMeanTotal(X) 2 | % function Y=ZeroMeanTotal(X) subtracts mean from 3 | % all black and all white subsets of columns and rows in the checkerboard pattern 4 | % X 2-D or 3-D matrix 5 | 6 | Y = zeros(size(X)); 7 | 8 | [Z,LP11] = ZeroMean(X(1:2:end,1:2:end,:),'both'); 9 | Y(1:2:end,1:2:end,:) = Z; 10 | [Z,LP12] = ZeroMean(X(1:2:end,2:2:end,:),'both'); 11 | Y(1:2:end,2:2:end,:) = Z; 12 | [Z,LP21] = ZeroMean(X(2:2:end,1:2:end,:),'both'); 13 | Y(2:2:end,1:2:end,:) = Z; 14 | [Z,LP22] = ZeroMean(X(2:2:end,2:2:end,:),'both'); 15 | Y(2:2:end,2:2:end,:) = Z; 16 | 17 | LP.d11=LP11; LP.d12=LP12; LP.d21=LP21; LP.d22=LP22; -------------------------------------------------------------------------------- /matlab/Functions/crosscorr.m: -------------------------------------------------------------------------------- 1 | function ret = crosscorr(array1, array2) 2 | % function ret = crosscor2(array1, array2) 3 | % Computes 2D crosscorrelation of 2D arrays 4 | % Function returns DOUBLE type 2D array 5 | % No normalization applied 6 | 7 | array1 = double(array1); 8 | array2 = double(array2); 9 | array1 = array1 - mean(array1(:)); 10 | array2 = array2 - mean(array2(:)); 11 | 12 | %%%%%%%%%%%%%%% End of filtering 13 | tilted_array2 = fliplr(array2); clear array2 14 | tilted_array2 = flipud(tilted_array2); 15 | TA = fft2(tilted_array2); clear tilted_array2 16 | FA = fft2(array1); clear array1 17 | FF = FA .* TA; clear FA TA 18 | ret = real(ifft2(FF)); 19 | -------------------------------------------------------------------------------- /matlab/Functions/imcropmiddle.m: -------------------------------------------------------------------------------- 1 | function X = imcropmiddle(X,sizeout,preference) 2 | % function X = imcropmiddle(X,sizeout,preference) crops the middle portion of a given size 3 | % X image matrix 4 | % sizeout size of the output image 5 | 6 | if nargin<3, preference='SE'; end 7 | if length(sizeout)>2, sizeout = sizeout(1:2); end 8 | 9 | [M,N,three]=size(X); 10 | sizeout = min([[M,N];sizeout]); 11 | switch preference % the cropped region is off center by 1/2 pixel 12 | case 'NW' 13 | M0 = floor((M-sizeout(1))/2); 14 | M1 = M0+sizeout(1); 15 | N0 = floor((N-sizeout(2))/2); 16 | N1 = N0+sizeout(2); 17 | case 'SW' 18 | M0 = ceil((M-sizeout(1))/2); 19 | M1 = M0+sizeout(1); 20 | N0 = floor((N-sizeout(2))/2); 21 | N1 = N0+sizeout(2); 22 | case 'NE' 23 | M0 = floor((M-sizeout(1))/2); 24 | M1 = M0+sizeout(1); 25 | N0 = ceil((N-sizeout(2))/2); 26 | N1 = N0+sizeout(2); 27 | case 'SE' 28 | M0 = ceil((M-sizeout(1))/2); 29 | M1 = M0+sizeout(1); 30 | N0 = ceil((N-sizeout(2))/2); 31 | N1 = N0+sizeout(2); 32 | end 33 | X = X(M0+1:M1,N0+1:N1,:); 34 | -------------------------------------------------------------------------------- /matlab/Functions/rgb2gray1.m: -------------------------------------------------------------------------------- 1 | function G = rgb2gray1(X,datatype) 2 | % function G = rgb2gray1(X) Convert RGB-like real data to gray-like output. 3 | 4 | if size(X,3)==1; G=X; return, end 5 | if nargin<2, datatype = 'double'; end 6 | [M,N,three] = size(X); 7 | X = reshape(X,[M*N,three]); 8 | 9 | % Calculate transformation matrix 10 | T = inv([1.0 0.956 0.621; 1.0 -0.272 -0.647; 1.0 -1.106 1.703]); 11 | coef = T(1,:)'; 12 | 13 | switch datatype 14 | case 'single' 15 | G = reshape(single(X)*coef,[M,N]); 16 | case 'double' 17 | G = reshape(double(X)*coef,[M,N]); 18 | end -------------------------------------------------------------------------------- /matlab/NoiseExtractFromImage.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/NoiseExtractFromImage.m -------------------------------------------------------------------------------- /matlab/PRNUtraining.m: -------------------------------------------------------------------------------- 1 | function [fingerprint] = PRNUtraining(imgpath,n) 2 | 3 | % PRNU fingerprint extraction from n images placed in imgpath 4 | % 5 | % The fingerprint is extracted according to Goljan, Fridrich 6 | % http://dde.binghamton.edu/download/camera_fingerprint/ 7 | % 8 | % INPUT 9 | % imgpath (optional): path of reference images for PRNU estimation 10 | % n (optional): number of images to be processed 11 | % 12 | % OUTPUT 13 | % fingerprint: grey-scale estimation of PRNU 14 | 15 | % if no input, standard path 16 | if nargin < 1 17 | imgpath = '/Users/massimoiuliani/CyberShare/Dottorato/matlab/dataset/Nikon'; 18 | end 19 | 20 | 21 | imgs = dir(imgpath); 22 | imgs = imgs(~cellfun(@isempty,regexpi({imgs(:,1).name},'\.(tiff?|jpe?g|png|gif)$'))); 23 | 24 | if nargin < 2 25 | n = length(imgs); 26 | end 27 | 28 | % size check 29 | if n > length(imgs) 30 | disp('n bigger than number of images!! Going on taking into account real number of images') 31 | length(imgs) 32 | imgs = imgs(1:end); 33 | else 34 | imgs = imgs(1:n); 35 | end 36 | 37 | % fingerprint extraction 38 | RP = getFingerprint(imgs); 39 | RP = rgb2gray1(RP); 40 | sigmaRP = std2(RP); 41 | fingerprint = WienerInDFT(RP,sigmaRP); 42 | 43 | end 44 | 45 | -------------------------------------------------------------------------------- /matlab/ncuts/Ncut.m: -------------------------------------------------------------------------------- 1 | function [value] = Ncut(weights, degree, eigenvector, threshold) 2 | %NCUTS Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | x = (eigenvector > threshold); 6 | x = (2 * x) - 1; 7 | d = diag(degree); 8 | k = sum(d(x > 0)) / sum(d); 9 | b = k / (1 - k); 10 | y = (1 + x) - b * (1 - x); 11 | value = (y' * (degree - weights) * y) / ( y' * degree * y ); 12 | 13 | end -------------------------------------------------------------------------------- /matlab/ncuts/NcutPartition.m: -------------------------------------------------------------------------------- 1 | function [segments] = NcutPartition(I, weights, id, th_ncut, verbose) 2 | %Normalized cuts algorithm using ncut value of the bipartition to stop 3 | %recursion. 4 | 5 | if verbose 6 | fprintf('ID %s: ', id); 7 | disp(I); 8 | end 9 | 10 | if length(I) < 2 11 | segments{1} = I; 12 | return; 13 | end 14 | 15 | %Compute degree matrix 16 | degree = getDegreeMatrix(weights); 17 | 18 | %Solve the generalized eigenvalues problem 19 | [eigenvectors, eigenvalues] = eigs(degree - weights, degree, 2, 'sm'); 20 | %Take the second smallest eigenvalue 21 | [eigenvalue, i] = max(abs(sum(eigenvalues, 2))); 22 | %Take the eigenvector associated to the second smallest eigenvalue 23 | eigenvector = eigenvectors(:, i); 24 | 25 | %Get best threshold value 26 | threshold = computeBestThresholdValue(weights, degree, eigenvector); 27 | 28 | %Bipartition of the graph 29 | [A, B] = bipartition(eigenvector, threshold); 30 | 31 | %Check if recursion must be stopped 32 | ncut = Ncut(weights, degree, eigenvector, threshold); 33 | if ncut > th_ncut 34 | segments{1} = I; 35 | return; 36 | end 37 | 38 | %Recursion 39 | segments_A = NcutPartition(I(A), weights(A, A), [id, '-A'], th_ncut, verbose); 40 | segments_B = NcutPartition(I(B), weights(B, B), [id, '-B'], th_ncut, verbose); 41 | 42 | %Concatenate segments and ids 43 | segments = [segments_A, segments_B]; 44 | 45 | end 46 | -------------------------------------------------------------------------------- /matlab/ncuts/NcutPartitionAggregationCoefficient.m: -------------------------------------------------------------------------------- 1 | function [segments] = NcutPartitionAggregationCoefficient(I, weights, id, th_recursion, verbose) 2 | %Normalized cuts algorithm using aggregation coefficients as threshold 3 | %value to stop recursion. 4 | 5 | if verbose 6 | fprintf('ID %s: ', id); 7 | disp(I); 8 | end 9 | 10 | if length(I) < 2 11 | segments{1} = I; 12 | return; 13 | end 14 | 15 | %Compute degree matrix 16 | degree = getDegreeMatrix(weights); 17 | 18 | %Solve the generalized eigenvalues problem 19 | [eigenvectors, eigenvalues] = eigs(degree - weights, degree, 2, 'sm'); 20 | %Take the second smallest eigenvalue 21 | [eigenvalue, i] = max(abs(sum(eigenvalues, 2))); 22 | %Take the eigenvector associated to the second smallest eigenvalue 23 | eigenvector = eigenvectors(:, i); 24 | 25 | %Get best threshold value 26 | threshold = computeBestThresholdValue(weights, degree, eigenvector); 27 | 28 | %Bipartition of the graph 29 | [A, B] = bipartition(eigenvector, threshold); 30 | 31 | ac_A = aggregationCoefficient(weights(A, A)); 32 | ac_B = aggregationCoefficient(weights(B, B)); 33 | 34 | %Check if recursion must be stopped 35 | segments_A = {I(A)}; 36 | if ac_A < th_recursion 37 | segments_A = NcutPartitionAggregationCoefficient(I(A), weights(A, A), [id, '-A'], th_recursion, verbose); 38 | end 39 | 40 | segments_B = {I(B)}; 41 | if ac_B < th_recursion 42 | segments_B = NcutPartitionAggregationCoefficient(I(B), weights(B, B), [id, '-B'], th_recursion, verbose); 43 | end 44 | 45 | %Concatenate segments and ids 46 | segments = [segments_A, segments_B]; 47 | 48 | end 49 | -------------------------------------------------------------------------------- /matlab/ncuts/aggregationCoefficient.m: -------------------------------------------------------------------------------- 1 | function [value] = aggregationCoefficient(weights) 2 | %AGGREGATIONCOEFFICIENT Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | value = sum(sum(weights)) / (size(weights, 1)^2); 6 | 7 | end 8 | 9 | -------------------------------------------------------------------------------- /matlab/ncuts/bipartition.m: -------------------------------------------------------------------------------- 1 | function [A, B] = bipartition(vector, threshold) 2 | %BIPARTITION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | A = find(vector > threshold); 6 | B = find(vector <= threshold); 7 | 8 | end 9 | -------------------------------------------------------------------------------- /matlab/ncuts/computeBestThresholdValue.m: -------------------------------------------------------------------------------- 1 | function [threshold] = computeBestThresholdValue(weights, degree, eigenvector) 2 | %COMPUTEBESTTHRESHOLDVALUE Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | values = zeros(1, size(eigenvector, 1)); 6 | for i = 1:size(eigenvector, 1) 7 | values(i) = Ncut(weights, degree, eigenvector, eigenvector(i)); 8 | end 9 | 10 | [~, idx] = min(values); 11 | threshold = eigenvector(idx); 12 | 13 | end 14 | -------------------------------------------------------------------------------- /matlab/ncuts/crossvalidateThreshold.m: -------------------------------------------------------------------------------- 1 | function [tprs, fprs, thresholds] = crossvalidateThreshold(imgpath, imgtype, numFolders, numImages, weights, range, type, outputPath, offset) 2 | % Find optimal threshold for normalized cuts algorithm 3 | % 4 | % INPUTS 5 | % Required parameters 6 | % 7 | % weights : matrix of weights for the grapth 8 | % range: range of values for searching threshold 9 | % type: 'NC' or 'AC' 10 | % ---------------------------------------------------- 11 | % Authors: Lorenzo Cioni, Saverio Meucci 12 | % ---------------------------------------------------- 13 | 14 | filenames = getImagesPath(imgpath, imgtype, 'NumFolders', numFolders, 'NumImages', numImages, 'Offset', offset); 15 | n_images = length(filenames); 16 | images = cell(n_images, 1); 17 | 18 | for i = 1:n_images 19 | images{i}.name = filenames(i).filename; 20 | images{i}.folder = filenames(i).camera; 21 | end 22 | 23 | images = cell2mat(images); 24 | 25 | fprintf('Crossvalidate threshold value in range\n\n'); 26 | 27 | thresholds = zeros(length(range), 1); 28 | fprs = zeros(length(range), 1); 29 | tprs = zeros(length(range), 1); 30 | 31 | for i = 1:length(range) 32 | th = range(i); 33 | fprintf('Setting threshold to: %f - ', th); 34 | clusters = normalizedCuts(weights, 'Type', type, 'Threshold', th, 'Verbose', false); 35 | [TPR, FPR] = validateClusterResults(images, clusters); 36 | fprintf('TPR: %f, FPR: %f\n', TPR, FPR); 37 | thresholds(i) = th; 38 | fprs(i) = FPR; 39 | tprs(i) = TPR; 40 | end 41 | 42 | if ~isempty(outputPath) && ~exist(['mat/' outputPath], 'dir') 43 | mkdir(['mat/' outputPath]); 44 | end 45 | save(['mat/' outputPath 'threshold_crossvalidation' type '.mat'], 'thresholds', 'fprs', 'tprs'); 46 | 47 | end 48 | 49 | -------------------------------------------------------------------------------- /matlab/ncuts/getDegreeMatrix.m: -------------------------------------------------------------------------------- 1 | function [degree] = getDegreeMatrix(weights) 2 | %GETDEGREEMATRIX Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | degree = zeros(size(weights, 1), size(weights, 2)); 6 | s = sum(weights, 1); 7 | for i = 1:size(weights, 1) 8 | degree(i, i) = s(i); 9 | end 10 | 11 | end 12 | 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/AUTHORS: -------------------------------------------------------------------------------- 1 | The primary authors of Rice Wavelet Toolbox are and/or have been: 2 | * Richard Baraniuk 3 | * Hyeokho Choi 4 | * Ramesh Neelamani 5 | * Vinay Ribeiro 6 | * Rebecca Hindman 7 | * Justin Romberg 8 | * Haitao Guo 9 | * Felix Fernandes 10 | * Brent Hendricks 11 | * Ramesh Gopinath 12 | * Markus Lang 13 | * Jan Erik Odegard 14 | * Dong Wei 15 | * Joshua Jackson 16 | -------------------------------------------------------------------------------- /matlab/rwt-master/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | project (rwt) 3 | subdirs(lib/src) 4 | subdirs(doc) 5 | subdirs(python) 6 | 7 | #set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") 8 | #FIND_PACKAGE(MatlabMex REQUIRED) 9 | 10 | # This section based on http://www.cmake.org/pipermail/cmake/2003-June/003953.html 11 | IF (UNIX) 12 | ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) 13 | SET(DISTCLEANED 14 | CMakeFiles 15 | cmake.depends 16 | cmake.check_depends 17 | CMakeCache.txt 18 | cmake.check_cache 19 | Makefile 20 | *.cmake 21 | */CMakeCache.txt 22 | */CMakeFiles 23 | */Makefile 24 | */*.cmake 25 | */*/CMakeCache.txt 26 | */*/CMakeFiles 27 | */*/*.cmake 28 | */*/Makefile 29 | lib/src/*.a 30 | doc/Doxyfile 31 | doc/html 32 | doc/latex 33 | core core.* 34 | gmon.out 35 | */*.mex* 36 | */*.o 37 | lib/src/*.o 38 | python/rwtPYTHON_wrap.cxx 39 | python/rwt.py 40 | python/rwt.pyc 41 | python/_rwt.so 42 | *~ 43 | ) 44 | 45 | ADD_CUSTOM_COMMAND( 46 | DEPENDS clean 47 | COMMENT "distribution clean" 48 | COMMAND rm 49 | ARGS -Rf CMakeTmp ${DISTCLEANED} 50 | TARGET distclean 51 | ) 52 | ENDIF(UNIX) 53 | -------------------------------------------------------------------------------- /matlab/rwt-master/INSTALL: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | = MATLAB Installation Instructions = 3 | ================================================================================ 4 | 5 | 1. Make sure you have the latest source code. See the GitHub page at 6 | https://github.com/ricedsp/rwt 7 | If you have the command line git tool installed you should be able to run: 8 | git clone https://github.com/ricedsp/rwt.git 9 | 10 | 2. Properly set up your system to create MEX-files. Refer to the MATLAB 11 | documentation section "Build MEX-Files" at 12 | http://www.mathworks.com/help/matlab/matlab_external/building-mex-files.html 13 | 14 | 3. Run MATLAB and change to the "bin" subdirectory containing the .m files 15 | 16 | 4. Compile the toolbox by executing the Matlab command: compile 17 | 18 | 5. Add the toolbox "bin" subdirectory to your Matlab path. 19 | 20 | ================================================================================ 21 | = Octave Installation Instructions = 22 | ================================================================================ 23 | 24 | Octave installation is similar to the procedure for MATLAB above. On Linux you 25 | will need the octave-dev (Debian/Ubuntu) or octave-devel (RedHat, etc.) package 26 | installed. 27 | 28 | ================================================================================ 29 | = Python Installation Instructions = 30 | ================================================================================ 31 | 32 | Python installation requires CMake. To install the python bindings, execute the 33 | following commands: 34 | cd python 35 | cmake . 36 | sudo make install 37 | 38 | On OSX, CMake is available from Macports http://www.macports.org/ 39 | For Redhat Enterprise Linux, Scientific Linux, CentOS, etc. there is a package 40 | available on RepoForge http://repoforge.org/use/ 41 | -------------------------------------------------------------------------------- /matlab/rwt-master/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2000 RICE UNIVERSITY. All rights reserved. 2 | 3 | This software is distributed and licensed to you on a non-exclusive 4 | basis, free-of-charge. Redistribution and use in source and binary forms, 5 | with or without modification, are permitted provided that the following 6 | conditions are met: 7 | 8 | 1. Redistribution of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 2. Redistribution in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY WILLIAM MARSH RICE UNIVERSITY, HOUSTON, TEXAS, 18 | AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 19 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICE UNIVERSITY 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | OR BUSINESS INTERRUPTIONS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | OTHERWISE), PRODUCT LIABILITY, OR OTHERWISE ARISING IN ANY WAY OUT OF THE 27 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | For information on commercial licenses, contact Rice University's Office of 30 | Technology Transfer at techtran@rice.edu or (713) 348-6173 31 | 32 | -------------------------------------------------------------------------------- /matlab/rwt-master/bin/HardTh.m: -------------------------------------------------------------------------------- 1 | function x = HardTh(y,thld) 2 | % x = HardTh(y,thld); 3 | % 4 | % HARDTH hard thresholds the input signal y with the threshold value 5 | % thld. 6 | % 7 | % Input: 8 | % y : 1D or 2D signal to be thresholded 9 | % thld : threshold value 10 | % 11 | % Output: 12 | % x : Hard thresholded output (x = (abs(y)>thld).*y) 13 | % 14 | % HERE'S AN EASY WAY TO RUN THE EXAMPLES: 15 | % Cut-and-paste the example you want to run to a new file 16 | % called ex.m, for example. Delete out the % at the beginning 17 | % of each line in ex.m (Can use search-and-replace in your editor 18 | % to replace it with a space). Type 'ex' in matlab and hit return. 19 | % 20 | % 21 | % Example: 22 | % y = makesig('WernerSorrows',8); 23 | % thld = 1; 24 | % x = HardTh(y,thld) 25 | % x = 1.5545 5.3175 0 1.6956 -1.2678 0 1.7332 0 26 | % 27 | % See also: SoftTh 28 | % 29 | %Author: Haitao Guo 30 | 31 | x = (abs(y) > thld).*y; 32 | -------------------------------------------------------------------------------- /matlab/rwt-master/bin/SoftTh.m: -------------------------------------------------------------------------------- 1 | function x = SoftTh(y,thld) 2 | % x = SoftTh(y,thld); 3 | % 4 | % SOFTTH soft thresholds the input signal y with the threshold value 5 | % thld. 6 | % 7 | % Input: 8 | % y : 1D or 2D signal to be thresholded 9 | % thld : Threshold value 10 | % 11 | % Output: 12 | % x : Soft thresholded output (x = sign(y)(|y|-thld)_+) 13 | % 14 | % HERE'S AN EASY WAY TO RUN THE EXAMPLES: 15 | % Cut-and-paste the example you want to run to a new file 16 | % called ex.m, for example. Delete out the % at the beginning 17 | % of each line in ex.m (Can use search-and-replace in your editor 18 | % to replace it with a space). Type 'ex' in matlab and hit return. 19 | % 20 | % 21 | % Example: 22 | % y = makesig('Doppler',8); 23 | % thld = 0.2; 24 | % x = SoftTh(y,thld) 25 | % x = 0 0 0 -0.0703 0 0.2001 0.0483 0 26 | % 27 | % See also: HardTh 28 | % 29 | % Reference: 30 | % "De-noising via Soft-Thresholding" Tech. Rept. Statistics, 31 | % Stanford, 1992. D.L. Donoho. 32 | % 33 | %Author: Haitao Guo 34 | 35 | x = abs(y); 36 | x = sign(y).*(x >= thld).*(x - thld); 37 | -------------------------------------------------------------------------------- /matlab/rwt-master/bin/compile.m: -------------------------------------------------------------------------------- 1 | % COMPILE compiles the c files and generates mex files. 2 | % 3 | 4 | if exist('OCTAVE_VERSION', 'builtin') 5 | mkoctfile --mex -v -DOCTAVE_MEX_FILE ../mex/mdwt.c ../lib/src/dwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -o omdwt.mex 6 | mkoctfile --mex -v -DOCTAVE_MEX_FILE ../mex/midwt.c ../lib/src/idwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -o omidwt.mex 7 | mkoctfile --mex -v -DOCTAVE_MEX_FILE ../mex/mrdwt.c ../lib/src/rdwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -o omrdwt.mex 8 | mkoctfile --mex -v -DOCTAVE_MEX_FILE ../mex/mirdwt.c ../lib/src/irdwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -o omirdwt.mex 9 | else 10 | x = computer(); 11 | if (x(length(x)-1:length(x)) == '64') 12 | mex -v -largeArrayDims ../mex/mdwt.c ../lib/src/dwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 13 | mex -v -largeArrayDims ../mex/midwt.c ../lib/src/idwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 14 | mex -v -largeArrayDims ../mex/mrdwt.c ../lib/src/rdwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 15 | mex -v -largeArrayDims ../mex/mirdwt.c ../lib/src/irdwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 16 | else 17 | mex -v -compatibleArrayDims ../mex/mdwt.c ../lib/src/dwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 18 | mex -v -compatibleArrayDims ../mex/midwt.c ../lib/src/idwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 19 | mex -v -compatibleArrayDims ../mex/mrdwt.c ../lib/src/rdwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 20 | mex -v -compatibleArrayDims ../mex/mirdwt.c ../lib/src/irdwt.c ../lib/src/init.c ../lib/src/platform.c -I../lib/inc -outdir ../bin 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /matlab/rwt-master/bin/daubcqf.m: -------------------------------------------------------------------------------- 1 | function [h_0,h_1] = daubcqf(N,TYPE) 2 | % [h_0,h_1] = daubcqf(N,TYPE); 3 | % 4 | % Function computes the Daubechies' scaling and wavelet filters 5 | % (normalized to sqrt(2)). 6 | % 7 | % Input: 8 | % N : Length of filter (must be even) 9 | % TYPE : Optional parameter that distinguishes the minimum phase, 10 | % maximum phase and mid-phase solutions ('min', 'max', or 11 | % 'mid'). If no argument is specified, the minimum phase 12 | % solution is used. 13 | % 14 | % Output: 15 | % h_0 : Minimal phase Daubechies' scaling filter 16 | % h_1 : Minimal phase Daubechies' wavelet filter 17 | % 18 | % Example: 19 | % N = 4; 20 | % TYPE = 'min'; 21 | % [h_0,h_1] = daubcqf(N,TYPE) 22 | % h_0 = 0.4830 0.8365 0.2241 -0.1294 23 | % h_1 = 0.1294 0.2241 -0.8365 0.4830 24 | % 25 | % Reference: "Orthonormal Bases of Compactly Supported Wavelets", 26 | % CPAM, Oct.89 27 | % 28 | %Author: Ramesh Gopinath 29 | 30 | if(nargin < 2), 31 | TYPE = 'min'; 32 | end; 33 | if(rem(N,2) ~= 0), 34 | error('No Daubechies filter exists for ODD length'); 35 | end; 36 | K = N/2; 37 | a = 1; 38 | p = 1; 39 | q = 1; 40 | h_0 = [1 1]; 41 | for j = 1:K-1, 42 | a = -a * 0.25 * (j + K - 1)/j; 43 | h_0 = [0 h_0] + [h_0 0]; 44 | p = [0 -p] + [p 0]; 45 | p = [0 -p] + [p 0]; 46 | q = [0 q 0] + a*p; 47 | end; 48 | q = sort(roots(q)); 49 | qt = q(1:K-1); 50 | if TYPE=='mid', 51 | if rem(K,2)==1, 52 | qt = q([1:4:N-2 2:4:N-2]); 53 | else 54 | qt = q([1 4:4:K-1 5:4:K-1 N-3:-4:K N-4:-4:K]); 55 | end; 56 | end; 57 | h_0 = conv(h_0,real(poly(qt))); 58 | h_0 = sqrt(2)*h_0/sum(h_0); %Normalize to sqrt(2); 59 | if(TYPE=='max'), 60 | h_0 = fliplr(h_0); 61 | end; 62 | if(abs(sum(h_0 .^ 2))-1 > 1e-4) 63 | error('Numerically unstable for this value of "N".'); 64 | end; 65 | h_1 = rot90(h_0,2); 66 | h_1(1:2:N)=-h_1(1:2:N); 67 | -------------------------------------------------------------------------------- /matlab/rwt-master/bin/mdwt.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/bin/mdwt.mexmaci64 -------------------------------------------------------------------------------- /matlab/rwt-master/bin/midwt.m: -------------------------------------------------------------------------------- 1 | function [y,L] = midwt(x,h,L) 2 | % [x,L] = midwt(y,h,L); 3 | % 4 | % Function computes the inverse discrete wavelet transform x for a 1D or 5 | % 2D input signal y using the scaling filter h. 6 | % 7 | % Input: 8 | % y : finite length 1D or 2D input signal (implicitly periodized) 9 | % (see function mdwt to find the structure of y) 10 | % h : scaling filter 11 | % L : number of levels. In the case of a 1D signal, length(x) must be 12 | % divisible by 2^L; in the case of a 2D signal, the row and the 13 | % column dimension must be divisible by 2^L. If no argument is 14 | % specified, a full inverse DWT is returned for maximal possible 15 | % L. 16 | % 17 | % Output: 18 | % x : periodic reconstructed signal 19 | % L : number of decomposition levels 20 | % 21 | % 1D Example: 22 | % xin = makesig('LinChirp',8); 23 | % h = daubcqf(4,'min'); 24 | % L = 1; 25 | % [y,L] = mdwt(xin,h,L); 26 | % [x,L] = midwt(y,h,L) 27 | % 28 | % 1D Example's output: 29 | % 30 | % x = 0.0491 0.1951 0.4276 0.7071 0.9415 0.9808 0.6716 0.0000 31 | % L = 1 32 | % 33 | % See also: mdwt, mrdwt, mirdwt 34 | % 35 | %Author: Markus Lang 36 | if exist('OCTAVE_VERSION', 'builtin') 37 | if (exist('L')) 38 | [y,L] = omidwt(x,h,L); 39 | else 40 | [y,L] = omidwt(x,h); 41 | end 42 | else 43 | error('You must compile wavelet toolbox before use') 44 | end 45 | -------------------------------------------------------------------------------- /matlab/rwt-master/bin/midwt.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/bin/midwt.mexmaci64 -------------------------------------------------------------------------------- /matlab/rwt-master/bin/mirdwt.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/bin/mirdwt.mexmaci64 -------------------------------------------------------------------------------- /matlab/rwt-master/bin/mrdwt.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/bin/mrdwt.mexmaci64 -------------------------------------------------------------------------------- /matlab/rwt-master/bin/setopt.m: -------------------------------------------------------------------------------- 1 | function option = setopt(opt_par,default); 2 | % option = setopt(opt_par,default); 3 | % 4 | % SETOPT can modify a default option vector with user specified options. 5 | % 6 | % Input: 7 | % opt_par : Users desired option vector 8 | % default : Program default option vector 9 | % 10 | % Output: 11 | % option : New option vector 12 | % 13 | % Example: 14 | % opt_par = [1 2 3 4]; 15 | % default = [1 1 1 1]; 16 | % option = setopt(opt_par,default) 17 | % option = 1 2 3 4 18 | % 19 | %Author: Jan Erik Odegard 20 | 21 | if (nargin < 2) 22 | error('You need two inputs'); 23 | end; 24 | len = length(opt_par); 25 | option = zeros(size(default)); 26 | option(1:len) = opt_par(1:len); 27 | option = option + (option == 0).*default; 28 | -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.01/RWT-2.01.tar.Z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.01/RWT-2.01.tar.Z -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/INSTALL: -------------------------------------------------------------------------------- 1 | Installation instructions 2 | ------------------------- 3 | 4 | In order to install this distribution of Rice Wavelet Tools version 2.3 5 | released - 6 | 7 | 1. Properly set up your system to create MEX-files. Please refer to the 8 | "Matlab Application Program Guide" to properly set up of your matlab 9 | and C-compiler to be able to compile C-mex files on your system. 10 | All reference documentations are available on the MathWorks web page: 11 | www.mathworks.com 12 | 13 | 2. Make a toolbox directory and uncompress/extract all the files. 14 | For example, in the unix environment, 15 | 16 | gunzip rwt.tar.gz 17 | tar xvf rwt.tar 18 | 19 | 3. Run MATLAB and change to the temporary directory containing the files. 20 | 21 | 4. Compile the toolbox by executing the Matlab command 22 | 23 | compile 24 | 25 | 5. Add the toolbox directory to your Matlab path. 26 | 27 | 6. For further instructions, please refer to the README file. 28 | 29 | -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/INSTALL_PRECOMPILED: -------------------------------------------------------------------------------- 1 | Installation instructions 2 | ------------------------- 3 | 4 | In order to install this distribution of Rice Wavelet Tools version 2.3 5 | released - 6 | 7 | 1. Make a toolbox directory and uncompress/extract all the files. 8 | For example, in the unix environment, 9 | 10 | gunzip rwt.tar.gz 11 | tar xvf rwt.tar 12 | 13 | 2. Add the toolbox directory to your Matlab path. 14 | 15 | 3. For further instructions, please refer to the README file. 16 | 17 | -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/README: -------------------------------------------------------------------------------- 1 | Rice Wavelet Tools version 2.3 2 | Released - 3 | 4 | NEWER VERSION: 5 | A newer version of this toolbox is available at 6 | http://www.dsp.rice.edu/software/rwt.shtml 7 | 8 | INSTALLATION: 9 | To install this distribution of Rice Wavelet Tools see the INSTALL file. 10 | 11 | SOURCE: 12 | www.dsp.rice.edu/software/rwt.shtml 13 | 14 | EMAIL: 15 | For bug reports and questions, send email to webmaster-dsp@ece.rice.edu 16 | 17 | CONDITIONS FOR USE: 18 | See the LICENSE file 19 | 20 | TOOLBOX FUNCTIONS: 21 | 22 | Wavelet Transforms 23 | mdwt - Discrete orthogonal wavelet transform using the Mallat algorithm (1D and 2D) 24 | midwt - Inverse discrete orthogonal wavelet transform 25 | mrdwt - Undecimated (redundant) discrete wavelet transform (1D and 2D) 26 | mirdwt - Inverse undecimated discrete wavelet transform 27 | daubcqf - Daubechies filter coefficients 28 | 29 | Wavelet Domain Processing 30 | denoise - Denoise signals and images by thresholding wavelet coefficients 31 | HardTh - Hard thresholding 32 | SoftTh - Soft thresholding 33 | 34 | Other 35 | makesig - Create Donoho-Johnstone test signals 36 | compile - Compile the Rice Wavelet Toolbox 37 | 38 | Functions omitted in this version of toolbox can be found in 39 | version 2.01 at www.dsp.rice.edu/software/RWT2.01/RWT-2.01.tar.Z 40 | 41 | This version may not compile with Matlab 6.0 (Release 12) and above. 42 | This problem has been fixed in version 2.4 at 43 | www.dsp.rice.edu/software/rwt.shtml 44 | -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwt-lnx.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwt-lnx.tar.gz -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwt-sol.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwt-sol.tar.gz -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwt.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwt.tar.gz -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwt.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwt.zip -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwt_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwt_logo.jpg -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwtwin98.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwtwin98.zip -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.3/rwtwinnt.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.3/rwtwinnt.zip -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.4/rwt-linux7.2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.4/rwt-linux7.2.tar.gz -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.4/rwt-osx.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.4/rwt-osx.tar.gz -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.4/rwt.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.4/rwt.tar.gz -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.4/rwt.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.4/rwt.zip -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.4/rwtwin98.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.4/rwtwin98.zip -------------------------------------------------------------------------------- /matlab/rwt-master/dist/2.4/rwtwinxp.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/dist/2.4/rwtwinxp.zip -------------------------------------------------------------------------------- /matlab/rwt-master/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # add a target to generate API documentation with Doxygen 2 | find_package(Doxygen) 3 | if(DOXYGEN_FOUND) 4 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) 5 | add_custom_target(doc 6 | ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 7 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 8 | COMMENT "Generating API documentation with Doxygen" VERBATIM 9 | ) 10 | 11 | find_package(LATEX) 12 | find_program(DOXYFILE_MAKE make) 13 | mark_as_advanced(DOXYFILE_MAKE) 14 | add_custom_command(TARGET doc 15 | POST_BUILD 16 | COMMAND "${DOXYFILE_MAKE}" 17 | COMMENT "Running LaTeX for Doxygen documentation in ${CMAKE_CURRENT_SOURCE_DIR}/latex..." 18 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/latex") 19 | 20 | 21 | endif(DOXYGEN_FOUND) 22 | -------------------------------------------------------------------------------- /matlab/rwt-master/lib/inc/rwt_init.h: -------------------------------------------------------------------------------- 1 | /*! \file rwt_init.h 2 | \brief Header for matlab init functions in init.c 3 | */ 4 | #ifndef RWT_INIT_H_ 5 | #define RWT_INIT_H_ 6 | 7 | #include "rwt_platform.h" 8 | 9 | #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) 10 | #include "mex.h" 11 | #ifndef OCTAVE_MEX_FILE 12 | #include "matrix.h" 13 | #endif 14 | typedef struct { 15 | size_t nrows; /*!< The number of rows in the input matrix. Output matrix will match. */ 16 | size_t ncols; /*!< The number of columns in the input matrix. Output matrix will match. */ 17 | int levels; /*!< L, the number of levels for the transform. */ 18 | int ncoeff; /*!< Length of h / the number of scaling coefficients */ 19 | double *scalings; /*!< Wavelet scaling coefficients */ 20 | } rwt_init_params; 21 | typedef enum {NORMAL_DWT, REDUNDANT_DWT, INVERSE_DWT, INVERSE_REDUNDANT_DWT} transform_t; 22 | #endif 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) 29 | rwt_init_params rwt_matlab_init(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], transform_t dwtType); 30 | #else 31 | int rwt_find_levels(size_t m, size_t n); 32 | int rwt_check_levels(int levels, size_t rows, size_t cols); 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* RWT_INIT_H_ */ 40 | -------------------------------------------------------------------------------- /matlab/rwt-master/lib/inc/rwt_platform.h: -------------------------------------------------------------------------------- 1 | /*! \file rwt_platform.h 2 | \brief Abstract away environment differences and provide some common macros 3 | */ 4 | #ifndef RWT_PLATFORM_H 5 | #define RWT_PLATFORM_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /*! For MATLAB we address 2d inputs and outputs in column-major order */ 12 | /*! For Python we address 2d inputs and outputs in row-major order */ 13 | /*! The offset macros are for debugging */ 14 | /*! The parameters for the mat() macro are: 15 | * a - the base pointer to the matrix of values 16 | * i - index of the target row 17 | * j - index of the target column 18 | * m - the number of rows 19 | * n - the number of columns 20 | */ 21 | #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) 22 | #define COLUMN_MAJOR_ORDER 1 23 | #include "mex.h" 24 | #ifndef OCTAVE_MEX_FILE 25 | #include "matrix.h" 26 | #endif 27 | #define mat(a, i, j, m, n) (*(a + (m*(j)+i))) 28 | #define mat_offset(a, i, j, m, n) (m*(j)+i) 29 | #define offset_row(offset, m, n) (offset % m) 30 | #define offset_col(offset, m, n) ((offset - (offset % m)) / m) 31 | #define rwt_printf(fmt, ...) mexPrintf(fmt, ##__VA_ARGS__) 32 | #define rwt_errormsg(msg) mexErrMsgTxt(msg) 33 | #else 34 | #define ROW_MAJOR_ORDER 1 35 | #define mat(a, i, j, m, n) (*(a + (n*(i)+j))) 36 | #define mat_offset(a, i, j, m, n) (n*(i)+j) 37 | #define offset_row(offset, m, n) ((offset - (offset % n)) / n) 38 | #define offset_col(offset, m, n) (offset % n) 39 | #define rwt_printf(fmt, ...) printf(fmt, ##__VA_ARGS__) 40 | #define rwt_errormsg(msg) printf("\033[91m%s\033[0m\n", msg); 41 | #endif 42 | 43 | #ifndef max 44 | #define max(A,B) (A > B ? A : B) 45 | #endif 46 | #ifndef min 47 | #define min(A,B) (A < B ? A : B) 48 | #endif 49 | #define even(x) ((x & 1) ? 0 : 1) 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | void *rwt_malloc(size_t size); 56 | void *rwt_calloc(size_t num, size_t size); 57 | void rwt_free(void *ptr); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /matlab/rwt-master/lib/inc/rwt_transforms.h: -------------------------------------------------------------------------------- 1 | /*! \file rwt_transforms.h 2 | \brief Function prototypes for the transform implementations 3 | */ 4 | #ifndef TRANSFORMS_H_ 5 | #define TRANSFORMS_H_ 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /*! dwt and rdwt take an input x and store the result in y or yl and yh 14 | * idwt and irdwt take an input y or yl and yh and store the result in x 15 | * In all cases it is expected that the output array has already been 16 | * allocated prior to calling the transform function. 17 | */ 18 | void dwt(double *x, size_t nrows, size_t ncols, double *h, int ncoeff, int levels, double *y); 19 | void idwt(double *x, size_t nrows, size_t ncols, double *h, int ncoeff, int levels, double *y); 20 | void rdwt(double *x, size_t nrows, size_t ncols, double *h, int ncoeff, int levels, double *yl, double *yh); 21 | void irdwt(double *x, size_t nrows, size_t ncols, double *h, int ncoeff, int levels, double *yl, double *yh); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif /* TRANSFORMS_H_ */ 28 | -------------------------------------------------------------------------------- /matlab/rwt-master/lib/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories ("${PROJECT_SOURCE_DIR}/lib/inc") 2 | add_library(dwt dwt.c) 3 | add_library(idwt idwt.c) 4 | add_library(irdwt irdwt.c) 5 | add_library(rdwt rdwt.c) 6 | add_library(platform platform.c) 7 | -------------------------------------------------------------------------------- /matlab/rwt-master/lib/src/platform.c: -------------------------------------------------------------------------------- 1 | /*! \file platform.c 2 | \brief Wrap memory allocation routines so that we can use the MATLAB ones when we build for MATLAB. 3 | 4 | rwt_malloc, rwt_calloc, and rwt_free simply wrap the MATLAB or system versions of malloc, calloc, and free. 5 | */ 6 | 7 | #include "rwt_platform.h" 8 | 9 | #if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE) 10 | void *rwt_malloc(size_t size) { 11 | return mxMalloc(size); 12 | } 13 | void *rwt_calloc(size_t num, size_t size) { 14 | return mxCalloc(num, size); 15 | } 16 | void rwt_free(void *ptr) { 17 | mxFree(ptr); 18 | } 19 | #else 20 | void *rwt_malloc(size_t size) { 21 | return malloc(size); 22 | } 23 | void *rwt_calloc(size_t num, size_t size) { 24 | return calloc(num, size); 25 | } 26 | void rwt_free(void *ptr) { 27 | free(ptr); 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /matlab/rwt-master/mex/mdwt.c: -------------------------------------------------------------------------------- 1 | /*! \file mdwt.c 2 | \brief MATLAB gateway for the discrete wavelet transform 3 | 4 | This file is used to produce a MATLAB MEX binary for the discrete wavelet transform 5 | 6 | %y = mdwt(x,h,L); 7 | % 8 | % function computes the discrete wavelet transform y for a 1D or 2D input 9 | % signal x. 10 | % 11 | % Input: 12 | % x : finite length 1D or 2D signal (implicitely periodized) 13 | % h : scaling filter 14 | % L : number of levels. in case of a 1D signal length(x) must be 15 | % divisible by 2^L; in case of a 2D signal the row and the 16 | % column dimension must be divisible by 2^L. 17 | % 18 | % see also: midwt, mrdwt, mirdwt 19 | */ 20 | 21 | #include "mex.h" 22 | #include "rwt_init.h" 23 | #include "rwt_transforms.h" 24 | 25 | /*! 26 | * Matlab MEX definition for the discrete wavelet transform. 27 | * 28 | * @param nlhs number of items on left hand side of matlab call 29 | * @param plhs pointer to left hand side data structure 30 | * @param nrhs number of items on right hand side of matlab call 31 | * @param prhs pointer to right hand side data structure 32 | * 33 | */ 34 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 35 | rwt_init_params params = rwt_matlab_init(nlhs, plhs, nrhs, prhs, NORMAL_DWT); /*! Check input and determine the parameters for dwt() */ 36 | plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL); /*! Create the output matrix */ 37 | *mxGetPr(plhs[1]) = params.levels; /*! The second returned item is the number of levels */ 38 | dwt(mxGetPr(prhs[0]), params.nrows, params.ncols, params.scalings, params.ncoeff, params.levels, mxGetPr(plhs[0])); /*! Perform the DWT */ 39 | } 40 | 41 | -------------------------------------------------------------------------------- /matlab/rwt-master/mex/midwt.c: -------------------------------------------------------------------------------- 1 | /*! \file midwt.c 2 | \brief MATLAB gateway for the inverse discrete wavelet transform 3 | 4 | This file is used to produce a MATLAB MEX binary for the inverse discrete wavelet transform 5 | 6 | %y = midwt(x,h,L); 7 | % 8 | % function computes the inverse discrete wavelet transform y for a 1D or 2D 9 | % input signal x. 10 | % 11 | % Input: 12 | % x : finite length 1D or 2D input signal (implicitely periodized) 13 | % h : scaling filter 14 | % L : number of levels. in case of a 1D signal length(x) must be 15 | % divisible by 2^L; in case of a 2D signal the row and the 16 | % column dimension must be divisible by 2^L. 17 | % 18 | % see also: mdwt, mrdwt, mirdwt 19 | */ 20 | 21 | #include "mex.h" 22 | #include "rwt_init.h" 23 | #include "rwt_transforms.h" 24 | 25 | /*! 26 | * Matlab MEX definition for the inverse discrete wavelet transform. 27 | * 28 | * @param nlhs number of items on left hand side of matlab call 29 | * @param plhs pointer to left hand side data structure 30 | * @param nrhs number of items on right hand side of matlab call 31 | * @param prhs pointer to right hand side data structure 32 | * 33 | */ 34 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { 35 | double *x, *y; 36 | rwt_init_params params = rwt_matlab_init(nlhs, plhs, nrhs, prhs, INVERSE_DWT); 37 | y = mxGetPr(prhs[0]); 38 | x = mxGetPr(plhs[0]); 39 | plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL); 40 | *mxGetPr(plhs[1]) = params.levels; 41 | idwt(x, params.nrows, params.ncols, params.scalings, params.ncoeff, params.levels, y); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /matlab/rwt-master/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | FIND_PACKAGE(SWIG REQUIRED) 3 | INCLUDE(${SWIG_USE_FILE}) 4 | 5 | FIND_PACKAGE(PythonLibs) 6 | INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) 7 | 8 | FIND_PROGRAM(PYTHON_EXECUTABLE NAMES python python 3.3 python3.2 python3.1 python3.0 python3 python2.7) 9 | message("python: " ${PYTHON_EXECUTABLE}) 10 | 11 | EXEC_PROGRAM ("${PYTHON_EXECUTABLE}" 12 | ARGS "-c 'import numpy; print numpy.get_include()'" 13 | OUTPUT_VARIABLE NUMPY_INCLUDE_DIR 14 | RETURN_VALUE NUMPY_NOT_FOUND) 15 | message("numpy : " ${NUMPY_INCLUDE_DIR}) 16 | INCLUDE_DIRECTORIES(${NUMPY_INCLUDE_DIR}) 17 | 18 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) 19 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../lib/inc) 20 | 21 | SET(CMAKE_SWIG_FLAGS "") 22 | 23 | SET_SOURCE_FILES_PROPERTIES(rwt.i PROPERTIES CPLUSPLUS ON) 24 | #SET_SOURCE_FILES_PROPERTIES(rwt.i PROPERTIES SWIG_FLAGS "-includeall") 25 | SWIG_ADD_MODULE(rwt python rwt.i ../lib/src/dwt.c ../lib/src/idwt.c ../lib/src/rdwt.c ../lib/src/irdwt.c ../lib/src/platform.c ../lib/src/init.c) 26 | SWIG_LINK_LIBRARIES(rwt ${PYTHON_LIBRARIES}) 27 | 28 | execute_process(COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) 29 | install(TARGETS _rwt DESTINATION ${PYTHON_SITE_PACKAGES}) 30 | install(FILES rwt.py DESTINATION ${PYTHON_SITE_PACKAGES}) 31 | -------------------------------------------------------------------------------- /matlab/rwt-master/python/LICENSE.numpy: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2011, NumPy Developers. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of the NumPy Developers nor the names of any 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/lena.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/lena.bmp -------------------------------------------------------------------------------- /matlab/rwt-master/tests/lena512.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/lena512.mat -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/Readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/class_diagram_a.vsd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/architecture/class_diagram_a.vsd -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/class_diagram_b.vsd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/architecture/class_diagram_b.vsd -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/class_diagram_c.vsd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/architecture/class_diagram_c.vsd -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/html/class_diagram_a.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/architecture/html/class_diagram_a.gif -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/html/class_diagram_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/architecture/html/class_diagram_b.gif -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/html/class_diagram_c.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/architecture/html/class_diagram_c.gif -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/architecture/testSample.m: -------------------------------------------------------------------------------- 1 | function test_suite = testSample 2 | initTestSuite; 3 | 4 | function testMyCode 5 | assertEqual(1, 1); 6 | assertElementsAlmostEqual(1, 1.1); 7 | assertTrue(10 == 10); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/+abc/+tests/test_that.m: -------------------------------------------------------------------------------- 1 | % Do-nothing test used in the examples for organizing tests inside packages. 2 | % 3 | % Steven L. Eddins 4 | % Copyright 2010 The MathWorks, Inc. 5 | 6 | function test_that 7 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/+abc/+tests/test_this.m: -------------------------------------------------------------------------------- 1 | % Do-nothing test used in the examples for organizing tests inside packages. 2 | % 3 | % Steven L. Eddins 4 | % Copyright 2010 The MathWorks, Inc. 5 | 6 | function test_this 7 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/+abc_tests/test_that.m: -------------------------------------------------------------------------------- 1 | % Do-nothing test used in the examples for organizing tests inside packages. 2 | % 3 | % Steven L. Eddins 4 | % Copyright 2010 The MathWorks, Inc. 5 | 6 | function test_that 7 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/+abc_tests/test_this.m: -------------------------------------------------------------------------------- 1 | % Do-nothing test used in the examples for organizing tests inside packages. 2 | % 3 | % Steven L. Eddins 4 | % Copyright 2010 The MathWorks, Inc. 5 | 6 | function test_this 7 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exQuickStart.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How to Write and Run Tests 2 | % This example shows how to write and run a couple of test cases for the MATLAB 3 | % |fliplr| function. 4 | 5 | %% Make a folder for your tests 6 | % To get started, create a folder (directory) that will contain your tests, and 7 | % then make that your working folder. The test directory in this example is 8 | % example_quick_start. 9 | 10 | cd example_quick_start 11 | 12 | %% Write each test case as a simple M-file 13 | % Write each test case as an M-file function that returns no output arguments. 14 | % The function name should start or end with "test" or "Test". The test case 15 | % passes if the function runs with no error. 16 | % 17 | % Here's a test-case M-file that verifies the correct output for a vector input. 18 | 19 | type testFliplrVector 20 | 21 | %% 22 | % The function |testFliplrVector| calls the function being tested and checks the 23 | % output against the expected output. If the output is different than expected, 24 | % the function calls |error|. 25 | % 26 | % Here's another test-case M-file that verifies the correct |fliplr| output for 27 | % a matrix input. 28 | 29 | type testFliplrMatrix 30 | 31 | %% 32 | % This function is simpler than |testFliplrVector| because it uses the utility 33 | % testing function |assertEqual|. |assertEqual| checks to see whether its two 34 | % inputs are equal. If they are equal, |assertEqual| simply returns silently. 35 | % If they are not equal, |assertEqual| calls |error|. 36 | 37 | %% Run all the tests using |runtests| 38 | % To run all your test cases, simply call |runtests|. |runtests| automatically finds 39 | % all the test cases in the current directory, runs them, and reports the 40 | % results to the Command Window. 41 | 42 | runtests 43 | 44 | %% 45 | % <../index.html Back to MATLAB xUnit Test Framework> 46 | 47 | %% 48 | % Copyright 2008-2010 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exRunSpecificTest.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How to Run a Specific Test 2 | % To run all the test cases in just one M-file, ignoring other test 3 | % cases that might be in other files in the same directory, give 4 | % the name of the file (without the ".m" extension) as an argument 5 | % to |runtests|. 6 | % 7 | % For example 8 | 9 | cd example_subfunction_tests 10 | 11 | runtests testFliplr 12 | 13 | %% 14 | % To run a single test case, add the name of the test case using a 15 | % colon (":"), like this: 16 | 17 | runtests testFliplr:testFliplrVector 18 | 19 | %% 20 | % <../index.html Back to MATLAB xUnit Test Framework> 21 | 22 | %% 23 | % Copyright 2008-2010 The MathWorks, Inc. 24 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exRunTestsInADirectory.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests in Specific Directories 2 | % To run all the test cases in a specific directory, give the name of the 3 | % directory as an argument to |runtests|. 4 | % 5 | % For example 6 | 7 | runtests example_subfunction_tests 8 | 9 | %% 10 | % To run tests in multiple directories, give each directory name as a separate 11 | % argument to |runtests|. 12 | 13 | %% 14 | % <../index.html Back to MATLAB xUnit Test Framework> 15 | 16 | %% 17 | % Copyright 2008-2010 The MathWorks, Inc. 18 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exRunTestsInPackage.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How to Run Tests in a Package 2 | % To run all the test cases in a package, give the name of the 3 | % package as an argument to |runtests|. *Note:* Running tests in a package 4 | % requires MATLAB R2009a or later. 5 | % 6 | % For example, suppose you are distributing a set of MATLAB files called the 7 | % "ABC Toolbox." Then you could put your tests inside a package called abc_tests 8 | % and run them like this: 9 | 10 | runtests abc_tests 11 | 12 | %% 13 | % (Note that the initial "+" character in the name of the package folder on disk 14 | % is not part of the package name.) 15 | % 16 | % Or you could put your tests inside a subpackage called abc.tests and run them 17 | % like this: 18 | 19 | runtests abc.tests 20 | 21 | %% 22 | % You should not use a generic top-level package name such "tests" because then 23 | % your package might be unintentionally combined with packages with the same 24 | % name created by other people. 25 | 26 | %% 27 | % <../index.html Back to MATLAB xUnit Test Framework> 28 | 29 | %% 30 | % Copyright 2010 The MathWorks, Inc. 31 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exSubfunctionTests.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How to Put Multiple Test Cases in One M-file 2 | % The Quick Start example showed how you can write a simple M-file 3 | % to be a single test case. This example shows you how to put multiple 4 | % test cases in one M-file. 5 | % 6 | % Name your M-file beginning or ending with "test", like 7 | % "testMyFunc". Start by putting the following two lines at the 8 | % beginning of the file. It's important that the output variable 9 | % name on line 1 be |test_suite|. 10 | % 11 | % function test_suite = testMyFunc 12 | % initTestSuite; 13 | % 14 | % Next, add subfunctions to the file. Each subfunction beginning 15 | % or ending with "test" becomes an individual test case. 16 | % 17 | % The directory example_subfunction_tests contains a test M-file 18 | % containing subfunction test cases for the |fliplr| function. 19 | 20 | cd example_subfunction_tests 21 | 22 | type testFliplr 23 | 24 | %% 25 | % As usual, run the test cases using |runtests|: 26 | 27 | runtests 28 | 29 | %% 30 | % <../index.html Back to MATLAB xUnit Test Framework> 31 | 32 | %% 33 | % Copyright 2008-2010 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exTestCaseSearching.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How RUNTESTS Searches for Test Cases 2 | % When you call |runtests| with no input arguments: 3 | % 4 | % >> runtests 5 | % 6 | % it automatically searches for all the test cases in the current directory. It 7 | % looks for test cases in three types of M-files: 8 | % 9 | % 1. An M-file function whose name begins or ends with "test" or "Test" and that does 10 | % not return an output argument. Such a function is considered to be a single 11 | % test case. 12 | % 13 | % 2. An M-file function whose name begins or ends with "test" or "Test" and that returns 14 | % an output argument that is a test suite. Such a function is considered to contain 15 | % subfunction-style test cases. Each subfunction whose name begins or ends with "test" 16 | % or "Test" is a test case. 17 | % 18 | % 3. An M-file that defines a subclass of TestCase. Each method beginning or ending with 19 | % "test" or "Test" is a test case. 20 | % 21 | % |runtests| uses the |TestSuite| static methods |fromName| and |fromPwd| to 22 | % automatically construct the test suites. 23 | % 24 | % Here are a couple of examples. 25 | % 26 | % |TestSuite.fromName| takes an M-file name, determines what 27 | % kind of test file it is, and returns a cell array of test case objects. 28 | 29 | cd examples_general 30 | test_suite_1 = TestSuite.fromName('testSetupExample') 31 | 32 | %% 33 | % |TestSuite.fromPwd| returns a test suite based on all the test files in the 34 | % current directory. 35 | 36 | test_suite_2 = TestSuite.fromPwd() 37 | 38 | %% 39 | % <../index.html Back to MATLAB xUnit Test Framework> 40 | 41 | %% 42 | % Copyright 2008-2010 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/exTestFixtures.m: -------------------------------------------------------------------------------- 1 | %% <../index.html MATLAB xUnit Test Framework>: How to Write Tests That Share Common Set-Up Code 2 | % Sometimes you want to write a set of test cases in which the same 3 | % set of initialization steps is performed before each test case, or 4 | % in which the same set of cleanup steps is performed after each 5 | % test case. This set of common _setup_ and _teardown_ code is 6 | % called a _test fixture_. 7 | % 8 | % In subfunction-based test files, you can add subfunctions whose 9 | % names begin with "setup" and "teardown". These functions will be 10 | % called before and after every test-case subfunction is called. If 11 | % the setup function returns an output argument, that value is saved 12 | % and passed to every test-case subfunction and also to the teardown 13 | % function. 14 | % 15 | % This example shows a setup function that creates a figure and 16 | % returns its handle. The figure handle is passed to each test-case 17 | % subfunction. The figure handle is also passed to the teardown 18 | % function, which cleans up after each test case by deleting the 19 | % figure. 20 | 21 | cd examples_general 22 | type testSetupExample 23 | 24 | %% 25 | % Run the tests using |runtests|. 26 | 27 | runtests testSetupExample 28 | 29 | %% 30 | % You might also want to see the 31 | % <./exTestCase.html example on writing test cases by 32 | % subclassing TestCase>. 33 | 34 | %% 35 | % <../index.html Back to MATLAB xUnit Test Framework> 36 | 37 | %% 38 | % Copyright 2008-2010 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/example_quick_start/testFliplrMatrix.m: -------------------------------------------------------------------------------- 1 | function testFliplrMatrix 2 | %testFliplrMatrix Unit test for fliplr with matrix input 3 | 4 | in = magic(3); 5 | assertEqual(fliplr(in), in(:, [3 2 1])); 6 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/example_quick_start/testFliplrVector.m: -------------------------------------------------------------------------------- 1 | function testFliplrVector 2 | %testFliplrVector Unit test for fliplr with vector input 3 | 4 | in = [1 4 10]; 5 | out = fliplr(in); 6 | expected_out = [10 4 1]; 7 | 8 | if ~isequal(out, expected_out) 9 | error('testFliplrVector:notEqual', 'Incorrect output for vector.'); 10 | end 11 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/example_subfunction_tests/testFliplr.m: -------------------------------------------------------------------------------- 1 | function test_suite = testFliplr 2 | initTestSuite; 3 | 4 | function testFliplrMatrix 5 | in = magic(3); 6 | assertEqual(fliplr(in), in(:, [3 2 1])); 7 | 8 | function testFliplrVector 9 | assertEqual(fliplr([1 4 10]), [10 4 1]); 10 | 11 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/examples_general/TestUsingTestCase.m: -------------------------------------------------------------------------------- 1 | classdef TestUsingTestCase < TestCase 2 | 3 | properties 4 | fh 5 | end 6 | 7 | methods 8 | function self = TestUsingTestCase(name) 9 | self = self@TestCase(name); 10 | end 11 | 12 | function setUp(self) 13 | self.fh = figure; 14 | end 15 | 16 | function tearDown(self) 17 | delete(self.fh); 18 | end 19 | 20 | function testColormapColumns(self) 21 | assertEqual(size(get(self.fh, 'Colormap'), 2), 3); 22 | end 23 | 24 | function testPointer(self) 25 | assertEqual(get(self.fh, 'Pointer'), 'arrow'); 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/examples_general/testBadSinTest.m: -------------------------------------------------------------------------------- 1 | function test_suite = testBadSinTest 2 | initTestSuite; 3 | 4 | function testSinPi 5 | % Example of a failing test case. The test writer should have used 6 | % assertAlmostEqual here. 7 | assertEqual(sin(pi), 0); 8 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/examples_general/testCos.m: -------------------------------------------------------------------------------- 1 | function test_suite = testCos 2 | initTestSuite; 3 | 4 | function testTooManyInputs 5 | assertExceptionThrown(@() cos(1, 2), 'MATLAB:maxrhs'); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/examples_general/testSetupExample.m: -------------------------------------------------------------------------------- 1 | function test_suite = testSetupExample 2 | initTestSuite; 3 | 4 | function fh = setup 5 | fh = figure; 6 | 7 | function teardown(fh) 8 | delete(fh); 9 | 10 | function testColormapColumns(fh) 11 | assertEqual(size(get(fh, 'Colormap'), 2), 3); 12 | 13 | function testPointer(fh) 14 | assertEqual(get(fh, 'Pointer'), 'arrow'); 15 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/examples_general/testSin.m: -------------------------------------------------------------------------------- 1 | function testSin 2 | 3 | assertElementsAlmostEqual(sin(pi), 0); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/examples_general/testWithSetupError.m: -------------------------------------------------------------------------------- 1 | function test_suite = testWithSetupError 2 | %Example of a test with an error. The setup function calls cos with 3 | %too many input arguments. 4 | 5 | initTestSuite; 6 | 7 | function testData = setup 8 | testData = cos(1, 2); 9 | 10 | function testMyFeature(testData) 11 | assertEqual(1, 1); 12 | 13 | function teardown(testData) 14 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/file_exchange_description.txt: -------------------------------------------------------------------------------- 1 | MATLAB xUnit Test Framework is a unit test framework for MATLAB code. 2 | 3 | MATLAB xUnit is designed to be easy to use for MATLAB users with a wide range of experience. Users can write tests using ordinary M-files that are very simple in structure. 4 | 5 | MATLAB xUnit comes with extensive documentation that ranges in scope from a "Getting Started" section to advanced techniques and architectural notes. You can view this documentation online without downloading the package. For example, scroll down to the "Published M Files" section on this page and click on "MATLAB xUnit Quick Start - How to write and run tests." To see all the MATLAB xUnit documentation online, scroll down to the "HTML Files" section on this page and click on "Readme.html." 6 | 7 | Only the "xunit" directory is needed to use the framework. The "tests" directory contains the framework's own test suite. The "architecture" directory contains architectural notes on the framework's design and how it might be extended. 8 | 9 | MATLAB xUnit can be used with MATLAB releases R2008a and later. MATLAB xUnit relies heavily on object-oriented language features introduced in R2008a and will not work with earlier releases. 10 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/helptoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MATLAB xUnit Test Framework for MATLAB 6 | 7 | Quick Start: How to Write and Run Tests 8 | 9 | 10 | How to Put Multiple Test Cases in One M-file 11 | 12 | 13 | How to Run a Specific Test 14 | 15 | 16 | How to Run Tests in Specific Directories 17 | 18 | 19 | How to Run Tests in a Package 20 | 21 | 22 | How to Test Using a Floating-Point Tolerance 23 | 24 | 25 | How to Test an Error Message 26 | 27 | 28 | How to Run Tests Silently and Query the Results 29 | 30 | 31 | How to Write Tests That Share Common Set-Up Code 32 | 33 | 34 | How to Write xUnit-Style Tests by Subclassing TestCase 35 | 36 | 37 | How MATLAB xUnit Searches for Test Cases 38 | 39 | 40 | Latest Version 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/html/exTolerance_eq28823.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/doc/html/exTolerance_eq28823.png -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/html/exTolerance_eq55725.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/doc/html/exTolerance_eq55725.png -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/doc/screen-shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/doc/screen-shot.png -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, The MathWorks, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | * Neither the name of the The MathWorks, Inc. nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/Contents.m: -------------------------------------------------------------------------------- 1 | % UTILS Utility package for MTEST unit testing framework 2 | % 3 | % Array Comparison 4 | % compareFloats - Compare floating-point arrays using tolerance 5 | % 6 | % Test Case Discovery Functions 7 | % isTestCaseSubclass - True for name of TestCase subclass 8 | % 9 | % String Functions 10 | % containsRegexp - True if string contains regular expression 11 | % isSetUpString - True for string that looks like a setup function 12 | % isTearDownString - True for string that looks like teardown function 13 | % isTestString - True for string that looks like a test function 14 | % 15 | % Miscellaneous Functions 16 | % generateDoc - Publish test scripts in mtest/doc 17 | % parseFloatAssertInputs - Common input-parsing logic for several functions 18 | 19 | % Undocumented Functions 20 | % isAlmostEqual - Floating-point equality test using relative tolerance 21 | 22 | % Steven L. Eddins 23 | % Copyright 2008-2009 The MathWorks, Inc. 24 | 25 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/containsRegexp.m: -------------------------------------------------------------------------------- 1 | function tf = containsRegexp(str, exp) 2 | %containsRegexp True if string contains regular expression 3 | % TF = containsRegexp(str, exp) returns true if the string str contains the 4 | % regular expression exp. If str is a cell array of strings, then 5 | % containsRegexp tests each string in the cell array, returning the results in 6 | % a logical array with the same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | % Convert to canonical input form: A cell array of strings. 12 | if ~iscell(str) 13 | str = {str}; 14 | end 15 | 16 | matches = regexp(str, exp); 17 | tf = ~cellfun('isempty', matches); 18 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/generateDoc.m: -------------------------------------------------------------------------------- 1 | function generateDoc 2 | %generateDoc Publish the example scripts in the doc directory 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008-2009 The MathWorks, Inc. 6 | 7 | doc_dir = fullfile(fileparts(which('mtest')), '..', 'doc'); 8 | addpath(doc_dir); 9 | cd(doc_dir) 10 | mfiles = dir('*.m'); 11 | for k = 1:numel(mfiles) 12 | publish(mfiles(k).name); 13 | cd(doc_dir) 14 | end 15 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/isAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function same = isAlmostEqual(A, B, reltol) 2 | %isAlmostEqual Equality test using relative tolerance 3 | % same = isAlmostEqual(A, B, reltol), for two floating-point arrays A and B, 4 | % tests A and B for equality using the specified relative tolerance. 5 | % isAlmostEqual returns true if the following relationship is satisfied for 6 | % all values in A and B: 7 | % 8 | % abs(A - B) ./ max(abs(A), abs(B)) <= reltol 9 | % 10 | % same = isAlmostEqual(A, B) uses the following value for the relative 11 | % tolerance: 12 | % 13 | % 100 * max(eps(class(A)), eps(class(B))) 14 | % 15 | % If either A or B is not a floating-point array, then isAlmostEqual returns 16 | % the result of isequal(A, B). 17 | 18 | % Steven L. Eddins 19 | % Copyright 2008-2009 The MathWorks, Inc. 20 | 21 | if ~isfloat(A) || ~isfloat(B) 22 | same = isequal(A, B); 23 | return 24 | end 25 | 26 | if nargin < 3 27 | reltol = 100 * max(eps(class(A)), eps(class(B))); 28 | end 29 | 30 | if ~isequal(size(A), size(B)) 31 | same = false; 32 | return 33 | end 34 | 35 | A = A(:); 36 | B = B(:); 37 | 38 | delta = abs(A - B) ./ max(max(abs(A), abs(B)), 1); 39 | 40 | % Some floating-point values require special handling. 41 | delta((A == 0) & (B == 0)) = 0; 42 | delta(isnan(A) & isnan(B)) = 0; 43 | delta((A == Inf) & (B == Inf)) = 0; 44 | delta((A == -Inf) & (B == -Inf)) = 0; 45 | 46 | same = all(delta <= reltol); 47 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/isSetUpString.m: -------------------------------------------------------------------------------- 1 | function tf = isSetUpString(str) 2 | %isSetUpString True if string looks like the name of a setup function 3 | % tf = isSetUpString(str) returns true if the string str looks like the name 4 | % of a setup function. If str is a cell array of strings, then isSetUpString 5 | % tests each string in the cell array, returning the results in a logical 6 | % array with the same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | setup_exp = '^[sS]et[uU]p'; 12 | tf = mtest.utils.containsRegexp(str, setup_exp); 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/isTearDownString.m: -------------------------------------------------------------------------------- 1 | function tf = isTearDownString(str) 2 | %isTearDownString True if string looks like the name of a teardown function 3 | % tf = isTearDownString(str) returns true if the string str looks like the 4 | % name of a teardown function. If str is a cell array of strings, then 5 | % isTearDownString tests each string in the cell array, returning the results 6 | % in a logical array with the same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | setup_exp = '^[tT]ear[dD]own'; 12 | tf = mtest.utils.containsRegexp(str, setup_exp); 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/isTestCaseSubclass.m: -------------------------------------------------------------------------------- 1 | function tf = isTestCaseSubclass(name) 2 | %isTestCaseSubclass True for name of a TestCase subclass 3 | % tf = isTestCaseSubclass(name) returns true if the string name is the name of 4 | % a TestCase subclass on the MATLAB path. 5 | 6 | % Steven L. Eddins 7 | % Copyright 2008-2009 The MathWorks, Inc. 8 | 9 | tf = false; 10 | 11 | class_meta = meta.class.fromName(name); 12 | if isempty(class_meta) 13 | % Not the name of a class 14 | return; 15 | end 16 | 17 | if strcmp(class_meta.Name, 'TestCase') 18 | tf = true; 19 | else 20 | tf = isMetaTestCaseSubclass(class_meta); 21 | end 22 | 23 | function tf = isMetaTestCaseSubclass(class_meta) 24 | 25 | tf = false; 26 | 27 | if strcmp(class_meta.Name, 'TestCase') 28 | tf = true; 29 | else 30 | % Invoke function recursively on parent classes. 31 | super_classes = class_meta.SuperClasses; 32 | for k = 1:numel(super_classes) 33 | if isMetaTestCaseSubclass(super_classes{k}) 34 | tf = true; 35 | break; 36 | end 37 | end 38 | end 39 | 40 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/+mtest/+utils/isTestString.m: -------------------------------------------------------------------------------- 1 | function tf = isTestString(str) 2 | %isTestString True if string looks like the name of a test 3 | % tf = isTestString(str) returns true if the string str looks like the name of 4 | % a test. If str is a cell array of strings, then isTestString tests each 5 | % string in the cell array, returning the results in a logical array with the 6 | % same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | test_exp = '^[tT]est'; 12 | tf = mtest.utils.containsRegexp(str, test_exp); 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/assertAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function assertAlmostEqual(A, B, reltol, message) 2 | %assertEqual Assert that inputs are equal within relative tolerance 3 | % assertEqual(A, B, RELTOL) throws an exception of any of the values in A and 4 | % B are not equal within the specified tolerance. NaN values are considered 5 | % to be equal. A and B have to have the same class and sparsity to be 6 | % considered equal. 7 | % 8 | % assertEqual(A, B) uses the following relative tolerance value: 9 | % 10 | % 100 * eps(class(A)) 11 | % 12 | % assertEqual(A, B, RELTOL, MESSAGE) uses the specified message string when 13 | % throwing the exception. With this syntax, use RELTOL = [] to specify the 14 | % default relative tolerance. 15 | % 16 | % Note that if either A or B are not floating-point arrays, then A and B are 17 | % compared using ISEQUALWITHEQUALNANS and the relative tolerance value is not 18 | % used. 19 | % 20 | % Examples 21 | % -------- 22 | % % This call returns silently. 23 | % assertAlmostEqual(1.0, 1.0 + eps); 24 | % 25 | % % This call throws an error. 26 | % assertAlmostEqual(1.0, 1.1); 27 | % 28 | % See also assertEqual, mtest.utils.isAlmostEqual 29 | 30 | % Steven L. Eddins 31 | % Copyright 2008-2009 The MathWorks, Inc. 32 | 33 | if ~(issparse(A) == issparse(B)) 34 | throw(MException('assertAlmostEqual:sparsityNotEqual', message)); 35 | end 36 | 37 | if ~strcmp(class(A), class(B)) 38 | throw(MException('assertAlmostEqual:classNotEqual', message)); 39 | end 40 | 41 | if nargin < 3 || isempty(reltol) 42 | reltol = 100 * eps(class(A)); 43 | end 44 | 45 | if nargin < 4 46 | message = sprintf('Inputs are not equal within relative tolerance: %g', ... 47 | reltol); 48 | end 49 | 50 | if ~mtest.utils.isAlmostEqual(A, B, reltol) 51 | throw(MException('assertAlmostEqual:tolExceeded', message)); 52 | end 53 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/tests/MtestTest.m: -------------------------------------------------------------------------------- 1 | %TestSuiteTest Unit tests for mtest command-line test runner. 2 | 3 | classdef MtestTest < TestCaseInDir 4 | 5 | methods 6 | 7 | function self = MtestTest(name) 8 | self = self@TestCaseInDir(name, ... 9 | fullfile(fileparts(which(mfilename)), 'cwd_test')); 10 | end 11 | 12 | function test_noInputArgs(self) 13 | [T, did_pass] = evalc('mtest'); 14 | % The cwd_test directory contains some test cases that fail, 15 | % so output of mtest should be false. 16 | assertFalse(did_pass); 17 | end 18 | 19 | function test_oneInputArg(self) 20 | [T, did_pass] = evalc('mtest(''testFoobar'')'); 21 | % cwd_test/testFoobar.m is supposed to pass. 22 | assertTrue(did_pass); 23 | end 24 | 25 | function test_oneInputArgWithFilter_passing(self) 26 | [T, did_pass] = evalc('mtest(''TestCaseSubclass:testA'')'); 27 | assertTrue(did_pass); 28 | end 29 | 30 | function test_oneInputArgWithFilter_failing(self) 31 | [T, did_pass] = evalc('mtest(''TestCaseSubclass:testB'')'); 32 | assertFalse(did_pass); 33 | end 34 | 35 | end 36 | 37 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/tests/cwd_test/TestCaseSubclass.m: -------------------------------------------------------------------------------- 1 | %TestCaseSubclass TestCase subclass containing two passing tests 2 | 3 | % Steven L. Eddins 4 | % Copyright 2008 The MathWorks, Inc. 5 | 6 | classdef TestCaseSubclass < TestCase 7 | methods 8 | function self = TestCaseSubclass(name) 9 | self = self@TestCase(name); 10 | end 11 | 12 | function testA(self) 13 | end 14 | 15 | function testB(self) 16 | % Intentionally fail this test case. 17 | assertFalse(true); 18 | end 19 | end 20 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/tests/cwd_test/testFoobar.m: -------------------------------------------------------------------------------- 1 | function testFoobar 2 | %testFoobar Passing M-file test 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/tests/cwd_test/testSubfunctions.m: -------------------------------------------------------------------------------- 1 | function test_cases = testSubfunctions 2 | %testSubfunctions Contains two passing subfunction tests 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | findSubfunctionTests; 8 | 9 | function testSub1 10 | 11 | function testSub2 12 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/tests/testAssertAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function test_suite = testAssertAlmostEqual 2 | %testAssertAlmostEqual Unit tests for assertAlmostEqual 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testEqual 10 | assertAlmostEqual(1, 1); 11 | 12 | function testEqualWithThreeInputs 13 | assertAlmostEqual(1, 1.1, 0.2); 14 | 15 | function testEqualWithFourInputs 16 | assertExceptionThrown(@() assertAlmostEqual(1, 2, 0.1, 'checkmate'), ... 17 | 'assertAlmostEqual:tolExceeded'); 18 | 19 | function testEmptyRelTol 20 | assertAlmostEqual(1, 1+10*eps, [], 'checkmate'); 21 | 22 | function testNotEqual 23 | assertExceptionThrown(@() assertAlmostEqual(1, 1+1000*eps), ... 24 | 'assertAlmostEqual:tolExceeded'); 25 | 26 | function testSingleEqual 27 | assertAlmostEqual(single(1), single(1 + 10*eps('single'))); 28 | 29 | function testSingleNotEqual 30 | assertExceptionThrown(@() assertAlmostEqual(single(1), ... 31 | single(1 + 1000*eps('single'))), 'assertAlmostEqual:tolExceeded'); 32 | 33 | function testZeros 34 | assertAlmostEqual(0, 0); 35 | 36 | function testSingleZeros 37 | assertAlmostEqual(single(0), single(0)); 38 | 39 | function testSparse 40 | assertAlmostEqual(sparse(1), sparse(1 + 10*eps)); 41 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/obsolete/tests/testIsAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function test_suite = testIsAlmostEqual 2 | %testIsAlmostEqual Unit tests for isAlmostEqual 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testExactlyEqual 10 | A = [1 2; 3 4]; 11 | B = [1 2; 3 4]; 12 | assertTrue(mtest.utils.isAlmostEqual(A, B)); 13 | 14 | function testDefaultTolerance 15 | assertTrue(mtest.utils.isAlmostEqual(1, 1+10*eps)); 16 | assertFalse(mtest.utils.isAlmostEqual(1, 1+1000*eps)); 17 | 18 | function testDefaultToleranceSingle 19 | assertTrue(mtest.utils.isAlmostEqual(single(1), 1 + 10*eps('single'))); 20 | assertFalse(mtest.utils.isAlmostEqual(single(1), 1 + 1000*eps('single'))); 21 | 22 | function testSpecifiedTolerance 23 | assertTrue(mtest.utils.isAlmostEqual(1, 1.09, 0.1)); 24 | assertFalse(mtest.utils.isAlmostEqual(1, 1.2, 0.1)); 25 | 26 | function testSpecialValues 27 | A = [Inf, -Inf, NaN, 2.0]; 28 | B = [Inf, -Inf, NaN, 2.0+10*eps]; 29 | assertTrue(mtest.utils.isAlmostEqual(A, B)); 30 | 31 | C = [Inf, -Inf, NaN, 2.0]; 32 | D = [Inf, -Inf, 0, 2.0+10*eps]; 33 | assertFalse(mtest.utils.isAlmostEqual(C, D)); 34 | 35 | function testUint8 36 | assertTrue(mtest.utils.isAlmostEqual(uint8(1), uint8(1))); 37 | assertFalse(mtest.utils.isAlmostEqual(uint8(1), uint8(2))); 38 | 39 | function testChar 40 | assertTrue(mtest.utils.isAlmostEqual('foobar', 'foobar')); 41 | assertFalse(mtest.utils.isAlmostEqual('foo', 'bar')); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/+subpkg/test_a_bit.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_a_bit 2 | initTestSuite 3 | 4 | function test_now 5 | 6 | function test_later 7 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/A.m: -------------------------------------------------------------------------------- 1 | % Class A is a TestCase subclass containing two test cases (test_a and test_b). 2 | classdef A < TestCase 3 | 4 | methods 5 | function self = A(name) 6 | self = self@TestCase(name); 7 | end 8 | 9 | function test_a(self) 10 | end 11 | 12 | function test_b(self) 13 | end 14 | end 15 | 16 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/B.m: -------------------------------------------------------------------------------- 1 | % Class B is not a TestCase subclass. 2 | 3 | classdef B 4 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/FooTest.m: -------------------------------------------------------------------------------- 1 | classdef FooTest < TestCase 2 | methods 3 | function object = FooTest(name) 4 | object = object@TestCase(name); 5 | end 6 | function test_sanity(object) 7 | assertEqual(0, 0) 8 | end 9 | end 10 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/helper_that.m: -------------------------------------------------------------------------------- 1 | % helper_that is not a test file. 2 | 3 | function y = helper_that(x) 4 | y = x; 5 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/test_that.m: -------------------------------------------------------------------------------- 1 | % test_that.m is a subfunction test file. 2 | function test_suite = test_this 3 | initTestSuite 4 | 5 | function test_the_other 6 | a = magic(3); 7 | 8 | function test_nifty 9 | b = magic(5); 10 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/+xunit/+mocktests/test_this.m: -------------------------------------------------------------------------------- 1 | % test_this.m is a function-file test case. 2 | function test_this -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/Readme.m: -------------------------------------------------------------------------------- 1 | % This directory contains the test suite for the mUnit test framework. Before 2 | % running the test suite, do the following: 3 | % 4 | % 1. Make sure the mUnit test framework directory is on your path 5 | % 2. Make sure the helper_classes subdirectory of the test directory is on 6 | % your path. 7 | % 3. Make the test directory your current directory. 8 | % 9 | % To run the test suite: 10 | % 11 | % run(TestSuite()) 12 | 13 | % Steven L. Eddins 14 | % Copyright 2008 The MathWorks 15 | 16 | help Readme -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/TestCaseWithAddPathTest.m: -------------------------------------------------------------------------------- 1 | %TestCaseTest Unit tests for the TestCaseWithAddPath class 2 | 3 | % Steven L. Eddins 4 | % Copyright The MathWorks 2008 5 | 6 | classdef TestCaseWithAddPathTest < TestCaseWithAddPath 7 | 8 | methods 9 | function self = TestCaseWithAddPathTest(name) 10 | self = self@TestCaseWithAddPath(name, ... 11 | fullfile(fileparts(which(mfilename)), 'helper_classes')); 12 | end 13 | 14 | function testPath(self) 15 | % Verify that a function in helper_classes is seen on the path. 16 | assertEqual(exist('testFunctionHandlesA', 'file'), 2); 17 | end 18 | 19 | function testRunTestOnPath(self) 20 | % Verify that we can make a test suite and run it using a file 21 | % in the new path directory. 22 | logger = TestRunLogger(); 23 | suite = TestSuite('testFunctionHandlesA'); 24 | did_pass = suite.run(logger); 25 | assertTrue(did_pass); 26 | end 27 | end 28 | 29 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/TestRunLoggerTest.m: -------------------------------------------------------------------------------- 1 | %TestSuiteTest Unit tests for TestSuite class 2 | 3 | classdef TestRunLoggerTest < TestCaseInDir 4 | 5 | methods 6 | function self = TestRunLoggerTest(name) 7 | self = self@TestCaseInDir(name, ... 8 | fullfile(fileparts(which(mfilename)), 'helper_classes')); 9 | end 10 | 11 | function testTwoPassingTests(self) 12 | logger = TestRunLogger; 13 | suite = TestSuite('TwoPassingTests'); 14 | suite.run(logger); 15 | 16 | assertEqual(logger.Log, ... 17 | {'TestRunStarted', ... 18 | 'TestComponentStarted', ... 19 | 'TestComponentStarted', 'TestComponentFinished', ... 20 | 'TestComponentStarted', 'TestComponentFinished', ... 21 | 'TestComponentFinished', ... 22 | 'TestRunFinished'}); 23 | 24 | assertEqual(logger.NumTestCases, 2); 25 | assertEqual(logger.NumFailures, 0); 26 | assertEqual(logger.NumErrors, 0); 27 | assertTrue(isempty(logger.Faults)); 28 | end 29 | 30 | function testFailingTestCase(self) 31 | logger = TestRunLogger; 32 | suite = TestSuite('FailingTestCase'); 33 | suite.run(logger); 34 | 35 | assertEqual(logger.Log, ... 36 | {'TestRunStarted', ... 37 | 'TestComponentStarted', ... 38 | 'TestComponentStarted', 'TestCaseFailure', 'TestComponentFinished', ... 39 | 'TestComponentFinished', ... 40 | 'TestRunFinished'}); 41 | 42 | assertEqual(logger.NumTestCases, 1); 43 | assertEqual(logger.NumFailures, 1); 44 | assertEqual(logger.NumErrors, 0); 45 | assertEqual(numel(logger.Faults), 1); 46 | assertEqual(logger.Faults(1).Type, 'failure'); 47 | end 48 | 49 | end 50 | 51 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/ThrowsExceptionTest.m: -------------------------------------------------------------------------------- 1 | classdef ThrowsExceptionTest < TestCaseInDir 2 | 3 | methods 4 | function self = ThrowsExceptionTest(methodName) 5 | self = self@TestCaseInDir(methodName, ... 6 | fullfile(fileparts(which(mfilename)), 'helper_classes')); 7 | end 8 | 9 | function testPassingTest(self) 10 | logger = TestRunLogger(); 11 | TestSuite('PassingExceptionTest').run(logger); 12 | assertTrue((logger.NumTestCases == 1) && ... 13 | (logger.NumFailures == 0) && ... 14 | (logger.NumErrors == 0), ... 15 | 'Passing exception test should have no failures or errors'); 16 | end 17 | 18 | function testNoExceptionTest(self) 19 | logger = TestRunLogger(); 20 | TestSuite('ExceptionNotThrownTest').run(logger); 21 | assertTrue(strcmp(logger.Faults(1).Exception.identifier, ... 22 | 'assertExceptionThrown:noException'), ... 23 | 'Fault exception should be throwsException:noException'); 24 | end 25 | 26 | function testWrongExceptionTest(self) 27 | logger = TestRunLogger(); 28 | TestSuite('WrongExceptionThrownTest').run(logger); 29 | assertTrue(strcmp(logger.Faults(1).Exception.identifier, ... 30 | 'assertExceptionThrown:wrongException'), ... 31 | 'Fault exception should be throwsException:wrongException'); 32 | end 33 | 34 | end 35 | 36 | 37 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/almost_black.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/tests/almost_black.tif -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/tests/black.png -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/black.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/tests/black.tif -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/cwd_test/TestCaseSubclass.m: -------------------------------------------------------------------------------- 1 | %TestCaseSubclass TestCase subclass containing two passing tests 2 | 3 | % Steven L. Eddins 4 | % Copyright 2008 The MathWorks, Inc. 5 | 6 | classdef TestCaseSubclass < TestCase 7 | methods 8 | function self = TestCaseSubclass(name) 9 | self = self@TestCase(name); 10 | end 11 | 12 | function testA(self) 13 | end 14 | 15 | function testB(self) 16 | % Intentionally fail this test case. 17 | assertFalse(true); 18 | end 19 | end 20 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/cwd_test/testFoobar.m: -------------------------------------------------------------------------------- 1 | function testFoobar 2 | %testFoobar Passing M-file test 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/cwd_test/testSubfunctions.m: -------------------------------------------------------------------------------- 1 | function test_suite = testSubfunctions 2 | %testSubfunctions Contains two passing subfunction tests 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testSub1 10 | 11 | function testSub2 12 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/dir1/test_thatPasses.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_thatPasses 2 | initTestSuite; 3 | 4 | function test_case 5 | assertTrue(true); 6 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/dir2/test_thatFails.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_thatFails 2 | initTestSuite; 3 | 4 | function test_case 5 | assertTrue(false); 6 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/empty_file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smeucci/CameraIdentification/2f12de31740da09d184e014a73ed52d73aca6a72/matlab/rwt-master/tests/matlab_xunit/tests/empty_file -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/BadFixture.m: -------------------------------------------------------------------------------- 1 | classdef BadFixture < TestCase 2 | 3 | methods 4 | function self = BadFixture(name) 5 | self = self@TestCase(name); 6 | end 7 | 8 | function setUp(self) 9 | throw(MException('setUpError:BadFixture', ... 10 | 'BadFixture setUp method always throws exception')); 11 | end 12 | 13 | function testMethod(self) 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/Contents.m: -------------------------------------------------------------------------------- 1 | % Helper Classes for mUnit Test Suite 2 | % 3 | % TestCase Subclasses 4 | % BadFixture - Contains setUp method that throws exception 5 | % FailingTestCase - Contains one test method that throws exception 6 | % LoggingTestCase - Logs calls to setUp, tearDown, and test method 7 | % NoTestMethods - TestCase subclass that contains no test methods 8 | % TestsToBeDiscovered - Used in TestSuiteTest 9 | % TwoPassingTests - Contains two passing test methods 10 | 11 | % Steven L. Eddins 12 | % Copyright 2008 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/ExceptionNotThrownTest.m: -------------------------------------------------------------------------------- 1 | classdef ExceptionNotThrownTest < TestCase 2 | methods 3 | function self = ExceptionNotThrownTest(methodName) 4 | self = self@TestCase(methodName); 5 | end 6 | 7 | function testThrowsException(self) 8 | f = @() []; 9 | assertExceptionThrown(f, 'a:b:c'); 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/FailingTestCase.m: -------------------------------------------------------------------------------- 1 | % FailingTestCase 2 | % Utility class used by unit tests. 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | classdef FailingTestCase < TestCase 8 | 9 | methods 10 | function self = FailingTestCase(name) 11 | self = self@TestCase(name); 12 | end 13 | 14 | function testFail(self) 15 | throw(MException('testFail:FailingTestCase', ... 16 | 'testFail always fails')); 17 | end 18 | end 19 | 20 | end 21 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/LoggingTestCase.m: -------------------------------------------------------------------------------- 1 | % LoggingTestCase 2 | % Utility class used by unit tests. 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | classdef LoggingTestCase < TestCase 8 | 9 | properties 10 | log = {}; 11 | end 12 | 13 | methods 14 | function self = LoggingTestCase(name) 15 | self = self@TestCase(name); 16 | end 17 | 18 | function setUp(self) 19 | self.log{end + 1} = 'setUp'; 20 | end 21 | 22 | function tearDown(self) 23 | self.log{end + 1} = 'tearDown'; 24 | end 25 | 26 | function testMethod(self) 27 | self.log{end + 1} = 'testMethod'; 28 | end 29 | 30 | function testBrokenMethod(self) 31 | throw(MException('brokenMethod:WasRun', ... 32 | 'Call to testBrokenMethod always throws exception')); 33 | end 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/NoTestMethods.m: -------------------------------------------------------------------------------- 1 | classdef NoTestMethods < TestCase 2 | methods 3 | function self = NoTestMethods(name) 4 | self = self@TestCase(name); 5 | end 6 | end 7 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/PassingExceptionTest.m: -------------------------------------------------------------------------------- 1 | classdef PassingExceptionTest < TestCase 2 | methods 3 | function self = PassingExceptionTest(methodName) 4 | self = self@TestCase(methodName); 5 | end 6 | 7 | function testThrowsException(self) 8 | f = @() error('a:b:c', 'error message'); 9 | assertExceptionThrown(f, 'a:b:c'); 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/TestsToBeDiscovered.m: -------------------------------------------------------------------------------- 1 | classdef TestsToBeDiscovered < TestCase 2 | 3 | methods 4 | function self = TestsToBeDiscovered(name) 5 | self = self@TestCase(name); 6 | end 7 | 8 | function testMethodA 9 | end 10 | 11 | function testMethodB 12 | end 13 | 14 | function notATestMethod 15 | end 16 | 17 | end 18 | 19 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/TwoPassingTests.m: -------------------------------------------------------------------------------- 1 | classdef TwoPassingTests < TestCase 2 | 3 | methods 4 | function self = TwoPassingTests(name) 5 | self = self@TestCase(name); 6 | end 7 | 8 | function testMethod1(self) 9 | end 10 | 11 | function testMethod2(self) 12 | end 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/WrongExceptionThrownTest.m: -------------------------------------------------------------------------------- 1 | classdef WrongExceptionThrownTest < TestCase 2 | methods 3 | function self = WrongExceptionThrownTest(methodName) 4 | self = self@TestCase(methodName); 5 | end 6 | 7 | function testThrowsException(self) 8 | f = @() error('d:e:f', 'message'); 9 | assertExceptionThrown(f, 'a:b:c'); 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/notTestString.m: -------------------------------------------------------------------------------- 1 | function suite = notTestString 2 | % This function exists to help test that the TestSuite.fromPwd() method does not 3 | % pick up function-handle test files that do not match the naming convention. 4 | initTestSuite; 5 | 6 | function testA 7 | 8 | function testB 9 | 10 | 11 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testFunctionHandlesA.m: -------------------------------------------------------------------------------- 1 | function test_suite = testFunctionHandlesA 2 | %testFunctionHandlesA Test file used by TestFunctionHandlesTest 3 | % Contains two passing tests. 4 | 5 | % Steven L. Eddins 6 | % Copyright 2008 The MathWorks, Inc. 7 | 8 | initTestSuite; 9 | 10 | function testA 11 | 12 | function testB 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testFunctionHandlesB.m: -------------------------------------------------------------------------------- 1 | function test_suite = testFunctionHandlesB 2 | %testFunctionHandlesB Test file used by TestFunctionHandlesTest 3 | % Contains two passing tests that use a test fixture. 4 | 5 | % Steven L. Eddins 6 | % Copyright 2008 The MathWorks, Inc. 7 | 8 | initTestSuite; 9 | 10 | function testData = setUpFcn 11 | testData = 5; 12 | 13 | function testA(testData) 14 | assertEqual(testData, 5); 15 | 16 | function testB(testData) 17 | assertEqual(testData, 5); 18 | 19 | function tearDownFcn(testData) 20 | assertEqual(testData, 5); 21 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testFunctionHandlesC.m: -------------------------------------------------------------------------------- 1 | function test_suite = testFunctionHandlesC 2 | %testFunctionHandlesC Test file used by TestFunctionHandlesTest 3 | % Contains two passing tests that use a test fixture containing an intentional 4 | % error. 5 | 6 | % Steven L. Eddins 7 | % Copyright 2008 The MathWorks, Inc. 8 | 9 | initTestSuite; 10 | 11 | function testData = setUpFcn 12 | testData = 5; 13 | 14 | function testA(testData) 15 | assertEqual(testData, 5); 16 | 17 | function testB(testData) 18 | assertEqual(testData, 5); 19 | 20 | function tearDownFcn(testData) 21 | % This assertion is expected to error. 22 | assertEqual(testData, 20); 23 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testFunctionHandlesD.m: -------------------------------------------------------------------------------- 1 | function test_suite = testFunctionHandlesD 2 | %testFunctionHandlesD Test file used by TestFunctionHandlesTest 3 | % Contains two passing tests that use a test fixture with no test data. 4 | 5 | % Steven L. Eddins 6 | % Copyright 2008 The MathWorks, Inc. 7 | 8 | initTestSuite; 9 | 10 | function setUpFcn 11 | 12 | 13 | function testA(varargin) 14 | assertTrue(isempty(varargin)); 15 | 16 | function testB(varargin) 17 | assertTrue(isempty(varargin)); 18 | 19 | function tearDownFcn(varargin) 20 | assertTrue(isempty(varargin)); 21 | 22 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testFunctionHandlesE.m: -------------------------------------------------------------------------------- 1 | function test_suite = testFunctionHandlesA 2 | %testFunctionHandlesE Test file used by TestFunctionHandlesTest 3 | % Contains one failing test. 4 | 5 | % Steven L. Eddins 6 | % Copyright 2008 The MathWorks, Inc. 7 | 8 | initTestSuite; 9 | 10 | function testA 11 | error('testFunctionHandlesA:expectedFailure', 'Bogus message'); 12 | 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testFunctionHandlesTeardownNoSetup.m: -------------------------------------------------------------------------------- 1 | function suite = testFunctionHandlesTeardownNoSetup 2 | % Verify that test file works if it has a teardown function but no setup 3 | % function. 4 | initTestSuite; 5 | 6 | function teardown 7 | close all 8 | 9 | function test_normalCase 10 | assertEqual(1, 1); 11 | 12 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/helper_classes/testSimple.m: -------------------------------------------------------------------------------- 1 | function testSimple 2 | %testSimple Simple M-file test that passes 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testAssertEqual.m: -------------------------------------------------------------------------------- 1 | function test_suite = testAssertEqual 2 | %testAssertEqual Unit tests for assertEqual 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testAssertEqualHappyCase 10 | assertEqual(5, 5); 11 | 12 | function testAssertEqualWithThreeInputs 13 | assertEqual(5, 5, 'Scandinavian Defense'); 14 | 15 | function testAssertEqualHappyCaseString 16 | assertEqual('foobar', 'foobar'); 17 | 18 | function testAssertEqualHappyCaseMatrix 19 | assertEqual(magic(3), magic(3)) 20 | 21 | function testInfAndInf 22 | assertEqual(Inf, Inf); 23 | 24 | function testMinusInfAndMinusInf 25 | assertEqual(-Inf, -Inf); 26 | 27 | function testOppositeSignInfs 28 | assertExceptionThrown(@() assertEqual(-Inf, Inf), 'assertEqual:nonEqual'); 29 | 30 | function testFiniteAndInf 31 | assertExceptionThrown(@() assertEqual(1, Inf), 'assertEqual:nonEqual'); 32 | 33 | function testFiniteAndNaN 34 | assertExceptionThrown(@() assertEqual(1, NaN), 'assertEqual:nonEqual'); 35 | 36 | function testInfiniteAndNaN 37 | assertExceptionThrown(@() assertEqual(Inf, NaN), 'assertEqual:nonEqual'); 38 | 39 | function testAssertEqualNotEqual 40 | assertExceptionThrown(@() assertEqual(5, 4), 'assertEqual:nonEqual'); 41 | 42 | function testAssertEqualSparsity 43 | assertExceptionThrown(@() assertEqual(5, sparse(5)), 'assertEqual:sparsityNotEqual'); 44 | 45 | function testAssertEqualNans 46 | assertEqual([1 NaN 2], [1 NaN 2]); 47 | 48 | function testAssertEqualClass 49 | assertExceptionThrown(@() assertEqual(5, uint8(5)), 'assertEqual:classNotEqual'); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testAssertExceptionThrown.m: -------------------------------------------------------------------------------- 1 | function test_suite = testAssertExceptionThrown 2 | %testAssertExceptionThrown Unit tests for assertExceptionThrown 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function test_happyCase 10 | assertExceptionThrown(... 11 | @() error('MyProd:MyFun:MyId', 'my message'), 'MyProd:MyFun:MyId'); 12 | 13 | function test_wrongException 14 | assertExceptionThrown(@() assertExceptionThrown(... 15 | @() error('MyProd:MyFun:MyId', 'my message'), ... 16 | 'MyProd:MyFun:DifferentId'), 'assertExceptionThrown:wrongException'); 17 | 18 | function test_noException 19 | assertExceptionThrown(@() assertExceptionThrown(@() sin(pi), 'foobar'), ... 20 | 'assertExceptionThrown:noException'); 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testAssertFalse.m: -------------------------------------------------------------------------------- 1 | function test_suite = testAssertFalse 2 | %testAssertFalse Unit tests for assertFalse 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testAssertFalseHappyCase 10 | assertFalse(false); 11 | 12 | function testAssertFalseHappyCaseWithTwoArgs 13 | assertFalse(false, '1.e4 e5 2.Nf3 Nc6'); 14 | 15 | function testAssertFalseFailed 16 | % Verify exception when false is passed to assertFalse. 17 | assertExceptionThrown(@() assertFalse(true), 'assertFalse:trueCondition'); 18 | 19 | function testAssertFalseNonscalar 20 | % Verify that assertFalse doesn't like nonscalar input. 21 | assertExceptionThrown(@() assertFalse(logical([0 0])), 'assertFalse:invalidCondition'); 22 | 23 | function testAssertFalseNonlogical 24 | % Verify that assertFalse doesn't like nonlogical input. 25 | assertExceptionThrown(@() assertFalse(0), 'assertFalse:invalidCondition'); 26 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testAssertTrue.m: -------------------------------------------------------------------------------- 1 | function test_suite = testAssertTrue 2 | %testAssertTrue Unit tests for assertTrue 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testAssertTrueHappyCase 10 | assertTrue(true); 11 | 12 | function testAssertTrueHappyCaseWithTwoArgs 13 | assertTrue(true, '1.e4 e5 2.Nf3 Nc6'); 14 | 15 | function testAssertTrueFailed 16 | % Verify exception when false is passed to assertTrue. 17 | assertExceptionThrown(@() assertTrue(false), 'assertTrue:falseCondition'); 18 | 19 | function testAssertTrueNonscalar 20 | % Verify that assertTrue doesn't like nonscalar input. 21 | assertExceptionThrown(@() assertTrue(logical([1 1])), 'assertTrue:invalidCondition'); 22 | 23 | function testAssertTrueNonlogical 24 | % Verify that assertTrue doesn't like nonlogical input. 25 | assertExceptionThrown(@() assertTrue(5), 'assertTrue:invalidCondition'); 26 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testContainsRegexp.m: -------------------------------------------------------------------------------- 1 | function test_suite = testContainsRegexp 2 | %testContainsRegexp Unit tests for containsRegexp 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testOneStringContains 10 | assertTrue(xunit.utils.containsRegexp('MATLAB is great', '[A-Z]')); 11 | 12 | function testOneStringDoesntContain 13 | assertTrue(~ xunit.utils.containsRegexp('no upper-case letters', '[A-Z]')); 14 | 15 | function testCellArray 16 | strs = {'MATLAB is great', 'no upper-case letters'}; 17 | assertEqual(xunit.utils.containsRegexp(strs, '[A-Z]'), [true false]); 18 | assertEqual(xunit.utils.containsRegexp(strs', '[A-Z]'), [true; false]); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testIsSetUpString.m: -------------------------------------------------------------------------------- 1 | function test_suite = testIsSetUpString 2 | %testIsSetUpString Unit tests for isSetUpString 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testOneStringIs 10 | assertTrue(xunit.utils.isSetUpString('setup')); 11 | assertTrue(xunit.utils.isSetUpString('setUp_fixture')); 12 | 13 | function testOneStringIsNot 14 | assertFalse(xunit.utils.isSetUpString('bogus')); 15 | 16 | function testCellArray 17 | strs = {'setup', 'bogus'}; 18 | assertEqual(xunit.utils.isSetUpString(strs), [true false]); 19 | assertEqual(xunit.utils.isSetUpString(strs'), [true; false]); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testIsTearDownString.m: -------------------------------------------------------------------------------- 1 | function test_suite = testIsTearDownString 2 | %testIsTearDownString Unit tests for isTearDownString 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testOneStringIs 10 | assertTrue(xunit.utils.isTearDownString('teardownfoobar')); 11 | assertTrue(xunit.utils.isTearDownString('TearDown_foobar')); 12 | 13 | function testOneStringIsNot 14 | assertFalse(xunit.utils.isTearDownString('tEardown')); 15 | 16 | function testCellArray 17 | strs = {'teardown', 'tearup'}; 18 | assertEqual(xunit.utils.isTearDownString(strs), [true false]); 19 | assertEqual(xunit.utils.isTearDownString(strs'), [true; false]); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testIsTestCaseSubclass.m: -------------------------------------------------------------------------------- 1 | function test_suite = testIsTestCaseSubclass 2 | %testIsTestCaseSubclass Unit tests for isTestCaseSubclass 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testTestCase 10 | assertTrue(xunit.utils.isTestCaseSubclass('TestCase')); 11 | 12 | function testSubclass 13 | assertTrue(xunit.utils.isTestCaseSubclass('TestCaseInDir')); 14 | 15 | function testNotASubclass 16 | assertFalse(xunit.utils.isTestCaseSubclass('atan2')); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testIsTestString.m: -------------------------------------------------------------------------------- 1 | function test_suite = testIsTestString 2 | %testIsTestString Unit tests for isTestString 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function testOneStringIs 10 | assertTrue(xunit.utils.isTestString('testFoobar')); 11 | assertTrue(xunit.utils.isTestString('Test_foobar')); 12 | 13 | function testOneStringIsNot 14 | assertFalse(xunit.utils.isTestString('foobar')); 15 | 16 | function testCellArray 17 | strs = {'testFoobar', 'foobar_test', 'foobar', 'foobar_Test'}; 18 | assertEqual(xunit.utils.isTestString(strs), [true true false true]); 19 | assertEqual(xunit.utils.isTestString(strs'), [true; true; false; true]); -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/testRuntestsWithDirectoryName.m: -------------------------------------------------------------------------------- 1 | function test_suite = testRuntestsWithDirectoryName 2 | %testRuntestsWithDirectoryName Unit test for mtest('dirname') syntax. 3 | 4 | initTestSuite; 5 | 6 | function testDirName 7 | current_dir = pwd; 8 | target_dir = fullfile(fileparts(which(mfilename)), 'cwd_test'); 9 | [T, did_pass] = evalc('runtests(target_dir)'); 10 | assertFalse(did_pass); 11 | assertEqual(current_dir, pwd); 12 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_TestSuiteInDir.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_TestSuiteInDir 2 | %test_TestSuiteInDir Unit test for TestSuiteInDir class. 3 | 4 | % Steven L. Eddins 5 | % Copyright 2009 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function test_constructor 10 | this_test_path = fileparts(which(mfilename)); 11 | cwd_test_dir = fullfile(this_test_path, 'cwd_test'); 12 | suite = TestSuiteInDir(cwd_test_dir); 13 | 14 | assertEqual(suite.Name, 'cwd_test'); 15 | assertEqual(suite.Location, cwd_test_dir); 16 | 17 | function test_gatherTestCases 18 | this_test_path = fileparts(which(mfilename)); 19 | cwd_test_dir = fullfile(this_test_path, 'cwd_test'); 20 | suite = TestSuiteInDir(cwd_test_dir); 21 | suite.gatherTestCases(); 22 | 23 | assertEqual(numel(suite.TestComponents), 3); 24 | 25 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_arrayToString.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_arrayToString 2 | %test_arrayToString Unit test for arrayToString. 3 | 4 | % Steven L. Eddins 5 | % Copyright 2009 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function test_smallInput 10 | A = [1 2 3]; 11 | assertEqual(strtrim(xunit.utils.arrayToString(A)), '1 2 3'); 12 | 13 | function test_largeInput 14 | A = zeros(1000, 1000); 15 | assertEqual(xunit.utils.arrayToString(A), '[1000x1000 double]'); 16 | 17 | function test_emptyInput 18 | assertEqual(xunit.utils.arrayToString(zeros(1,0,2)), '[1x0x2 double]'); 19 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_assertElementsAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function suite = test_assertElementsAlmostEqual 2 | initTestSuite; 3 | 4 | %=============================================================================== 5 | function test_happyCase 6 | 7 | % All code here should execute with no error. 8 | assertElementsAlmostEqual(1, 1 + sqrt(eps)/10); 9 | assertElementsAlmostEqual(1, 1 + sqrt(eps)/10, 'custom message'); 10 | 11 | %=============================================================================== 12 | function test_failedAssertion 13 | 14 | f = @() assertElementsAlmostEqual(1, 1 + 10*sqrt(eps)); 15 | assertExceptionThrown(f, 'assertElementsAlmostEqual:tolExceeded'); 16 | 17 | %=============================================================================== 18 | function test_nonFloatInputs() 19 | assertExceptionThrown(@() assertElementsAlmostEqual('hello', 'world'), ... 20 | 'assertElementsAlmostEqual:notFloat'); 21 | 22 | %=============================================================================== 23 | function test_sizeMismatch() 24 | assertExceptionThrown(@() assertElementsAlmostEqual(1, [1 2]), ... 25 | 'assertElementsAlmostEqual:sizeMismatch'); 26 | 27 | function test_finiteAndInfinite() 28 | assertExceptionThrown(@() assertElementsAlmostEqual(1, Inf), ... 29 | 'assertElementsAlmostEqual:tolExceeded'); 30 | 31 | function test_infiniteAndInfinite() 32 | assertElementsAlmostEqual(Inf, Inf); 33 | 34 | function test_finiteAndNaN() 35 | assertExceptionThrown(@() assertElementsAlmostEqual(1, NaN), ... 36 | 'assertElementsAlmostEqual:tolExceeded'); 37 | 38 | function test_nanAndNaN() 39 | assertElementsAlmostEqual(NaN, NaN); 40 | 41 | function test_plusMinusInfinity() 42 | assertExceptionThrown(@() assertElementsAlmostEqual(+Inf, -Inf), ... 43 | 'assertElementsAlmostEqual:tolExceeded'); 44 | 45 | function test_infiniteAndNaN() 46 | assertExceptionThrown(@() assertElementsAlmostEqual(Inf, NaN), ... 47 | 'assertElementsAlmostEqual:tolExceeded'); 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_assertFilesEqual.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_assertFilesEqual 2 | %test_assertFilesEqual Unit test for assertFilesEqual 3 | 4 | % Steven L. Eddins 5 | % Copyright 2009 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function test_equal 10 | assertFilesEqual('black.tif', 'black.tif'); 11 | 12 | function test_differentSize 13 | assertExceptionThrown(@() assertFilesEqual('black.tif', 'black.png'), ... 14 | 'assertFilesEqual:sizeMismatch'); 15 | 16 | function test_sameSizeButDifferent 17 | assertExceptionThrown(@() assertFilesEqual('black.tif', 'almost_black.tif'), ... 18 | 'assertFilesEqual:valuesDiffer'); 19 | 20 | function test_oneFileEmpty 21 | assertExceptionThrown(@() assertFilesEqual('empty_file', 'black.png'), ... 22 | 'assertFilesEqual:sizeMismatch'); 23 | 24 | function test_bothFilesEmpty 25 | assertFilesEqual('empty_file', 'empty_file'); 26 | 27 | function test_cannotReadFirstFile 28 | assertExceptionThrown(@() assertFilesEqual('bogus', 'black.png'), ... 29 | 'assertFilesEqual:readFailure'); 30 | 31 | function test_cannotReadSecondFile 32 | assertExceptionThrown(@() assertFilesEqual('black.png', 'bogus'), ... 33 | 'assertFilesEqual:readFailure'); 34 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_comparisonMessage.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_comparisonMessage 2 | %test_comparisonMessage Unit test for comparisonMessage. 3 | 4 | % Steven L. Eddins 5 | % Copyright 2009 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function test_happyCase 10 | s = xunit.utils.comparisonMessage('user message', 'assertion message', ... 11 | [1 2 3], 'hello'); 12 | c = xunit.utils.stringToCellArray(s); 13 | 14 | expected_output = { 'user message' 15 | 'assertion message' 16 | '' 17 | 'First input:' 18 | ' 1 2 3' 19 | '' 20 | 'Second input:' 21 | 'hello'}; 22 | 23 | assertEqual(c, expected_output); 24 | 25 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_packageName.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_packageName 2 | initTestSuite; 3 | 4 | function test_happyCase 5 | suite = TestSuite.fromPackageName('xunit.mocktests'); 6 | assertEqual(numel(suite.TestComponents), 5); 7 | 8 | assertEqual(numel(suite.TestComponents{1}.TestComponents), 1); 9 | assertEqual(suite.TestComponents{1}.Name, 'xunit.mocktests.subpkg'); 10 | 11 | assertEqual(numel(suite.TestComponents{2}.TestComponents), 2); 12 | assertEqual(suite.TestComponents{2}.Name, 'xunit.mocktests.A'); 13 | 14 | assertEqual(numel(suite.TestComponents{3}.TestComponents), 1); 15 | assertEqual(suite.TestComponents{3}.Name, 'xunit.mocktests.FooTest'); 16 | 17 | assertEqual(numel(suite.TestComponents{4}.TestComponents), 2); 18 | assertEqual(suite.TestComponents{4}.Name, 'test_that'); 19 | 20 | assertEqual(numel(suite.TestComponents{5}.TestComponents), 1); 21 | assertEqual(suite.TestComponents{5}.Name, 'xunit.mocktests.test_this'); 22 | 23 | function test_badPackageName 24 | assertExceptionThrown(@() TestSuite.fromPackageName('bogus'), ... 25 | 'xunit:fromPackageName:invalidName'); 26 | 27 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/tests/test_stringToCellArray.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_stringToCellArray 2 | %test_stringToCellArray Unit test for stringToCellArray 3 | 4 | % Steven L. Eddins 5 | % Copyright 2009 The MathWorks, Inc. 6 | 7 | initTestSuite; 8 | 9 | function test_happyCase 10 | s = sprintf('Hello\nWorld'); 11 | assertEqual(xunit.utils.stringToCellArray(s), {'Hello' ; 'World'}); 12 | 13 | function test_emptyInput 14 | assertEqual(xunit.utils.stringToCellArray(''), cell(0, 1)); 15 | 16 | function test_spacesInFront 17 | s = sprintf(' Hello\n World\n'); 18 | assertEqual(xunit.utils.stringToCellArray(s), {' Hello' ; ' World'}); 19 | 20 | function test_spacesAtEnd 21 | s = sprintf('Hello \nWorld '); 22 | assertEqual(xunit.utils.stringToCellArray(s), {'Hello ' ; 'World '}); 23 | 24 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/Contents.m: -------------------------------------------------------------------------------- 1 | % UTILS Utility package for MATLAB xUnit Test Framework 2 | % 3 | % Array Comparison 4 | % compareFloats - Compare floating-point arrays using tolerance 5 | % 6 | % Test Case Discovery Functions 7 | % isTestCaseSubclass - True for name of TestCase subclass 8 | % 9 | % String Functions 10 | % arrayToString - Convert array to string for display 11 | % comparisonMessage - Assertion message string for comparing two arrays 12 | % containsRegexp - True if string contains regular expression 13 | % isSetUpString - True for string that looks like a setup function 14 | % isTearDownString - True for string that looks like teardown function 15 | % isTestString - True for string that looks like a test function 16 | % stringToCellArray - Convert string to cell array of strings 17 | % 18 | % Miscellaneous Functions 19 | % generateDoc - Publish test scripts in mtest/doc 20 | % parseFloatAssertInputs - Common input-parsing logic for several functions 21 | 22 | % Steven L. Eddins 23 | % Copyright 2008-2009 The MathWorks, Inc. 24 | 25 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/comparisonMessage.m: -------------------------------------------------------------------------------- 1 | function msg = comparisonMessage(user_message, assertion_message, A, B) 2 | %comparisonMessage Generate assertion message when comparing two arrays. 3 | % msg = comparisonMessage(user_message, assertion_message, A, B) returns a 4 | % string appropriate to use in a call to throw inside an assertion function 5 | % that compares two arrays A and B. 6 | % 7 | % The string returned has the following form: 8 | % 9 | % 10 | % 11 | % 12 | % First input: 13 | % 14 | % 15 | % Second input: 16 | % 17 | % 18 | % user_message can be the empty string, '', in which case user_message is 19 | % skipped. 20 | 21 | % Steven L. Eddins 22 | % Copyright 2009 The MathWorks, Inc. 23 | 24 | msg = sprintf('%s\n\n%s\n%s\n\n%s\n%s', ... 25 | assertion_message, ... 26 | 'First input:', ... 27 | xunit.utils.arrayToString(A), ... 28 | 'Second input:', ... 29 | xunit.utils.arrayToString(B)); 30 | 31 | if ~isempty(user_message) 32 | msg = sprintf('%s\n%s', user_message, msg); 33 | end 34 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/containsRegexp.m: -------------------------------------------------------------------------------- 1 | function tf = containsRegexp(str, exp) 2 | %containsRegexp True if string contains regular expression 3 | % TF = containsRegexp(str, exp) returns true if the string str contains the 4 | % regular expression exp. If str is a cell array of strings, then 5 | % containsRegexp tests each string in the cell array, returning the results in 6 | % a logical array with the same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | % Convert to canonical input form: A cell array of strings. 12 | if ~iscell(str) 13 | str = {str}; 14 | end 15 | 16 | matches = regexp(str, exp); 17 | tf = ~cellfun('isempty', matches); 18 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/generateDoc.m: -------------------------------------------------------------------------------- 1 | function generateDoc 2 | %generateDoc Publish the example scripts in the doc directory 3 | 4 | % Steven L. Eddins 5 | % Copyright 2008-2009 The MathWorks, Inc. 6 | 7 | doc_dir = fullfile(fileparts(which('runtests')), '..', 'doc'); 8 | addpath(doc_dir); 9 | cd(doc_dir) 10 | mfiles = dir('*.m'); 11 | for k = 1:numel(mfiles) 12 | publish(mfiles(k).name); 13 | cd(doc_dir) 14 | end 15 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/isAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function same = isAlmostEqual(A, B, reltol) 2 | %isAlmostEqual Equality test using relative tolerance 3 | % same = isAlmostEqual(A, B, reltol), for two floating-point arrays A and B, 4 | % tests A and B for equality using the specified relative tolerance. 5 | % isAlmostEqual returns true if the following relationship is satisfied for 6 | % all values in A and B: 7 | % 8 | % abs(A - B) ./ max(abs(A), abs(B)) <= reltol 9 | % 10 | % same = isAlmostEqual(A, B) uses the following value for the relative 11 | % tolerance: 12 | % 13 | % 100 * max(eps(class(A)), eps(class(B))) 14 | % 15 | % If either A or B is not a floating-point array, then isAlmostEqual returns 16 | % the result of isequal(A, B). 17 | 18 | % Steven L. Eddins 19 | % Copyright 2008-2009 The MathWorks, Inc. 20 | 21 | if ~isfloat(A) || ~isfloat(B) 22 | same = isequal(A, B); 23 | return 24 | end 25 | 26 | if nargin < 3 27 | reltol = 100 * max(eps(class(A)), eps(class(B))); 28 | end 29 | 30 | if ~isequal(size(A), size(B)) 31 | same = false; 32 | return 33 | end 34 | 35 | A = A(:); 36 | B = B(:); 37 | 38 | delta = abs(A - B) ./ max(max(abs(A), abs(B)), 1); 39 | 40 | % Some floating-point values require special handling. 41 | delta((A == 0) & (B == 0)) = 0; 42 | delta(isnan(A) & isnan(B)) = 0; 43 | delta((A == Inf) & (B == Inf)) = 0; 44 | delta((A == -Inf) & (B == -Inf)) = 0; 45 | 46 | same = all(delta <= reltol); 47 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/isSetUpString.m: -------------------------------------------------------------------------------- 1 | function tf = isSetUpString(str) 2 | %isSetUpString True if string looks like the name of a setup function 3 | % tf = isSetUpString(str) returns true if the string str looks like the name 4 | % of a setup function. If str is a cell array of strings, then isSetUpString 5 | % tests each string in the cell array, returning the results in a logical 6 | % array with the same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | setup_exp = '^[sS]et[uU]p'; 12 | tf = xunit.utils.containsRegexp(str, setup_exp); 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/isTearDownString.m: -------------------------------------------------------------------------------- 1 | function tf = isTearDownString(str) 2 | %isTearDownString True if string looks like the name of a teardown function 3 | % tf = isTearDownString(str) returns true if the string str looks like the 4 | % name of a teardown function. If str is a cell array of strings, then 5 | % isTearDownString tests each string in the cell array, returning the results 6 | % in a logical array with the same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | setup_exp = '^[tT]ear[dD]own'; 12 | tf = xunit.utils.containsRegexp(str, setup_exp); 13 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/isTestCaseSubclass.m: -------------------------------------------------------------------------------- 1 | function tf = isTestCaseSubclass(name) 2 | %isTestCaseSubclass True for name of a TestCase subclass 3 | % tf = isTestCaseSubclass(name) returns true if the string name is the name of 4 | % a TestCase subclass on the MATLAB path. 5 | 6 | % Steven L. Eddins 7 | % Copyright 2008-2009 The MathWorks, Inc. 8 | 9 | tf = false; 10 | 11 | class_meta = meta.class.fromName(name); 12 | if isempty(class_meta) 13 | % Not the name of a class 14 | return; 15 | end 16 | 17 | if strcmp(class_meta.Name, 'TestCase') 18 | tf = true; 19 | else 20 | tf = isMetaTestCaseSubclass(class_meta); 21 | end 22 | 23 | function tf = isMetaTestCaseSubclass(class_meta) 24 | 25 | tf = false; 26 | 27 | if strcmp(class_meta.Name, 'TestCase') 28 | tf = true; 29 | else 30 | % Invoke function recursively on parent classes. 31 | super_classes = class_meta.SuperClasses; 32 | for k = 1:numel(super_classes) 33 | if isMetaTestCaseSubclass(super_classes{k}) 34 | tf = true; 35 | break; 36 | end 37 | end 38 | end 39 | 40 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/isTestString.m: -------------------------------------------------------------------------------- 1 | function tf = isTestString(str) 2 | %isTestString True if string looks like the name of a test 3 | % tf = isTestString(str) returns true if the string str looks like the name of 4 | % a test. If str is a cell array of strings, then isTestString tests each 5 | % string in the cell array, returning the results in a logical array with the 6 | % same size as str. 7 | 8 | % Steven L. Eddins 9 | % Copyright 2008-2009 The MathWorks, Inc. 10 | 11 | test_at_beginning = '^[tT]est'; 12 | test_at_end = '[tT]est$'; 13 | 14 | tf = xunit.utils.containsRegexp(str, test_at_beginning) | ... 15 | xunit.utils.containsRegexp(str, test_at_end); 16 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/parseFloatAssertInputs.m: -------------------------------------------------------------------------------- 1 | function params = parseFloatAssertInputs(varargin) 2 | %parseFloatAssertInputs Parse inputs for floating-point assertion functions. 3 | % params = parseFloatAssertInputs(varargin) parses the input arguments for 4 | % assertElementsAlmostEqual, assertVectorsAlmostEqual, and compareFcn. It 5 | % returns a parameter struct containing the fields: 6 | % 7 | % A B Message ToleranceType Tolerance FloorTolerance 8 | 9 | % Steven L. Eddins 10 | % Copyright 2008-2009 The MathWorks, Inc. 11 | 12 | error(nargchk(2, 6, nargin, 'struct')); 13 | 14 | params = struct('A', {[]}, 'B', {[]}, 'ToleranceType', {[]}, ... 15 | 'Tolerance', {[]}, 'FloorTolerance', {[]}, 'Message', {''}); 16 | 17 | % The first two input arguments are always A and B. 18 | params.A = varargin{1}; 19 | params.B = varargin{2}; 20 | varargin(1:2) = []; 21 | 22 | % If the last argument is a message string, process it and remove it from the list. 23 | if (numel(varargin) >= 1) && ischar(varargin{end}) && ... 24 | ~any(strcmp(varargin{end}, {'relative', 'absolute'})) 25 | params.Message = varargin{end}; 26 | varargin(end) = []; 27 | else 28 | params.Message = ''; 29 | end 30 | 31 | try 32 | epsilon = max(eps(class(params.A)), eps(class(params.B))); 33 | catch 34 | epsilon = eps; 35 | end 36 | 37 | if numel(varargin) < 3 38 | % floor_tol not specified; set default. 39 | params.FloorTolerance = sqrt(epsilon); 40 | else 41 | params.FloorTolerance = varargin{3}; 42 | end 43 | 44 | if numel(varargin) < 2 45 | % tol not specified; set default. 46 | params.Tolerance = sqrt(epsilon); 47 | else 48 | params.Tolerance = varargin{2}; 49 | end 50 | 51 | if numel(varargin) < 1 52 | % tol_type not specified; set default. 53 | params.ToleranceType = 'relative'; 54 | else 55 | params.ToleranceType = varargin{1}; 56 | end 57 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/+xunit/+utils/stringToCellArray.m: -------------------------------------------------------------------------------- 1 | function c = stringToCellArray(s) 2 | %stringToCellArray Convert string with newlines to cell array of strings. 3 | % C = stringToCellArray(S) converts the input string S to a cell array of 4 | % strings, breaking up S at new lines. 5 | 6 | % Steven L. Eddins 7 | % Copyright 2009 The MathWorks, Inc. 8 | 9 | if isempty(s) 10 | c = cell(0, 1); 11 | else 12 | c = textscan(s, '%s', 'Delimiter', '\n', 'Whitespace', ''); 13 | c = c{1}; 14 | end 15 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/CommandWindowTestRunDisplay.m: -------------------------------------------------------------------------------- 1 | classdef CommandWindowTestRunDisplay < TestRunDisplay 2 | %CommandWindowTestRunDisplay Print test suite execution results to Command Window. 3 | % CommandWindowTestRunDisplay is a subclass of TestRunMonitor. If a 4 | % CommandWindowTestRunDisplay object is passed to the run method of a 5 | % TestComponent, such as a TestSuite or a TestCase, it will print information 6 | % to the Command Window as the test run proceeds. 7 | % 8 | % CommandWindowTestRunDisplay methods: 9 | % testComponentStarted - Update Command Window display 10 | % testComponentFinished - Update Command Window display 11 | % testCaseFailure - Log test failure information 12 | % testCaseError - Log test error information 13 | % 14 | % CommandWindowTestRunDisplay properties: 15 | % TestCaseCount - Number of test cases executed 16 | % Faults - Struct array of test fault info 17 | % 18 | % See also TestRunLogger, TestRunMonitor, TestSuite 19 | 20 | % Steven L. Eddins 21 | % Copyright 2008-2010 The MathWorks, Inc. 22 | 23 | methods 24 | function self = CommandWindowTestRunDisplay 25 | self = self@TestRunDisplay(1); 26 | end 27 | end 28 | 29 | end 30 | 31 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/Contents.m: -------------------------------------------------------------------------------- 1 | % MATLAB xUnit Test Framework 2 | % Version 3.1 (R2010b) 19-Nov-2010 3 | % 4 | % Running Unit Tests 5 | % runtests - Run unit tests 6 | % 7 | % Writing Unit Tests 8 | % assertElementsAlmostEqual - Assert floating-point array elements almost equal 9 | % assertEqual - Assert that inputs are equal 10 | % assertFilesEqual - Assert that two files have the same content 11 | % assertExceptionThrown - Assert that specified exception is thrown 12 | % assertFalse - Assert that input condition is false 13 | % assertTrue - Assert that input condition is true 14 | % assertVectorsAlmostEqual - Assert floating-point vectors almost equal in norm sense 15 | % initTestSuite - Utility script used for subfunction-based tests 16 | % 17 | % Framework Classes 18 | % CommandWindowTestRunDisplay - Print test suite results to command window 19 | % FunctionHandleTestCase - Test case based on a function handle 20 | % TestCase - Class defining interface for test cases 21 | % TestCaseInDir - Test case requiring temporary directory change 22 | % TestCaseWithAddPath - Test case requiring temporary path modification 23 | % TestComponent - Abstract base class for TestCase and TestSuite 24 | % TestComponentInDir - Test component requiring temporary directory change 25 | % TestLogger - Collect data (silently) from running test suite 26 | % TestRunDisplay - Print test suite execution results 27 | % TestRunMonitor - Abstract base class for monitoring test suite 28 | % TestSuite - Collection of TestComponent objects 29 | % TestSuiteInDir - Test suite requiring temporary directory change 30 | % %VerboseTestRunDisplay - Print test suite execution results 31 | 32 | % Steven L. Eddins 33 | % Copyright 2008-2010 The MathWorks, Inc. -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/TestCaseInDir.m: -------------------------------------------------------------------------------- 1 | %TestCaseInDir Test case requiring temporary directory change 2 | % The TestCaseInDir class defines a test case that has to be run by first 3 | % changing to a specified directory. 4 | % 5 | % The setUp method adds the starting directory to the path and then uses cd to 6 | % change into the specified directory. The tearDown method restores the 7 | % original path and directory. 8 | % 9 | % TestCaseInDir is used by MATLAB xUnit's own test suite in order to test itself. 10 | % 11 | % TestCaseInDir methods: 12 | % TestCaseInDir - Constructor 13 | % 14 | % See also TestCase, TestCaseWithAddPath, TestComponent 15 | 16 | % Steven L. Eddins 17 | % Copyright 2008-2009 The MathWorks, Inc. 18 | 19 | classdef TestCaseInDir < TestCase & TestComponentInDir 20 | 21 | methods 22 | function self = TestCaseInDir(methodName, testDirectory) 23 | %TestCaseInDir Constructor 24 | % TestCaseInDir(testName, testDirectory) constructs a test case 25 | % using the specified name and located in the specified directory. 26 | self = self@TestCase(methodName); 27 | self = self@TestComponentInDir(testDirectory); 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/TestRunMonitor.m: -------------------------------------------------------------------------------- 1 | %TestRunMonitor Abstract base class for monitoring a running test suite 2 | % The abstract TestRunMonitor class defines an object that can observe and 3 | % record the results of running a test suite. The run() method of a 4 | % TestComponent object takes a TestRunMonitor object as an input argument. 5 | % 6 | % Different test suite logging or reporting functionality can be achieved by 7 | % subclassing TestRunMonitor. For example, see the TestRunLogger and the 8 | % CommandWindowTestRunDisplay classes. 9 | % 10 | % TestRunMonitor methods: 11 | % TestRunMonitor - Constructor 12 | % testComponentStarted - Called at beginning of test component run 13 | % testComponentFinished - Called when test component run finished 14 | % testCaseFailure - Called when a test case fails 15 | % testCaseError - Called when a test case causes an error 16 | % 17 | % See also CommandWindowTestRunDisplay, TestRunLogger, TestCase, TestSuite 18 | 19 | % Steven L. Eddins 20 | % Copyright 2008-2009 The MathWorks, Inc. 21 | 22 | classdef TestRunMonitor < handle 23 | 24 | methods (Abstract) 25 | 26 | testComponentStarted(self, component) 27 | 28 | testComponentFinished(self, component, did_pass) 29 | 30 | testCaseFailure(self, test_case, failure_exception) 31 | 32 | testCaseError(self, test_case, error_exception) 33 | 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/assertEqual.m: -------------------------------------------------------------------------------- 1 | function assertEqual(A, B, custom_message) 2 | %assertEqual Assert that inputs are equal 3 | % assertEqual(A, B) throws an exception if A and B are not equal. A and B 4 | % must have the same class and sparsity to be considered equal. 5 | % 6 | % assertEqual(A, B, MESSAGE) prepends the string MESSAGE to the assertion 7 | % message if A and B are not equal. 8 | % 9 | % Examples 10 | % -------- 11 | % % This call returns silently. 12 | % assertEqual([1 NaN 2], [1 NaN 2]); 13 | % 14 | % % This call throws an error. 15 | % assertEqual({'A', 'B', 'C'}, {'A', 'foo', 'C'}); 16 | % 17 | % See also assertElementsAlmostEqual, assertVectorsAlmostEqual 18 | 19 | % Steven L. Eddins 20 | % Copyright 2008-2010 The MathWorks, Inc. 21 | 22 | if nargin < 3 23 | custom_message = ''; 24 | end 25 | 26 | if ~ (issparse(A) == issparse(B)) 27 | message = xunit.utils.comparisonMessage(custom_message, ... 28 | 'One input is sparse and the other is not.', A, B); 29 | throwAsCaller(MException('assertEqual:sparsityNotEqual', '%s', message)); 30 | end 31 | 32 | if ~strcmp(class(A), class(B)) 33 | message = xunit.utils.comparisonMessage(custom_message, ... 34 | 'The inputs differ in class.', A, B); 35 | throwAsCaller(MException('assertEqual:classNotEqual', '%s', message)); 36 | end 37 | 38 | if ~isequalwithequalnans(A, B) 39 | message = xunit.utils.comparisonMessage(custom_message, ... 40 | 'Inputs are not equal.', A, B); 41 | throwAsCaller(MException('assertEqual:nonEqual', '%s', message)); 42 | end 43 | 44 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/assertFalse.m: -------------------------------------------------------------------------------- 1 | function assertFalse(condition, message) 2 | %assertFalse Assert that input condition is false 3 | % assertFalse(CONDITION, MESSAGE) throws an exception containing the string 4 | % MESSAGE if CONDITION is not false. 5 | % 6 | % MESSAGE is optional. 7 | % 8 | % Examples 9 | % -------- 10 | % assertFalse(isreal(sqrt(-1))) 11 | % 12 | % assertFalse(isreal(sqrt(-1)), ... 13 | % 'Expected isreal(sqrt(-1)) to be false.') 14 | % 15 | % See also assertTrue 16 | 17 | % Steven L. Eddins 18 | % Copyright 2008-2010 The MathWorks, Inc. 19 | 20 | if nargin < 2 21 | message = 'Asserted condition is not false.'; 22 | end 23 | 24 | if ~isscalar(condition) || ~islogical(condition) 25 | throwAsCaller(MException('assertFalse:invalidCondition', ... 26 | 'CONDITION must be a scalar logical value.')); 27 | end 28 | 29 | if condition 30 | throwAsCaller(MException('assertFalse:trueCondition', '%s', message)); 31 | end 32 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/assertTrue.m: -------------------------------------------------------------------------------- 1 | function assertTrue(condition, message) 2 | %assertTrue Assert that input condition is true 3 | % assertTrue(CONDITION, MESSAGE) throws an exception containing the string 4 | % MESSAGE if CONDITION is not true. 5 | % 6 | % MESSAGE is optional. 7 | % 8 | % Examples 9 | % -------- 10 | % % This call returns silently. 11 | % assertTrue(rand < 1, 'Expected output of rand to be less than 1') 12 | % 13 | % % This call throws an error. 14 | % assertTrue(sum(sum(magic(3))) == 0, ... 15 | % 'Expected sum of elements of magic(3) to be 0') 16 | % 17 | % See also assertEqual, assertFalse 18 | 19 | % Steven L. Eddins 20 | % Copyright 2008-2010 The MathWorks, Inc. 21 | 22 | if nargin < 2 23 | message = 'Asserted condition is not true.'; 24 | end 25 | 26 | if ~isscalar(condition) || ~islogical(condition) 27 | throwAsCaller(MException('assertTrue:invalidCondition', ... 28 | 'CONDITION must be a scalar logical value.')); 29 | end 30 | 31 | if ~condition 32 | throwAsCaller(MException('assertTrue:falseCondition', '%s', message)); 33 | end 34 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/info.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | R2009a 7 | MATLAB xUnit Test Framework 8 | Other 9 | $toolbox/matlab/icons/matlabicon.gif 10 | ../doc/ 11 | 12 | 13 | 14 | 15 | 16 | doc xunit 17 | $toolbox/matlab/icons/book_mat.gif 18 | 19 | 20 | 21 | 22 | web http://www.mathworks.com/matlabcentral/fileexchange/22846 -browser; 23 | $toolbox/matlab/icons/webicon.gif 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/matlab_xunit/xunit/initTestSuite.m: -------------------------------------------------------------------------------- 1 | %findSubfunctionTests Utility script used for subfunction-based tests 2 | % This file is a script that is called at the top of M-files containing 3 | % subfunction-based tests. 4 | % 5 | % The top of a typical M-file using this script looks like this: 6 | % 7 | % function test_suite = testFeatureA 8 | % 9 | % findSubfunctionTests; 10 | % 11 | % IMPORTANT NOTE 12 | % -------------- 13 | % The output variable name for an M-file using this script must be test_suite. 14 | 15 | % Steven L. Eddins 16 | % Copyright 2008-2009 The MathWorks, Inc. 17 | 18 | [ST,I] = dbstack('-completenames'); 19 | caller_name = ST(I + 1).name; 20 | caller_file = ST(I + 1).file; 21 | subFcns = which('-subfun', caller_file); 22 | 23 | setup_fcn_name = subFcns(xunit.utils.isSetUpString(subFcns)); 24 | if numel(setup_fcn_name) > 1 25 | error('findSubfunctionTests:tooManySetupFcns', ... 26 | 'Found more than one setup subfunction.') 27 | elseif isempty(setup_fcn_name) 28 | setup_fcn = []; 29 | else 30 | setup_fcn = str2func(setup_fcn_name{1}); 31 | end 32 | 33 | teardown_fcn_name = subFcns(xunit.utils.isTearDownString(subFcns)); 34 | if numel(teardown_fcn_name) > 1 35 | error('findSubfunctionTests:tooManyTeardownFcns', ... 36 | 'Found more than one teardown subfunction.') 37 | elseif isempty(teardown_fcn_name) 38 | teardown_fcn = []; 39 | else 40 | teardown_fcn = str2func(teardown_fcn_name{1}); 41 | end 42 | 43 | test_fcns = cellfun(@str2func, subFcns(xunit.utils.isTestString(subFcns)), ... 44 | 'UniformOutput', false); 45 | 46 | suite = TestSuite; 47 | suite.Name = caller_name; 48 | suite.Location = which(caller_file); 49 | for k = 1:numel(test_fcns) 50 | suite.add(FunctionHandleTestCase(test_fcns{k}, setup_fcn, teardown_fcn)); 51 | end 52 | 53 | if nargout > 0 54 | test_suite = suite; 55 | else 56 | suite.run(); 57 | end 58 | 59 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/assertEqual.m: -------------------------------------------------------------------------------- 1 | function [] = assertEqual(a, b) 2 | if (a != b) 3 | testFailed; 4 | end 5 | 6 | function [] = testFailed() 7 | [ST, I] = dbstack(2); 8 | disp(strcat("FAILED: ", ST(1).name)); 9 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/assertVectorsAlmostEqual.m: -------------------------------------------------------------------------------- 1 | function [] = assertVectorsAlmostEqual(a, b, comparetype, tolerance) 2 | if (max(abs(reshape(a-b,[],1))) > tolerance) 3 | testFailed(a,b); 4 | elseif (min(size(a) == size(b)) < 1) 5 | testFailed(a,b); 6 | end 7 | 8 | function [] = testFailed(a, b) 9 | [ST, I] = dbstack(2); 10 | disp(strcat("FAILED: ", ST(1).name)); 11 | disp(a) 12 | disp("--") 13 | disp(b) 14 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/runtests.m: -------------------------------------------------------------------------------- 1 | path('../../bin', path) 2 | test_mdwt 3 | test_midwt 4 | test_mirdwt 5 | test_mrdwt 6 | test_makesig 7 | test_denoise 8 | test_setopt 9 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/test_mdwt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_mdwt 2 | disp("mdwt") 3 | test_mdwt_1D 4 | test_mdwt_2D 5 | test_mdwt_compute_L1 6 | test_mdwt_compute_L2 7 | test_mdwt_compute_L3 8 | 9 | function test_mdwt_1D 10 | x = makesig('LinChirp', 8); 11 | h = daubcqf(4, 'min'); 12 | L = 2; % For 8 values in x we would normally be L=2 13 | [y, L] = mdwt(x, h, L); 14 | y_corr = [1.1097 0.8767 0.8204 -0.5201 -0.0339 0.1001 0.2201 -0.1401]; 15 | L_corr = 2; 16 | assertVectorsAlmostEqual(y, y_corr, 'relative', 0.001); 17 | assertEqual(L, L_corr); 18 | 19 | function test_mdwt_2D 20 | x = [1 2 3 4; 5 6 7 8 ; 9 10 11 12; 13 14 15 16]; 21 | h = daubcqf(4); 22 | y = mdwt(x, h); 23 | y_corr = [34.0000 -3.4641 0.0000 -2.0000; -13.8564 0.0000 0.0000 -2.0000; -0.0000 0.0000 -0.0000 -0.0000; -8.0000 -8.0000 0.0000 -0.0000]; 24 | assertVectorsAlmostEqual(y, y_corr, 'relative', 0.001); 25 | 26 | function test_mdwt_compute_L1 27 | x = [1 2]; 28 | h = daubcqf(4, 'min'); 29 | [y, L] = mdwt(x, h); 30 | assertEqual(L, 1); 31 | 32 | function test_mdwt_compute_L2 33 | x = [1 2 3 4]; 34 | h = daubcqf(4, 'min'); 35 | [y, L] = mdwt(x, h); 36 | assertEqual(L, 2); 37 | 38 | function test_mdwt_compute_L3 39 | x = [1 2 3 4 5 6 7 8]; 40 | h = daubcqf(4, 'min'); 41 | [y, L] = mdwt(x, h); 42 | assertEqual(L, 3); 43 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/test_midwt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_midwt 2 | disp("midwt") 3 | test_midwt_1D 4 | test_midwt_2D 5 | 6 | function test_midwt_1D 7 | x = makesig('LinChirp',8); 8 | h = daubcqf(4,'min'); 9 | L = 2; 10 | [y,L] = mdwt(x,h,L); 11 | [x_new,L] = midwt(y,h,L); 12 | assertVectorsAlmostEqual(x, x_new,'relative',0.0001); 13 | 14 | function test_midwt_2D 15 | load ../lena512; 16 | x = lena512; 17 | h = daubcqf(6); 18 | [y,L] = mdwt(x,h); 19 | [x_new,L] = midwt(y,h); 20 | assertEqual(L,9); 21 | assertVectorsAlmostEqual(x, x_new,'relative',0.0001); 22 | 23 | 24 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/test_mirdwt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_mirdwt 2 | disp("mrdwt") 3 | test_mirdwt_1 4 | test_mirdwt_2 5 | 6 | function test_mirdwt_1 7 | xin = makesig('Leopold',8); 8 | h = daubcqf(4,'min'); 9 | Lin = 1; 10 | [yl,yh,L] = mrdwt(xin,h,Lin); 11 | [x,L] = mirdwt(yl,yh,h,L); 12 | 13 | assertEqual(L,Lin); 14 | assertVectorsAlmostEqual(x, xin,'relative',0.0001); 15 | 16 | function test_mirdwt_2 17 | load ../lena512; 18 | x = lena512; 19 | h = daubcqf(6); 20 | [yl,yh,L] = mrdwt(x,h); 21 | assertEqual(L,9); 22 | [x_new,L] = mirdwt(yl,yh,h); 23 | assertEqual(L,9); 24 | assertVectorsAlmostEqual(x, x_new,'relative',0.0001); 25 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/octave/test_setopt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_setopt 2 | disp("setopt") 3 | test_setopt_all_defaults 4 | test_setopt_nonzero_becomes_zero 5 | 6 | function test_setopt_all_defaults 7 | x = []; 8 | default_opts = [5 6 7 8]; 9 | z = setopt(x, default_opts); 10 | z_corr = [5 6 7 8]; 11 | assertVectorsAlmostEqual(z, z_corr, 'relative', 0.0001); 12 | 13 | function test_setopt_nonzero_becomes_zero 14 | x = [1 0 3]; 15 | default_opts = [5 6 7 8]; 16 | z = setopt(x, default_opts); 17 | z_corr = [1 6 3 8]; 18 | %z_corr = [1 0 3 8]; % This would be more intuitive 19 | assertVectorsAlmostEqual(z, z_corr, 'relative', 0.0001); 20 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/runtests.m: -------------------------------------------------------------------------------- 1 | path(path, '../bin') 2 | path(path, 'matlab_xunit/xunit') 3 | test_mdwt 4 | test_midwt 5 | test_mirdwt 6 | test_mrdwt 7 | test_makesig 8 | test_denoise 9 | test_setopt 10 | test_daubcqf 11 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/test_daubcqf.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_daubcqf 2 | initTestSuite; 3 | 4 | function test_daubcqf_min 5 | [a, b] = daubcqf(4); 6 | ax = [0.482962913144534 0.836516303737808 0.224143868042013 -0.129409522551260]; 7 | bx = [0.129409522551260 0.224143868042013 -0.836516303737808 0.482962913144534]; 8 | assertVectorsAlmostEqual(a, ax, 'relative', 0.001); 9 | assertVectorsAlmostEqual(b, bx, 'relative', 0.001); 10 | 11 | function test_daubcqf_max 12 | [a, b] = daubcqf(4, 'max'); 13 | ax = [-0.129409522551260 0.224143868042013 0.836516303737808 0.482962913144534]; 14 | bx = [-0.482962913144534 0.836516303737808 -0.224143868042013 -0.129409522551260]; 15 | assertVectorsAlmostEqual(a, ax, 'relative', 0.001); 16 | assertVectorsAlmostEqual(b, bx, 'relative', 0.001); 17 | 18 | function test_daubcqf_mid_even_k 19 | [a, b] = daubcqf(4, 'mid'); 20 | ax = [0.482962913144534 0.836516303737808 0.224143868042013 -0.129409522551260]; 21 | bx = [0.129409522551260 0.224143868042013 -0.836516303737808 0.482962913144534]; 22 | assertVectorsAlmostEqual(a, ax, 'relative', 0.001); 23 | assertVectorsAlmostEqual(b, bx, 'relative', 0.001); 24 | 25 | function test_daubcqf_mid_odd_k 26 | [a, b] = daubcqf(6, 'mid'); 27 | ax = [0.332670552950083 0.806891509311093 0.459877502118491 -0.135011020010255 -0.085441273882027 0.035226291885710]; 28 | bx = [-0.035226291885710 -0.085441273882027 0.135011020010255 0.459877502118491 -0.806891509311093 0.332670552950083]; 29 | assertVectorsAlmostEqual(a, ax, 'relative', 0.001); 30 | assertVectorsAlmostEqual(b, bx, 'relative', 0.001); 31 | 32 | function test_daubcqf_odd 33 | handle = @() daubcqf(9); 34 | assertExceptionThrown(handle, ''); 35 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/test_mdwt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_mdwt 2 | initTestSuite; 3 | 4 | function test_mdwt_1D 5 | x = makesig('LinChirp', 8); 6 | h = daubcqf(4, 'min'); 7 | L = 2; % For 8 values in x we would normally be L=2 8 | [y, L] = mdwt(x, h, L); 9 | y_corr = [1.1097 0.8767 0.8204 -0.5201 -0.0339 0.1001 0.2201 -0.1401]; 10 | L_corr = 2; 11 | assertVectorsAlmostEqual(y, y_corr, 'relative', 0.001); 12 | assertEqual(L, L_corr); 13 | 14 | function test_mdwt_2D 15 | x = [1 2 3 4; 5 6 7 8 ; 9 10 11 12; 13 14 15 16]; 16 | h = daubcqf(4); 17 | y = mdwt(x, h); 18 | y_corr = [34.0000 -3.4641 0.0000 -2.0000; -13.8564 0.0000 0.0000 -2.0000; -0.0000 0.0000 -0.0000 -0.0000; -8.0000 -8.0000 0.0000 -0.0000]; 19 | assertVectorsAlmostEqual(y, y_corr, 'relative', 0.001); 20 | 21 | function test_mdwt_compute_L1 22 | x = [1 2]; 23 | h = daubcqf(4, 'min'); 24 | [y, L] = mdwt(x, h); 25 | assertEqual(L, 1); 26 | 27 | function test_mdwt_compute_L2 28 | x = [1 2 3 4]; 29 | h = daubcqf(4, 'min'); 30 | [y, L] = mdwt(x, h); 31 | assertEqual(L, 2); 32 | 33 | function test_mdwt_compute_L3 34 | x = [1 2 3 4 5 6 7 8]; 35 | h = daubcqf(4, 'min'); 36 | [y, L] = mdwt(x, h); 37 | assertEqual(L, 3); 38 | 39 | function test_mdwt_compute_bad_L 40 | L = -1; 41 | x = [1 2 3 4 5 6 7 8 9]; 42 | h = daubcqf(4, 'min'); 43 | mdwtHandle = @() mdwt(x, h); 44 | assertExceptionThrown(mdwtHandle, ''); 45 | 46 | function test_mdwt_empty_input 47 | mdwtHandle = @() mdwt([], [0 0 0 0]); 48 | assertExceptionThrown(mdwtHandle, ''); 49 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/test_midwt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_midwt 2 | initTestSuite; 3 | 4 | 5 | 6 | function test_midwt_1D 7 | x = makesig('LinChirp',8); 8 | h = daubcqf(4,'min'); 9 | L = 2; 10 | [y,L] = mdwt(x,h,L); 11 | [x_new,L] = midwt(y,h,L); 12 | assertVectorsAlmostEqual(x, x_new,'relative',0.0001); 13 | 14 | function test_midwt_2D 15 | load lena512; 16 | x = lena512; 17 | h = daubcqf(6); 18 | [y,L] = mdwt(x,h); 19 | [x_new,L] = midwt(y,h); 20 | assertEqual(L,9); 21 | assertVectorsAlmostEqual(x, x_new,'relative',0.0001); 22 | 23 | 24 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/test_mirdwt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_mirdwt 2 | initTestSuite; 3 | 4 | function test_mirdwt_1 5 | xin = makesig('Leopold',8); 6 | h = daubcqf(4,'min'); 7 | Lin = 1; 8 | [yl,yh,L] = mrdwt(xin,h,Lin); 9 | [x,L] = mirdwt(yl,yh,h,L); 10 | 11 | assertEqual(L,Lin); 12 | assertVectorsAlmostEqual(x, xin,'relative',0.0001); 13 | 14 | function test_mirdwt_2D 15 | load lena512; 16 | x = lena512; 17 | h = daubcqf(6); 18 | [yl,yh,L] = mrdwt(x,h); 19 | assertEqual(L,9); 20 | [x_new,L] = mirdwt(yl,yh,h); 21 | assertEqual(L,9); 22 | assertVectorsAlmostEqual(x, x_new,'relative',0.0001); 23 | -------------------------------------------------------------------------------- /matlab/rwt-master/tests/test_setopt.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_setopt 2 | initTestSuite; 3 | 4 | function test_setopt_all_defaults 5 | x = []; 6 | default_opts = [5 6 7 8]; 7 | z = setopt(x, default_opts); 8 | z_corr = [5 6 7 8]; 9 | assertVectorsAlmostEqual(z, z_corr, 'relative', 0.0001); 10 | 11 | function test_setopt_nonzero_becomes_zero 12 | x = [1 0 3]; 13 | default_opts = [5 6 7 8]; 14 | z = setopt(x, default_opts); 15 | z_corr = [1 6 3 8]; 16 | %z_corr = [1 0 3 8]; % This would be more intuitive 17 | assertVectorsAlmostEqual(z, z_corr, 'relative', 0.0001); 18 | -------------------------------------------------------------------------------- /matlab/temp/temp_FAfromPCE.m: -------------------------------------------------------------------------------- 1 | function [FA,log10FA] = temp_FAfromPCE(pce,search_space) 2 | % Calculates false alarm probability from having peak-to-cross-correlation (PCE) measure of the peak 3 | % pce PCE measure obtained from PCE.m 4 | % seach_space number of correlation samples from which the maximum is taken 5 | % USAGE: FA = FAfromPCE(31.5,32*32); 6 | 7 | % p = 1/2*erfc(sqrt(pce)/sqrt(2)); 8 | [p,logp] = Qfunction(sign(pce)*sqrt(abs(pce))); 9 | if pce<50, 10 | FA = 1-(1-p).^search_space; 11 | else 12 | FA = search_space*p; % an approximation 13 | end 14 | 15 | if FA==0, 16 | FA = search_space*p; 17 | log10FA = log10(search_space)+logp*log10(2); 18 | else 19 | log10FA = log10(FA); 20 | end 21 | end 22 | 23 | function [Q,logQ] = Qfunction(x) 24 | % Calculates probability of a Gaussian variable N(0,1) taking value larger than x 25 | 26 | if x<37.5, 27 | Q = 1/2*erfc(x/sqrt(2)); 28 | logQ = log(Q); 29 | else 30 | Q = 1./sqrt(2*pi)./x.*exp(-(x.^2)/2); 31 | logQ = -(x.^2)/2 - log(x)-1/2*log(2*pi); 32 | end 33 | end -------------------------------------------------------------------------------- /matlab/temp/temp_astroprnu.m: -------------------------------------------------------------------------------- 1 | path_calibr1 = '/Volumes/Macintosh HD/tmp_PCM/PRNU_DATASET/apple_iphone_4s_id01_calibration/'; 2 | path_calibr2 = '/Volumes/Macintosh HD/tmp_PCM/PRNU_DATASET/apple_iphone_4s_id02_calibration/'; 3 | addpath(path_calibr1) 4 | addpath(path_calibr2) 5 | [fingerprint1] = PRNUtraining(path_calibr1); 6 | [fingerprint2] = PRNUtraining(path_calibr2); 7 | 8 | orig_path='/Users/massimoiuliani/Desktop/astroprnu/orig/'; 9 | Img1or = 'IMG_0667orig1.JPG'; 10 | Img2or = 'IMG_0358orig2.JPG'; 11 | out_path = '/Users/massimoiuliani/Desktop/astroprnu/prnu_changed/'; 12 | [pce1or] = PRNUtest(fingerprint1,orig_path); 13 | [pce2or] = PRNUtest(fingerprint2,orig_path); 14 | Img1 = imread(strcat(orig_path,Img1or)); 15 | Img2 = imread(strcat(orig_path,Img2or)); 16 | 17 | %alpha = [0 0.5 : 0.1 : 1]; 18 | alpha = [0 0.65]; 19 | ll = length(alpha); 20 | for i = 1:ll 21 | Img1mod = zeros(size(Img1)); 22 | Img1mod(:,:,1) = double(Img1(:,:,1)) + alpha(i) * fingerprint2 - alpha(i) * fingerprint1; 23 | Img1mod(:,:,2) = double(Img1(:,:,2)) + alpha(i) * fingerprint2 - alpha(i) * fingerprint1; 24 | Img1mod(:,:,3) = double(Img1(:,:,3)) + alpha(i) * fingerprint2 - alpha(i) * fingerprint1; 25 | Img2mod = zeros(size(Img2)); 26 | Img2mod(:,:,1) = double(Img2(:,:,1)) + alpha(i) * fingerprint1 - alpha(i) * fingerprint2; 27 | Img2mod(:,:,2) = double(Img2(:,:,2)) + alpha(i) * fingerprint1 - alpha(i) * fingerprint2; 28 | Img2mod(:,:,3) = double(Img2(:,:,3)) + alpha(i) * fingerprint1 - alpha(i) * fingerprint2; 29 | Img1mod = uint8(Img1mod); 30 | Img2mod = uint8(Img2mod); 31 | imwrite(Img1mod,strcat(out_path,'IMG_0667mod1.JPG'),'JPG','Quality',96); 32 | imwrite(Img2mod,strcat(out_path,'IMG_0358mod2.JPG'),'JPG','Quality',96); 33 | [pce1mod(:,i)] = PRNUtest(fingerprint1,out_path); 34 | [pce2mod(:,i)] = PRNUtest(fingerprint2,out_path); 35 | end -------------------------------------------------------------------------------- /matlab/temp/temp_test.m: -------------------------------------------------------------------------------- 1 | s1=size(f1); 2 | s2=size(f1); 3 | for 1 = floor(-s1/2):ceil(s1/2) 4 | for j = 1:s2 5 | 6 | I1 = double(rgb2gray(D1)); 7 | I2 = double(rgb2gray(D2)); 8 | C12 = crosscorr(f1,I1c.*f2); 9 | detection = PCE(C12); -------------------------------------------------------------------------------- /matlab/utils/PCEdistance.m: -------------------------------------------------------------------------------- 1 | function affinity = PCEdistance(noisex, noisey) 2 | %Evaluate the PCE distance between imgx and imgy (both PRNU noises) 3 | C = crosscorr(noisex, noisey); 4 | detection = PCE(C); 5 | affinity = detection.PCE; 6 | end 7 | -------------------------------------------------------------------------------- /matlab/utils/detectOrientation.m: -------------------------------------------------------------------------------- 1 | function im = detectOrientation(image) 2 | %DETECTORIENTATION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | im = image; 6 | 7 | if size(image, 1) > size(image, 2) 8 | im = imrotate(image, 90); 9 | end 10 | 11 | end -------------------------------------------------------------------------------- /matlab/utils/double2range.m: -------------------------------------------------------------------------------- 1 | function X = double2range(X) 2 | % convert to double ranging from 0 to 255 3 | datatype = class(X); 4 | switch datatype, % convert to [0,255] 5 | case 'uint8', X = double(X); 6 | case 'uint16', X = double(X)/65535*255; 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /matlab/utils/evaluateClusterFingerprint.m: -------------------------------------------------------------------------------- 1 | function camera = evaluateClusterFingerprint(images, validation) 2 | %Evaluate fingerprint for images in a certain cluster 3 | camera = {}; 4 | 5 | folders = zeros(length(images), 1); 6 | if validation 7 | for i = 1:length(images) 8 | folders(i) = sum(cellfun(@(x) strcmp(x, images(i).folder), {images.folder})); 9 | end 10 | end 11 | [~, idx] = max(folders); 12 | camera.folder = images(idx).folder; 13 | 14 | RP = getFingerprint(images); 15 | RP = rgb2gray1(RP); 16 | sigmaRP = std2(RP); 17 | camera.fingerprint = WienerInDFT(RP,sigmaRP); 18 | end 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /matlab/utils/plotConfusionMatrix.m: -------------------------------------------------------------------------------- 1 | function [confusionMatrix, classes] = plotConfusionMatrix(trueLabels, predictedLabels, plot, name) 2 | %Generate confusion matrix and plot the result 3 | 4 | for i = 1:length(trueLabels) 5 | trueLabels(i) = strrep(trueLabels(i), '_', ' '); 6 | predictedLabels(i) = strrep(predictedLabels(i), '_', ' '); 7 | end 8 | 9 | [confusionMatrix, classes] = confusionmat(trueLabels, predictedLabels); 10 | confusionMat = confusionMatrix ./ repmat(sum(confusionMatrix, 2), 1, size(confusionMatrix, 2)); 11 | %Percentage 12 | confusionMat = confusionMat * 100; 13 | 14 | %Create a colored plot of the matrix values 15 | if plot 16 | figure; imagesc(confusionMat); 17 | 18 | title(sprintf(name)); 19 | %Determine the color scheme gray (so higher values are black and lower values are white) 20 | colormap(flipud(gray)); 21 | 22 | %Create strings from the matrix values and remove whitespaces 23 | textStrings = num2str(confusionMat(:),'%0.2f'); 24 | textStrings = strtrim(cellstr(textStrings)); 25 | 26 | [x, y] = meshgrid(1:length(classes)); 27 | %Plot the strings 28 | hStrings = text(x(:), y(:), textStrings(:), ... 29 | 'HorizontalAlignment', 'center', ... 30 | 'FontSize', 14); 31 | 32 | % Get the middle value of the color rang 33 | midValue = mean(get(gca,'CLim')); 34 | 35 | %Choose white or black for thetext color 36 | textColors = repmat(confusionMat(:) > midValue,1, 3); 37 | %Change the text colors 38 | set(hStrings,{'Color'}, num2cell(textColors, 2)); 39 | 40 | set(gca, ... 41 | 'FontWeight','bold', ... 42 | 'FontSize', 12, ... 43 | 'XTick', 1:length(classes), ... 44 | 'XTickLabel', classes,... 45 | 'YTick', 1:length(classes), ... 46 | 'YTickLabel', classes, ... 47 | 'TickLength', [0 0]); 48 | end 49 | end -------------------------------------------------------------------------------- /matlab/utils/remap.m: -------------------------------------------------------------------------------- 1 | function [value] = remap(input, ab, xy) 2 | %REMAP Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | a = ab(1); 6 | b = ab(2); 7 | x = xy(1); 8 | y = xy(2); 9 | 10 | value = (input - a) * (y - x) / (b - a) + x; 11 | 12 | end 13 | 14 | -------------------------------------------------------------------------------- /matlab/utils/storeEvaluatedClusters.m: -------------------------------------------------------------------------------- 1 | function storeEvaluatedClusters(images, clusters, outputPath) 2 | %Display evaluated class in table 3 | 4 | labels = cell(length(images), 1); 5 | for i = 1:length(clusters) 6 | clust = clusters{i}; 7 | for j = 1:length(clust) 8 | labels{clust(j)} = i; 9 | end 10 | end 11 | 12 | T = table({images.name}', labels, ... 13 | 'VariableNames', {'Image', 'Cluster'}); 14 | 15 | writetable(T, ['mat/' outputPath 'clusters.txt'], 'Delimiter',' ') 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /matlab/utils/validateClusterResults.m: -------------------------------------------------------------------------------- 1 | function [tpr, fpr] = validateClusterResults(images, clusters) 2 | %Evaluate clustering results 3 | 4 | tprs = zeros(length(clusters), 1); 5 | fprs = zeros(length(clusters), 1); 6 | 7 | total_labels = unique({images.folder}); 8 | for i = 1:length(clusters) 9 | intersections = zeros(length(total_labels), 1); 10 | for l = 1:length(total_labels) 11 | gt_label = find( cellfun(@(x) strcmp(x, total_labels(l)), {images.folder})); 12 | I = intersect(clusters{i}, gt_label); 13 | intersections(l) = length(I); 14 | end 15 | 16 | [best, idx] = max(intersections); 17 | gt_label = find( cellfun(@(x) strcmp(x, total_labels(idx)), {images.folder})); 18 | dim = length(gt_label); 19 | 20 | tp = best; 21 | fp = length(clusters{i}) - tp; 22 | fn = dim - tp; 23 | tn = length(images) - tp - fn; 24 | 25 | %Storing measures 26 | tprs(i) = tp / (tp + fn); 27 | fprs(i) = fp / (fp + tn); 28 | 29 | end 30 | 31 | %TPR and FPR average 32 | tpr = sum(tprs) / length(clusters); 33 | fpr = sum(fprs) / length(clusters); 34 | end 35 | 36 | --------------------------------------------------------------------------------