Created by Christos Sakaridis at Computer Vision Lab, ETH Zurich.
This is the source code for the fog simulation pipeline that we present in our ECCV 2018 paper titled Model Adaptation with Synthetic and Real Data for Semantic Dense Foggy Scene Understanding, which is used to create the Foggy Cityscapes-DBF dataset from the original Cityscapes dataset. This pipeline involves computation of a denoised and complete depth map, followed by refinement of the corresponding transmittance map with our novel Dual-reference cross-Bilateral Filter (DBF) that uses both color and semantics as reference, from which the dataset borrows its name. The refined transmittance map is combined with the real clear-weather Cityscapes image to obtain a partially synthetic foggy image. The aforementioned pipeline improves upon its predecessor presented in our previous IJCV 2018 article "Semantic Foggy Scene Understanding with Synthetic Data" and it generates synthetic foggy images with better adherence to semantic boundaries in the scene than the previous pipeline.
If you use our fog simulation code in your work, please cite:
- our publication as listed on our website,
- our preceding publication with the basic fog simulation pipeline,
- the Cityscapes publication, and
- the SLIC superpixels publication.
Our fog simulation code is made available for non-commercial use under the license agreement which is contained in the license file.
- MATLAB
The code has been developed and tested in MATLAB releases 2016b and 2017b. We therefore recommend using release 2016b or later. If such a configuration is not possible, using an earlier MATLAB release is the recommended (though not tested) alternative. - C compiler
Users will have to build a binary MEX file for SLIC superpixels themselves in MATLAB (see instructions below), which requires a MATLAB-supported C compiler.
Our fog simulation pipeline makes use of SLIC superpixels, for which the algorithm is implemented in the form of a source MEX file for usage in MATLAB. In short, a C compiler has to be configured with MATLAB and then used to build the binary MEX file for SLIC which is called in the pipeline. This MATLAB doc page can serve as a reference.
Steps:
- Clone this repository with
git clone https://github.com/sakaridis/fog_simulation_DBF.git - Make sure a MATLAB-supported C compiler is installed in your system, e.g. gcc for Linux.
- Open MATLAB and type in the Command Window
which will guide you through the process of configuring MATLAB's
mex -setupmexcommand with the compiler from step 2. Once this setup has been completed successfully, issuing the above command for a second time should generate a message similar toFor further details, please consult the mex command documentation.MEX configured to use 'gcc' for C language compilation. - Assign the MATLAB variable
FOG_SIMULATION_ROOTwith the path to the directory into which you have cloned this repository, by issuing in the Command Window something likeFOG_SIMULATION_ROOT = '/home/some_user/fog_simulation_DBF'; - Change MATLAB's current folder to
FOG_SIMULATION_ROOT, e.g. withcd(FOG_SIMULATION_ROOT); - Build the binary MEX file for SLIC from the respective C source file with
If the build is successful, it will generate a message similar to
cd(fullfile('source', 'external', 'SLIC_mex')); mex slicmex.c;and a binary MEX fileBuilding with 'gcc'. MEX completed successfully.slicmex.<ext>will be created in the SLIC source code directory, where extension<ext>depends on your system (see MATLAB docs for details).
After completing the basic installation, you will be all set to run the demo.
To run the demo in MATLAB, type in the Command Window
cd(fullfile(FOG_SIMULATION_ROOT, 'source'));
Demo_fog_simulation_Cityscapes;
The demo runs our fog simulation on an example clear-weather image from Cityscapes and writes the results (synthesized foggy image, estimated transmittance map and depth map) under the directory output/demos/. The running time for a single image is around 2-3 minutes on an Intel Core i7 machine with 16 GB RAM.
We have tested the demo:
- on Linux 64-bit with gcc and MATLAB releases 2016b and 2017b
The Foggy Cityscapes-DBF dataset is directly available for download at our dedicated website and at the Cityscapes website. However, for completeness we include in this repository some example code which can serve as a basis for users to reproduce the full-scale fog simulation experiments on Cityscapes for generating Foggy Cityscapes-DBF. Prior to running these experiments, the basic installation must be performed and a list of Cityscapes packages must be downloaded.
-
Download from the Cityscapes website the following packages:
leftImg8bit_trainvaltest.ziprightImg8bit_trainvaltest.zipdisparity_trainvaltest.zipcamera_trainvaltest.zipgtFine_trainvaltest.zip
-
After unzipping these packages, you have to ensure that the extracted files obey a certain directory structure. We will denote the root directory for Cityscapes into which you have put these packages by
CITYSCAPES_ROOT. The required directory structure is as follows:CITYSCAPES_ROOTleftImg8bittrainvaltest
rightImg8bittrainvaltest
disparitytrainvaltest
cameratrainvaltest
gtFinetrainvaltest
The lower levels of the directory structure correspond to city directories and files therein (e.g.
leftImg8bit/test/berlin/berlin_000362_000019_leftImg8bit.png) and are omitted above for brevity. -
Create a symbolic link to
CITYSCAPES_ROOTin thedata/directory of the repository and name itCityscapes. In Linux, supposing thatFOG_SIMULATION_ROOTpoints to the directory into which you have cloned this repository, this can be performed withcd ${FOG_SIMULATION_ROOT}/data ln -s ${CITYSCAPES_ROOT} Cityscapes -
Open MATLAB. Change its current folder to the experiments directory of the cloned repository with
cd(FOG_SIMULATION_ROOT); cd(fullfile('source', 'Fog_simulation', 'Experiments'));Run the experiment for generating Foggy Cityscapes-DBF-refined by issuing in the Command Window
Cityscapes_trainval_refined_stereoDBF_beta_0_01_serial;This should create the directory
output/Foggy_Cityscapes-DBF/and populate it with synthetic foggy images inleftImg8bit_trainval_refined_stereoBilateralDual_beta_0.01_foggyas well as corresponding estimated transmittance maps inleftImg8bit_trainval_refined_stereoBilateralDual_beta_0.01_transmittanceand depth maps indepth_stereoscopic_trainval_refined. Note: the results of this experiment will occupy around 6 GB of disk space.
Foggy Cityscapes-DBF-refined is based on a refined list of 550 Cityscapes images (498trainplus 52val) that yield high-quality synthetic foggy images; details are given in our IJCV publication.
The above experiment in step 4 uses a single thread and thus runs for around one day on an Intel Core i7 machine with 16 GB RAM and MATLAB 2017b. However, the implementation of the core MATLAB function Fog_simulation_Cityscapes.m of our fog simulation experiments allows parallel execution of the experiment. To this end, we provide a few example bash scripts in the experiments directory which launch experiments on a Grid Engine cluster for faster execution. These scripts along with the singled-threaded MATLAB script can be consulted for creating a user-specific script for parallel execution depending on the features of the user's system.
- M. Cordts, M. Omran, S. Ramos, T. Rehfeld, M. Enzweiler, R. Benenson, U. Franke, S. Roth, and B. Schiele: The Cityscapes Dataset for Semantic Urban Scene Understanding. In CVPR (2016).
- S. Paris and F. Durand: A Fast Approximation of the Bilateral Filter Using a Signal Processing Approach. International Journal of Computer Vision (2009).
- L. Wang, H. Jin, R. Yang, and M. Gong: Stereoscopic Inpainting: Joint Color and Depth Completion from Stereo Images. In CVPR (2008).
- R. Achanta, A. Shaji, K. Smith, A. Lucchi, P. Fua, and S. Süsstrunk: SLIC Superpixels Compared to State-of-the-Art Superpixel Methods. IEEE Transactions on Pattern Analysis and Machine Intelligence 34(11), 2274-2282 (2012).
- K. He, J. Sun, and X. Tang: Single Image Haze Removal Using Dark Channel Prior. IEEE Transactions on Pattern Analysis and Machine Intelligence 33(12), 2341–2353 (2011).
- K. Tang, J. Yang, and J. Wang: Investigating Haze-Relevant Features in a Learning Framework for Image Dehazing. In CVPR (2014).
Christos Sakaridis
csakarid[at]vision.ee.ethz.ch
https://www.vision.ee.ethz.ch/~csakarid/Model_adaptation_SFSU_dense/