This contains the scripts and data used to generate all the plots in the paper. Some of the code is based on Hermundstad et al. (2014).
Download the files into a directory of your choice. Before using the code, you must run setup_paths.m
. This temporarily adds all folders to the Matlab path, and must be done every done Matlab is restarted.
The psychophysics data is already available in the repository, in the data
folder. However, the natural-image data must be downloaded separately. We use two databases in the paper: the UPenn natural image database, and the van Hateren natural image dataset. Here are instructions for downloading the needed pictures:
- Penn database:
- this work uses a curated subset of the images from the Penn database, as described in Hermundstad et al. (2014)
- the download process from the UPenn website is a bit convoluted, so we made a copy here: https://www.dropbox.com/sh/14iti3zm7oxnw95/AAD5fWXTaRxpyJmPbR2S2UBxa?dl=0
- download and unzip into
NaturalImages/PennNoSky
in the directory containing the scripts
- download and unzip into
- to download directly from the source, follow these steps:
- first navigate to http://tofu.psych.upenn.edu/~upennidb/gallery2/main.php
- note that every step below can take a couple of minutes as the server is slow
- add any album to the cart (we will change the picture selection later)
- choose "Download in Zip" from the "cart actions" dropdown on the top right, then click the "Go" button
- on the "Image database download page", look down to where it says "Index file", press "Choose File" and choose the
indices/PennNoSkyIndex.txt
in this repository - press "Load existing list" button below
- in the form below, enter your email address and select "Include luminance (LUM) files"
- press the "Submit" button
- an archive will be prepared and you will receive an email to download it
- this will take a while!
- once downloaded, unzip the pictures under
NaturalImages/PennNoSky
in the directory where you downloaded the scripts (a symbolic link also works)
- alternatively, use FTP to download images from ftp://anonymous@tofu.psych.upenn.edu/fulldb
- van Hateren database
- we use a curated subset of the pictures from the van Hateren database; use the IMC format
- download the IMC files as a zip from http://cin-11.medizin.uni-tuebingen.de:61280/vanhateren/zipped/vanhateren_imc.zip
- unzip into
NaturalImages/vanHateren
The scripts for making the plots for the paper can be found in papers/ternary_salience
. These typically depend on results files generated by scripts in the analysis
folder and stored in save
.
Running the scripts in the order described below should ensure that all the results are present when they are needed. It's best to run clear all
before running each script below (note that options like dbChoice
must be set after the clear all
).
- run
plotsForPPExample.m
to make the plots needed for the figure describing the psychophysics - run
showMixedPlanePatches.m
to make the figure showing the textures in mixed planes - run
generateNIFilters.m
to generate whitening filters - run
generateTernaryNIDistribution.m
to analyze the texture content of all the images in the PennNoSky subset of the UPenn natural image database - run
plotsForTernaryExplanation.m
to make the plots needed for the figure describing the natural-image analysis - run
generateTernaryNIPredictions.m
to build threshold predictions based on the natural-image distribution - now we can:
- make the alloy plots comparing predicted to measured thresholds using
plotTernaryNIPPComparison.m
- run
statisticalTests.m
to check to what extent the results support our efficient-coding model- the results are saved in 'save/PennNoSky_equalize_square.csv' in a format similar to that from the Tables in the paper's SI
- make the plot showing how the results depend on the patch size and downsampling ratio using
plotDependenceOnNR.m
- make the plot showing the effect of symmetry transformations using
plotSymmetries.m
- plot per-subject results using
plotMultipleSubjects.m
- plot results in higher-order planes using
plotHigherOrder.m
- make the alloy plots comparing predicted to measured thresholds using
- to use the van Hateren database instead, we rerun
generateNIFilters.m
,generateTernaryNIDistribution.m
, andgenerateTernaryNIPredictions.m
, making sure to setdbChoice = 'vanHateren'
before running each script- we can now run
plotVanHaterenComparison.m
to compare predicted to measured thresholds for the van Hateren database - we can rerun
statisticalTests.m
settingdbChoice = 'vanHateren'
to perform statistical tests on the van Hateren results - we can rerun
plotDependenceOnNR.m
making sure to definedbChoice = 'vanHateren'
to show how the N and R parameters affect the results in this case - we can rerun
plotSymmetries.m
after definingdbChoice = 'vanHateren'
to see how the symmetry results change when using the van Hateren database
- we can now run
- run
generateTernaryNIDistributionMultiCutoffs.m
- run
generateTernaryNIPredictionsMultiCutoffs.m
- we can now run
plotTernarization.m
to see how the specific cutoff used for the ternarization process affects the results - optionally we can run the following scripts whose results have not been included in the paper:
plotTernaryPCA.m
to perform principal components analysis on the distribution of textures in natural imagescheckGaussianMixRobustness.m
to check how robust the separation between in-focus and blurry patches is -- this requires first runninggenerateBinaryNIDistribution.m
andgenerateFocusResamples.m
(takes a long time)
There are many more options for the analyses included in this repositories. Read the documentation for the various scripts and functions for details.