master 5922558ff1e5 cached
13 files
63.3 KB
28.1k tokens
1 requests
Download .txt
Repository: danaberman/non-local-dehazing
Branch: master
Commit: 5922558ff1e5
Files: 13
Total size: 63.3 KB

Directory structure:
gitextract_35gc0cc4/

├── .gitignore
├── LICENSE.md
├── README.md
├── TR1000.txt
├── adjust.m
├── demo_non_local_dehazing.m
├── estimate_airlight.m
├── images/
│   ├── cityscape_params.txt
│   ├── forest_params.txt
│   ├── pumpkins_params.txt
│   └── train_params.txt
├── non_local_dehazing.m
└── wls_optimization.m

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.asv

================================================
FILE: LICENSE.md
================================================
#LICENSE
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this license ("License"). To the extent this License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.

##Section 1 – Definitions.
a.	**Adapted Material** means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. 

b.	**Adapter's License** means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this License.

c.	**Copyright and Similar Rights** means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.

d.	**Effective Technological Measures** means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.

e.	**Exceptions and Limitations** means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.

f.	**Licensed Material** means the software code and associated literature to which the Licensor applied this License.

g.	**Licensed Rights** means the rights granted to You subject to the terms and conditions of this License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.

h.	**Licensor** means, jointly and severally: 

  1.	Carmel Haifa University Economic Corporation Ltd., of Haifa, Israel, its successors or assigns; and
	
  2.	Ramot at Tel Aviv University Ltd., of Tel Aviv, Israel, its successors or assigns.
  
i.	Non Commercial means intended solely for research purposes and not intended for or directed towards commercial advantage or monetary compensation. For purposes of this License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is Non Commercial provided there is no payment of monetary compensation in connection with the exchange.

j.	Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.

k.	Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.

l.	You means the individual or entity exercising the Licensed Rights under this License. Your has a corresponding meaning.

##Section 2 – Scope.

a. **License grant.**

  1.	Subject to the terms and conditions of this License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:

    A.	reproduce and Share the Licensed Material, in whole or in part, for Non Commercial purposes only; and

    B.	produce, reproduce, and Share Adapted Material for Non Commercial purposes only.
  2.	*Exceptions and Limitations*. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this License does not apply, and You do not need to comply with its terms and conditions.
  3.	*Term*. The term of this License is specified in Section 6(a).
  4.	*Media and formats; technical modifications allowed*. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
  5.	*Downstream recipients*.
    A.	*Offer from the Licensor – Licensed Material*. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this License.
    B.	*Additional offer from the Licensor – Adapted Material*. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
    C.	*No downstream restrictions*. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
  6.	*No endorsement*. Nothing in this License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
  
b.	Other rights.

  1.	Moral rights, such as the right of integrity, are not licensed under this License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
  2.	Patent and trademark rights are not licensed under this License.
  3.	To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for Non Commercial purposes.

##Section 3 – License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.

a.	**Attribution**.

  1.	If You Share the Licensed Material (including in modified form), You must:
  
    A.	retain the following if it is supplied by the Licensor with the Licensed Material:

      i.	identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor;

      ii.	a copyright notice;

      iii.	a notice that refers to this License;

      iv.	a notice that refers to the disclaimer of warranties;

      v.	a URI or hyperlink to the Licensed Material to the extent reasonably practicable;

    B.	indicate if You modified the Licensed Material and retain an indication of any previous modifications; and

    C.	indicate the Licensed Material is licensed under this License, and include the text of, or the URI or hyperlink to, this License.

  2.	You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.

  3.	If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
  
b.	**Share Alike**.

In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.

  1.	The Adapter’s License You apply must have the same conditions as this License.
  2.	You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
  3.	You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
  
##Section 4 – Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:

a.	for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for Non Commercial purposes only;

b.	if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and

c.	You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this License where the Licensed Rights include other Copyright and Similar Rights.

##Section 5 – Disclaimer of Warranties and Limitation of Liability.
a.	**Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.**

b.	**To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.**

c.	The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.

##Section 6 – Term and Termination.
a.	This License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this License, then Your rights under this License terminate automatically.

b.	Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:

  1.	automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
  2.	upon express reinstatement by the Licensor.
  
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this License.

c.	For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this License.

d.	Sections 1, 5, 6, 7, and 8 survive termination of this License.

##Section 7 – Other Terms and Conditions.
a.	The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.

b.	Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this License.

##Section 8 – Interpretation.
a.	For the avoidance of doubt, this License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this License.

b.	To the extent possible, if any provision of this License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this License without affecting the enforceability of the remaining terms and conditions.

c.	No term or condition of this License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.

d.	Nothing in this License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.



================================================
FILE: README.md
================================================
# Non-Local Image Dehazing

<img height="285px" width="200px" align="right" src="http://www.eng.tau.ac.il/~berman/images/cityscape_half.jpg">

This is the source code implementing the non-local single image dehazing algorithm described in the papers:

[Non-Local Image Dehazing. Berman, D. and Treibitz, T. and Avidan S., CVPR2016](https://www.eng.tau.ac.il/~berman/NonLocalDehazing/NonLocalDehazing_CVPR2016.pdf)

[Air-light Estimation using Haze-Lines. Berman, D. and Treibitz, T. and Avidan S., ICCP2017](https://www.eng.tau.ac.il/~berman/NonLocalDehazing/AirlightEstimation_ICCP2017.pdf)

If you use this code, please cite the appropriate paper.

#### bibtex

>    @inproceedings{NonLocalImageDehazing,    
>      title={Non-Local Image Dehazing},    
>      author={Berman, D. and Treibitz, T. and Avidan, S.},    
>      booktitle={IEEE Conf. CVPR},    
>      year={2016},
>    }
>
>    @inproceedings{AirlightEstimation,    
>      title={Air-light Estimation Using Haze-Lines},    
>      author={Berman, D. and Treibitz, T. and Avidan, S.},    
>      booktitle={IEEE Conf. ICCP},    
>      year={2017},
>    }




## Getting Started

### System Requirements:
The code requires MATLAB, and was tested on windows.

### Demo
1. Change MATLAB's directory to the folder the code was extracted to.
2. Run the file demo_non_local_dehazing.m in order to see the algorithm's
perfomance on the attached images.

### Dehazing other images
Each image in the demo is accompanied by a text file containing parameters. These value were taken from the [result pages of the paper: "Dehazing using Color-Lines"](http://www.cs.huji.ac.il/~raananf/projects/dehaze_cl/results/).

The gamma value is required since the image formation model applies to the linear images, where each pixel's value is directly related to the number of photons received at that location on the sensor. 
A non-linear tone-mapping is applied in camera and most of the images we see are not linear. The gamma value approximates the inverse mapping of the pixels' values to linear.

Despite that, **for new images, I recommend trying gamma=1 first** (this is the default). It often works even though it is not physically accurate.


## Authors
Dana Berman, *danamena@post.tau.ac.il*


## License
 
The software code of the non-local image dehazing algorithm is provided for non-commercial use under the attached [LICENSE.md](LICENSE.md)


================================================
FILE: TR1000.txt
================================================
   -0.9425   -0.2041   -0.2648
    0.5224    0.7539    0.3985
    0.5528    0.0429   -0.8322
    0.6499    0.0243   -0.7596
    0.6986    0.1199   -0.7054
   -0.0303    0.9929   -0.1151
    0.8482    0.0839   -0.5230
    0.9526    0.0586   -0.2985
   -0.2253   -0.1544   -0.9620
    0.9065    0.0667   -0.4168
    0.9313   -0.0364   -0.3625
    0.9274    0.2528   -0.2755
    0.9601    0.1575   -0.2311
    0.9827    0.0588   -0.1759
    0.4552    0.2145    0.8641
    0.0245    0.6354    0.7718
    0.9838    0.1794    0.0003
    0.9944    0.0840    0.0637
    0.1522    0.2044   -0.9670
    0.9784    0.1048    0.1784
    0.1846    0.8742   -0.4490
    0.9353    0.0254    0.3528
    0.8863    0.0396    0.4613
   -0.4683    0.2315    0.8527
    0.8514   -0.0566    0.5215
    0.8241    0.0513    0.5642
    0.7803   -0.0439    0.6238
    0.0253   -0.0740    0.9969
    0.6571    0.0871    0.7487
    0.5676    0.1304    0.8129
    0.4011    0.0242    0.9157
   -0.1442    0.9656    0.2165
    0.3730   -0.9271   -0.0358
    0.3781    0.2043   -0.9030
    0.5067    0.1507   -0.8489
    0.6084    0.1352   -0.7820
    0.6523    0.2322   -0.7215
    0.7786    0.1026   -0.6190
    0.7782    0.4864   -0.3974
    0.8083    0.1983   -0.5544
    0.8251    0.2929   -0.4831
    0.9227    0.1605   -0.3506
   -0.1930   -0.2652   -0.9447
    0.2991   -0.7068   -0.6410
    0.9420    0.2887   -0.1714
    0.9597    0.2731   -0.0659
    0.9245    0.3775   -0.0524
    0.9124    0.4034    0.0693
    0.8871    0.4228    0.1851
    0.9539    0.2970    0.0444
    0.9485    0.2208    0.2270
    0.9358    0.3163    0.1556
    0.9052    0.3318    0.2656
    0.9110    0.2363    0.3379
    0.8596    0.2498    0.4457
    0.8511    0.1507    0.5028
    0.5268   -0.1617   -0.8345
    0.4062   -0.8690   -0.2825
    0.7849    0.1609    0.5984
    0.6297    0.2089    0.7482
   -0.4992   -0.5457    0.6731
    0.4784    0.1069    0.8716
    0.3721    0.1418    0.9173
    0.2940    0.0590    0.9540
    0.1776    0.0098   -0.9841
    0.4599    0.2507   -0.8518
    0.5606    0.2450   -0.7910
    0.8616    0.3439    0.3733
    0.5910    0.3426   -0.7303
    0.6792    0.3292   -0.6559
    0.6980    0.4219   -0.5786
    0.7573    0.3130   -0.5732
    0.7092    0.5082   -0.4887
    0.8347    0.3809   -0.3977
    0.8390    0.4548   -0.2988
    0.7755    0.5572   -0.2970
    0.8357    0.5103   -0.2028
    0.8797    0.4629   -0.1087
    0.7105    0.5858   -0.3899
    0.8213    0.5628   -0.0929
    0.8731    0.4875    0.0001
    0.8536    0.5093    0.1093
    0.8232    0.5241    0.2183
    0.7814    0.5319    0.3263
    0.8495    0.4357    0.2975
   -0.2468    0.1027    0.9636
    0.7977    0.4449    0.4071
    0.1627   -0.2310    0.9593
    0.7389    0.3623    0.5681
    0.7948    0.2599    0.5484
    0.6632    0.3722    0.6494
    0.5757    0.4340    0.6929
    0.5132    0.3740    0.7725
    0.5376    0.2555    0.8036
    0.3492    0.2587    0.9006
    0.2158   -0.0260    0.9761
    0.2310    0.1126   -0.9664
    0.2889    0.3200   -0.9023
    0.3872    0.3360   -0.8586
    0.4929    0.3498   -0.7966
    0.6143    0.4353   -0.6581
    0.4626    0.6167   -0.6369
   -0.6389    0.0488   -0.7677
    0.6308    0.5228   -0.5734
    0.8405   -0.5070    0.1908
    0.6358    0.6762   -0.3721
    0.7049    0.6511   -0.2813
    0.2048   -0.4480    0.8703
    0.7686    0.6112   -0.1887
    0.6725    0.7383   -0.0519
    0.7523    0.6547   -0.0744
    0.8087    0.5879    0.0188
    0.7329    0.6792    0.0388
    0.7873   -0.6015    0.1353
    0.5690    0.7715    0.2847
   -0.1491   -0.2403    0.9592
    0.7501    0.6177    0.2361
   -0.7850    0.5957    0.1702
    0.6162    0.6969    0.3670
    0.7255    0.5343    0.4339
    0.6520    0.6136    0.4454
    0.7248    0.4607    0.5123
    0.6498    0.4717    0.5960
    0.4806    0.4880    0.7286
   -0.6173    0.7753    0.1334
    0.4338    0.3253    0.8403
    0.2405    0.2983    0.9237
    0.2661    0.1811    0.9468
    0.2703    0.2162   -0.9382
    0.4466    0.8881    0.1087
    0.3099    0.4290   -0.8485
    0.3354    0.5265   -0.7812
    0.4417    0.5321   -0.7223
   -0.7669   -0.1000   -0.6339
    0.5554    0.6141   -0.5607
   -0.7876    0.4996   -0.3608
    0.5594    0.6906   -0.4585
    0.6260    0.7356   -0.2588
    0.7031    0.6952    0.1496
    0.4621   -0.1997    0.8640
    0.5381    0.8103   -0.2322
    0.6084    0.7806   -0.1430
    0.5820    0.8127   -0.0279
    0.6463    0.7606    0.0617
    0.5501    0.8307    0.0855
    0.5624   -0.2132    0.7989
    0.6640    0.7017    0.2585
    0.7224   -0.6868    0.0807
   -0.0298    0.3762   -0.9261
    0.5645    0.6711    0.4806
    0.4687    0.7228    0.5077
    0.6256    0.5636    0.5394
    0.5548    0.5351    0.6371
   -0.4648    0.8330    0.3002
    0.4522    0.5876    0.6709
    0.3754    0.5376    0.7550
    0.4077    0.4334    0.8037
    0.0966    0.4429    0.8914
   -0.0566   -0.9558    0.2885
    0.1077    0.0948   -0.9897
    0.2017    0.4148   -0.8873
    0.5197    0.4436   -0.7302
    0.2489    0.6064   -0.7552
    0.2711    0.6883   -0.6729
    0.3592    0.6144   -0.7025
    0.3791    0.6935   -0.6126
    0.2903    0.7607   -0.5805
    0.3883    0.7669   -0.5109
    0.3818    0.8329   -0.4007
    0.3598    0.8862   -0.2918
    0.4628    0.8271   -0.3188
   -0.1835    0.3060    0.9342
    0.4391    0.8744   -0.2065
    0.5134    0.8500   -0.1180
    0.4820    0.8762   -0.0044
    0.4840   -0.3078    0.8191
    0.1280    0.3348    0.9335
    0.5120    0.8358    0.1982
    0.4699    0.8258    0.3118
    0.3654    0.8692    0.3332
    0.4230    0.8014    0.4230
    0.5220    0.6279    0.5773
    0.3662    0.7653    0.5294
    0.2580    0.7980    0.5447
    0.3434    0.6325    0.6943
    0.4017   -0.7699    0.4959
    0.2640    0.5758    0.7738
    0.2969    0.4765    0.8275
    0.2130    0.4087    0.8875
    0.1571    0.2192    0.9630
    0.0338    0.1872   -0.9817
    0.1778    0.3110   -0.9336
    0.6041   -0.7333   -0.3119
    0.1352    0.5942   -0.7929
   -0.5395   -0.4109   -0.7349
    0.1568    0.6791   -0.7171
    0.1087   -0.6415   -0.7594
    0.1768    0.7534   -0.6333
    0.0925   -0.5496   -0.8303
    0.2947    0.8282   -0.4767
   -0.7825    0.1475   -0.6049
    0.2749    0.8865   -0.3722
    0.7211   -0.3034   -0.6228
    0.3303    0.9261   -0.1825
    0.3376    0.9323    0.1298
    0.2606    0.9647    0.0375
    0.4078    0.8857    0.2218
    0.2982    0.9237    0.2406
   -0.2396    0.4107   -0.8797
    0.8711    0.1783   -0.4575
    0.2562    0.9013    0.3492
    0.2108    0.8654    0.4546
    0.3189    0.8386    0.4417
    0.1450    0.8198    0.5540
    0.7000   -0.5315    0.4770
    0.3049    0.7191    0.6244
    0.2295    0.6664    0.7094
    0.1898    0.7478    0.6362
    0.1472    0.6066    0.7813
    0.0623    0.5436    0.8370
    0.0763    0.1349    0.9879
    0.0624    0.2954   -0.9533
    0.0871    0.4001   -0.9123
    0.3691   -0.8047   -0.4650
   -0.0480    0.7293   -0.6825
   -0.6396    0.7299    0.2411
    0.0646    0.7522   -0.6557
    0.8438   -0.4136   -0.3420
    0.0872    0.8233   -0.5609
    0.0781    0.8946   -0.4400
    0.1588    0.9243   -0.3471
    0.0424    0.9421   -0.3328
    0.1262    0.9618   -0.2430
    0.2466    0.9318   -0.2665
    0.2133    0.9639   -0.1597
    0.0913    0.9865   -0.1361
    0.2965    0.9523   -0.0727
   -0.0677    0.9977   -0.0047
    0.1780    0.9827   -0.0517
    0.7488    0.0605    0.6601
    0.2231    0.9636    0.1471
    0.1033    0.9811    0.1636
    0.1427    0.9218    0.3604
    0.0997    0.8810    0.4625
    0.0641    0.9612    0.2682
    0.0694    0.7668    0.6382
   -0.0169    0.7166    0.6972
    0.1103    0.6919    0.7135
   -0.0998    0.6557    0.7484
   -0.0584    0.5691    0.8202
   -0.0211    0.4718    0.8815
    0.0124    0.3659    0.9306
    0.0450    0.2541    0.9661
   -0.0551    0.2675   -0.9620
   -0.0040    0.4795   -0.8775
   -0.0673    0.6417   -0.7640
   -0.6821    0.7297    0.0471
   -0.1518    0.7000   -0.6979
   -0.0348    0.8001   -0.5989
    0.6401   -0.2910   -0.7110
   -0.1488    0.7913   -0.5930
   -0.1151    0.8558   -0.5043
   -0.0421    0.9104   -0.4115
   -0.1567    0.9040   -0.3978
   -0.1948    0.9369   -0.2904
   -0.1145    0.9729   -0.2008
   -0.1515    0.9843   -0.0910
   -0.4692    0.0630   -0.8808
    0.4747    0.6953   -0.5396
   -0.1885    0.9819    0.0205
   -0.1057    0.9887    0.1060
    0.0169    0.9965    0.0814
   -0.1837    0.9266    0.3282
   -0.0634    0.9527    0.2971
   -0.1039    0.9096    0.4023
   -0.0142    0.8852    0.4651
    0.0264    0.8309    0.5557
   -0.1031    0.8475    0.5207
    0.2068   -0.6779   -0.7054
   -0.0618    0.7868    0.6141
   -0.1801    0.5848    0.7909
   -0.1393    0.4940    0.8583
   -0.8438   -0.4630    0.2714
   -0.0364    0.1688    0.9850
   -0.1683    0.2374   -0.9567
   -0.1216    0.4501   -0.8847
   -0.0947    0.5487   -0.8306
   -0.1829    0.6088   -0.7720
   -0.2701    0.6536   -0.7070
   -0.2340    0.7372   -0.6338
   -0.2850    0.7855   -0.5493
   -0.2225    0.8469   -0.4830
   -0.3395    0.8249   -0.4521
   -0.2707    0.8862   -0.3760
   -0.3087    0.9128   -0.2675
   -0.2318    0.9559   -0.1801
   -0.3451    0.9257   -0.1548
    0.7136    0.2696    0.6466
   -0.2687    0.9609   -0.0675
   -0.3047    0.9513    0.0460
   -0.4148    0.9067    0.0758
   -0.2251    0.9653    0.1326
   -0.2586    0.9338    0.2473
   -0.3581    0.8912    0.2785
   -0.1636   -0.1226    0.9789
   -0.1991    0.8678    0.4554
   -0.2778    0.8831    0.3781
    0.4746    0.7669   -0.4320
   -0.2832    0.8148    0.5058
   -0.1437    0.7314    0.6667
    0.9489    0.1232    0.2906
   -0.2233    0.6642    0.7134
    0.9079   -0.0710    0.4131
   -0.1030    0.3920    0.9142
   -0.2626    0.2148    0.9407
   -0.0787    0.1501   -0.9855
   -0.1468    0.3464   -0.9265
   -0.2126    0.5126   -0.8319
   -0.3017    0.5626   -0.7697
    0.7844    0.6069    0.1284
   -0.9995    0.0320    0.0087
   -0.3459    0.7023   -0.6222
   -0.4518    0.6594   -0.6009
   -0.3995    0.7489   -0.5287
   -0.6044    0.6423   -0.4713
   -0.3851    0.8548   -0.3480
   -0.4935    0.8081   -0.3216
   -0.5209    0.8268   -0.2124
   -0.4186    0.8759   -0.2399
   -0.4534    0.8824   -0.1258
   -0.3813    0.9236   -0.0401
    0.8824    0.2712   -0.3845
   -0.4876    0.8730   -0.0091
   -0.5171    0.8490    0.1084
   -0.3372    0.9276    0.1607
   -0.0030    0.8608   -0.5089
   -0.4804    0.7781    0.4048
   -0.3848    0.7901    0.4771
   -0.3625    0.7348    0.5733
   -0.9911   -0.0428    0.1264
   -0.2609    0.7375    0.6229
   -0.8758    0.0725    0.4772
   -0.3400    0.6627    0.6673
   -0.2590    0.5067    0.8223
   -0.2188    0.4123    0.8844
   -0.4272    0.0449    0.9030
   -0.1884    0.1246   -0.9742
   -0.2628    0.3033   -0.9159
   -0.3299    0.4643   -0.8220
   -0.4140    0.5157   -0.7501
   -0.5188    0.4615   -0.7196
   -0.4888    0.5637   -0.6658
   -0.5520    0.6068   -0.5719
   -0.5055    0.7006   -0.5036
   -0.5509    0.7323   -0.4002
   -0.5957    0.7486   -0.2910
   -0.6453    0.6707   -0.3657
   -0.8289   -0.0099    0.5594
   -0.6927    0.6750   -0.2543
   -0.6143    0.7677   -0.1827
   -0.7910    0.5591   -0.2484
   -0.5542    0.8269   -0.0952
   -0.5859    0.8100    0.0240
   -0.4533   -0.0577   -0.8895
    0.6376    0.6041   -0.4781
   -0.7078    0.6893    0.1545
   -0.5447    0.8099    0.2176
   -0.5635    0.7597    0.3244
   -0.6487    0.6762    0.3492
   -0.4726    0.7186    0.5102
   -0.5540    0.6387    0.5340
   -0.3829    0.6125   -0.6916
   -0.4975    0.4979    0.7104
   -0.4209    0.5839    0.6942
   -0.3816    0.5073    0.7727
   -0.3364    0.4241    0.8408
   -0.2959    0.3258    0.8979
    0.1060    0.0120    0.9943
   -0.2818    0.1905   -0.9404
    0.7198   -0.5001   -0.4814
   -0.3544    0.3592   -0.8634
   -0.4612    0.3020   -0.8343
   -0.1872    0.7990    0.5714
    0.0066    0.9744   -0.2246
   -0.5881    0.5058   -0.6311
   -0.6458    0.5454   -0.5344
   -0.7332    0.4808   -0.4809
   -0.6967    0.5739   -0.4305
   -0.6806    0.4421   -0.5843
   -0.7701    0.6184   -0.1565
   -0.7310    0.5983   -0.3281
   -0.6972    0.7015   -0.1480
   -0.8101    0.5847   -0.0434
   -0.7372    0.6743   -0.0438
   -0.3344   -0.1017   -0.9369
   -0.7666    0.6391    0.0624
   -0.7412   -0.5639   -0.3643
   -0.7217    0.6405    0.2625
   -0.7238    0.5834    0.3684
   -0.9242    0.3810   -0.0272
   -0.6450    0.6148    0.4538
   -0.6281    0.5486    0.5519
    0.2056   -0.0969   -0.9738
    0.6931    0.7010   -0.1678
   -0.5647    0.4003    0.7217
   -0.4563    0.4197    0.7846
   -0.4489    0.7844   -0.4280
   -0.4093    0.3354    0.8485
   -0.1534    0.1925    0.9692
    0.9774    0.1726   -0.1217
   -0.3738    0.2477   -0.8938
   -0.5558    0.2381   -0.7965
   -0.4485    0.6571    0.6059
   -0.5422    0.3535   -0.7623
   -0.6160    0.4004   -0.6784
   -0.7147    0.2203   -0.6638
   -0.7610    0.3699   -0.5329
   -0.8039    0.4078   -0.4329
   -0.8970    0.2891   -0.3343
   -0.9045    0.3564   -0.2344
   -0.8549    0.3924   -0.3395
   -0.2367   -0.5384   -0.8088
   -0.8956    0.4231   -0.1376
    0.4088    0.9077   -0.0944
   -0.8734    0.4859   -0.0326
   -0.8937    0.4420    0.0773
   -0.8359    0.5446    0.0684
   -0.9010    0.3919    0.1862
   -0.8491    0.4971    0.1785
   -0.8404    0.3770    0.3894
   -0.7924    0.5433    0.2773
   -0.8509    0.4406    0.2861
   -0.7880    0.4832    0.3816
   -0.7722    0.4150    0.4811
   -0.7451    0.3405    0.5736
   -0.6923    0.4484    0.5653
   -0.6191    0.2914    0.7292
    0.7103    0.1674    0.6838
    0.2117   -0.8454    0.4905
    0.3399   -0.8830    0.3237
   -0.0055    0.0495    0.9988
   -0.1348    0.0302   -0.9904
   -0.2808    0.0672   -0.9574
   -0.4711    0.1843   -0.8626
   -0.6328    0.2882   -0.7187
   -0.6413    0.1710   -0.7480
   -0.7022    0.3322   -0.6297
   -0.7815    0.2631   -0.5657
    0.1412    0.9884    0.0565
   -0.8376    0.3025   -0.4548
   -0.8880    0.2086   -0.4098
   -0.2688   -0.9286    0.2560
   -0.9349    0.1658   -0.3137
   -0.9410    0.3133   -0.1283
   -0.9628    0.2694   -0.0203
   -0.1435   -0.4813   -0.8647
   -0.9390    0.3339    0.0824
   -0.9716    0.2199    0.0875
   -0.9058    0.0963   -0.4125
   -0.9403    0.2819    0.1905
   -0.8970    0.3316    0.2922
   -0.7140    0.5188    0.4702
   -0.8804    0.2655    0.3930
   -0.8184    0.3052    0.4868
   -0.8528    0.1904    0.4863
   -0.7856    0.2265    0.5757
   -0.7483   -0.2219   -0.6251
   -0.6596    0.1761    0.7307
   -0.5678    0.2059    0.7970
   -0.4902    0.1264    0.8624
   -0.3696    0.2330    0.8995
   -0.6277   -0.7784    0.0020
    0.0688   -0.9925   -0.1015
   -0.3692    0.0059   -0.9293
   -0.5520   -0.0031   -0.8338
   -0.7153    0.0994   -0.6917
    0.0547    0.9981   -0.0277
   -0.7807    0.0274   -0.6243
   -0.8422    0.1859   -0.5060
   -0.8438    0.0767   -0.5312
   -0.9700   -0.1392    0.1994
    0.0243    0.9292    0.3687
    0.3428    0.1021   -0.9338
   -0.9698    0.1217   -0.2112
   -0.9796    0.0023   -0.2008
   -0.9726    0.1985   -0.1212
   -0.9426    0.2438   -0.2284
   -0.9881    0.1531   -0.0128
   -0.9906    0.0993    0.0943
   -0.9668    0.1671    0.1932
   -0.9525    0.0954    0.2891
    0.1838    0.9493    0.2551
   -0.0779    0.9482   -0.3079
   -0.9266    0.0310    0.3748
   -0.8141    0.1087    0.5705
   -0.7419    0.1432    0.6551
   -0.6837    0.0592    0.7274
   -0.5944    0.0936    0.7987
   -0.5288    0.0106    0.8487
    0.1947    0.8177   -0.5418
   -0.1203    0.0842    0.9892
   -0.2392   -0.0348   -0.9703
   -0.5331   -0.1214   -0.8373
   -0.6274   -0.0729   -0.7752
   -0.7094   -0.0238   -0.7044
   -0.2971   -0.8401    0.4539
   -0.6603    0.3729    0.6519
   -0.8314   -0.0490   -0.5535
   -0.8868   -0.0000   -0.4622
   -0.8782   -0.1168   -0.4637
    0.2250    0.5151   -0.8271
   -0.9284   -0.0423   -0.3691
   -0.9590   -0.0857   -0.2702
   -0.9849   -0.1664   -0.0485
   -0.9949   -0.0415   -0.0921
   -0.9967   -0.0784    0.0190
    0.9727    0.2020    0.1144
   -0.9371   -0.1745    0.3022
   -0.9805    0.0459    0.1910
   -0.9204   -0.2783    0.2745
   -0.9306   -0.0793    0.3573
   -0.9648   -0.0392    0.2600
   -0.8851   -0.0446    0.4633
   -0.8366   -0.1300    0.5322
   -0.7741   -0.0963    0.6257
   -0.7063   -0.1805    0.6845
   -0.7017   -0.0616    0.7098
   -0.6282   -0.1448    0.7645
   -0.6198   -0.0262    0.7843
   -0.3585    0.1286    0.9247
   -0.3286    0.0095    0.9444
    0.8513   -0.5228   -0.0450
   -0.4221   -0.1687   -0.8907
   -0.5033   -0.2328   -0.8322
   -0.6043   -0.1916   -0.7734
   -0.6916   -0.1479   -0.7070
   -0.6676   -0.2657   -0.6955
   -0.8182   -0.1718   -0.5486
   -0.7756   -0.6312    0.0074
   -0.6004    0.4779    0.6413
   -0.8319   -0.3501   -0.4305
   -0.3776    0.8432    0.3827
   -0.8932   -0.2817   -0.3505
   -0.9782   -0.1271   -0.1639
   -0.9244   -0.3568   -0.1348
   -0.9602   -0.2740   -0.0540
   -0.9615   -0.2691    0.0556
   -0.9266   -0.3759   -0.0130
   -0.9027   -0.3726    0.2154
    0.2015   -0.9477   -0.2474
    0.1105   -0.9386   -0.3268
   -0.8668   -0.3693    0.3352
   -0.8844   -0.2638    0.3851
   -0.8896   -0.1607    0.4275
   -0.8336   -0.2439    0.4956
    0.5379   -0.1063    0.8363
   -0.7747   -0.2142    0.5950
   -0.7018   -0.2963    0.6478
   -0.6280   -0.2618    0.7329
   -0.4426   -0.0642    0.8944
    0.6113    0.7722    0.1734
   -0.1982    0.0016    0.9802
   -0.1339   -0.0907   -0.9868
   -0.3793    0.1278   -0.9164
   -0.1804   -0.8800    0.4394
   -0.5759   -0.3033   -0.7592
    0.7352    0.2167   -0.6424
   -0.6361   -0.3771   -0.6732
   -0.7958   -0.2903   -0.5314
   -0.7210   -0.3377   -0.6051
   -0.9307    0.2172    0.2944
   -0.7612   -0.4045   -0.5069
   -0.8583   -0.3969   -0.3252
   -0.9143   -0.3224   -0.2452
   -0.8131   -0.5043   -0.2908
   -0.8751   -0.4339   -0.2143
   -0.8841   -0.4579   -0.0937
   -0.8714   -0.4668    0.1507
   -0.3026    0.5880    0.7501
   -0.7077   -0.7044   -0.0539
   -0.3130   -0.2184   -0.9243
   -0.8266   -0.5567    0.0824
   -0.7736   -0.5440    0.3250
   -0.8018   -0.4522    0.3907
   -0.6672   -0.5077    0.5451
   -0.8229   -0.3505    0.4473
   -0.7503   -0.4324    0.5001
   -0.7666   -0.3271    0.5525
   -0.6882   -0.4058    0.6014
   -0.6170   -0.3734    0.6928
   -0.5370   -0.3379    0.7730
   -0.5454   -0.2249    0.8074
   -0.3614   -0.1311    0.9231
    0.1862    0.0975    0.9777
    0.8099   -0.5151   -0.2805
   -0.2807   -0.3295   -0.9015
   -0.4734   -0.3426   -0.8115
   -0.3602   -0.3954   -0.8449
   -0.4335   -0.4484   -0.7816
   -0.5851   -0.4816   -0.6524
   -0.6810   -0.4477   -0.5795
   -0.6209   -0.5448   -0.5637
   -0.7157   -0.5108   -0.4762
   -0.7912   -0.4614   -0.4015
   -0.6655   -0.6451   -0.3753
   -0.7621   -0.5995   -0.2445
   -0.8287   -0.5328   -0.1714
   -0.7750   -0.6207   -0.1193
   -0.8350   -0.5484   -0.0452
   -0.8828   -0.4686    0.0328
   -0.7045   -0.7067    0.0651
   -0.8401    0.5232   -0.1429
   -0.8082   -0.5522    0.2048
   -0.7595   -0.6360    0.1368
   -0.7332   -0.6300    0.2561
   -0.7251   -0.5308    0.4387
   -0.6918   -0.6209    0.3687
   -0.6386   -0.6019    0.4795
    0.1816    0.5116    0.8398
   -0.5742   -0.5752    0.5825
   -0.5987   -0.4782    0.6425
   -0.4409    0.8767    0.1926
   -0.4493   -0.2979    0.8423
   -0.3440   -0.3610    0.8668
   -0.4554   -0.1837    0.8711
    0.7060    0.6205    0.3414
   -0.6464    0.7605   -0.0609
   -0.4609   -0.8136    0.3545
   -0.3483   -0.5175   -0.7816
   -0.4801   -0.5154   -0.7098
    0.3855   -0.7280   -0.5670
   -0.4433   -0.6686   -0.5970
   -0.5190   -0.5817   -0.6263
   -0.5484   -0.6422   -0.5355
   -0.5706   -0.6948   -0.4377
   -0.5131   -0.8117   -0.2790
   -0.5910   -0.7350   -0.3325
   -0.6851   -0.6748   -0.2745
   -0.6104   -0.7600   -0.2233
   -0.6443   -0.7063    0.2932
   -0.7009   -0.6934   -0.1673
   -0.5393   -0.8408   -0.0467
   -0.6223   -0.7738    0.1186
   -0.5425   -0.8367    0.0749
    0.7420   -0.5628    0.3643
   -0.6775   -0.7108    0.1891
   -0.5568   -0.7671    0.3186
   -0.5666    0.7014    0.4324
   -0.8503    0.4630   -0.2501
   -0.5432   -0.6640    0.5138
   -0.4163   -0.5091    0.7533
   -0.3917   -0.6049    0.6933
   -0.3268   -0.4665    0.8219
   -0.2322   -0.4163    0.8791
   -0.3562   -0.2496    0.9005
   -0.2583   -0.1983    0.9455
   -0.0369   -0.0324   -0.9988
   -0.1693   -0.3769   -0.9106
   -0.2599   -0.4420   -0.8585
   -0.4085   -0.5972   -0.6903
   -0.3053   -0.6128   -0.7289
   -0.3658   -0.7533   -0.5466
   -0.9087    0.1493    0.3898
   -0.4702   -0.7288   -0.4977
   -0.3903   -0.8069   -0.4434
    0.7702   -0.5864    0.2510
   -0.4928   -0.7773   -0.3912
   -0.4120   -0.8481   -0.3331
   -0.5297   -0.8322   -0.1641
   -0.4403    0.4121   -0.7977
   -0.4436   -0.8906   -0.1009
   -0.5405   -0.1069    0.8345
   -0.4518   -0.8919    0.0188
   -0.4301   -0.8760   -0.2182
   -0.4708   -0.8469    0.2473
   -0.3706   -0.9051    0.2085
   -0.3700   -0.8702    0.3252
   -0.5663   -0.7973    0.2086
   -0.5071   -0.7436    0.4359
    0.7099   -0.6764    0.1961
   -0.4382   -0.7243    0.5323
   -0.4713   -0.6390    0.6079
   -0.3625   -0.6928    0.6234
   -0.2775   -0.6581    0.6999
   -0.3046   -0.5659    0.7661
   -0.2131   -0.5183    0.8282
   -0.2473   -0.3094    0.9182
   -0.0222    0.9815    0.1900
   -0.0758   -0.3089   -0.9481
    0.5416    0.5314   -0.6514
   -0.9916    0.0770   -0.1040
   -0.1140   -0.5796   -0.8069
   -0.1952   -0.6296   -0.7520
   -0.2553   -0.7698   -0.5850
    0.1120    0.5000   -0.8588
   -0.1665   -0.8309   -0.5310
   -0.2817   -0.8264   -0.4875
   -0.2164   -0.9231   -0.3178
   -0.3056   -0.8724   -0.3815
   -0.3258   -0.9064   -0.2689
   -0.1397   -0.9814   -0.1314
   -0.3417   -0.9274   -0.1519
    0.3688   -0.9256    0.0851
   -0.3534   -0.9349   -0.0320
   -0.7076    0.2605    0.6568
   -0.2484   -0.9649   -0.0853
   -0.2651   -0.9531    0.1462
   -0.3643   -0.9269    0.0900
   -0.2692   -0.8925    0.3620
   -0.3948   -0.2837   -0.8738
   -0.9503    0.0483   -0.3074
   -0.3290   -0.7715    0.5445
   -0.2137   -0.8165    0.5362
   -0.2461   -0.7419    0.6237
    0.9062    0.1385    0.3996
   -0.1889   -0.6144    0.7661
   -0.0981   -0.5588    0.8235
   -0.1183   -0.4584    0.8808
   -0.1353   -0.3521    0.9261
    0.0475   -0.3508   -0.9352
   -0.0508   -0.4132   -0.9092
   -0.0245   -0.5115   -0.8589
   -0.9516   -0.2559    0.1704
   -0.1051   -0.6875   -0.7185
   -0.2257   -0.7038   -0.6736
   -0.1380   -0.7662   -0.6276
   -0.0767   -0.8832   -0.4627
    0.0175   -0.9175   -0.3974
   -0.1933   -0.8830   -0.4278
   -0.1029   -0.9276   -0.3592
   -0.0098   -0.9567   -0.2909
   -0.0292   -0.9840   -0.1756
    0.8777   -0.0262   -0.4785
   -0.2347   -0.9507   -0.2029
   -0.1501   -0.9886   -0.0139
    0.1662   -0.8336   -0.5267
   -0.0405   -0.9975   -0.0578
   -0.0508   -0.9834    0.1740
    0.0519   -0.9679    0.2459
   -0.1557   -0.9826    0.1017
    0.0371   -0.9317    0.3613
   -0.0723   -0.9124    0.4028
    0.0139   -0.8808    0.4734
   -0.0967   -0.8531    0.5127
   -0.0126   -0.8151    0.5792
   -0.1289   -0.7833    0.6082
   -0.0434   -0.7389    0.6724
   -0.0726   -0.6528    0.7541
    0.0163   -0.5916    0.8061
   -0.0223   -0.3890    0.9209
   -0.0388   -0.2781    0.9598
   -0.0018   -0.1375   -0.9905
   -0.0077   -0.6069   -0.7947
    0.0061   -0.6891   -0.7246
   -0.0237   -0.7624   -0.6466
   -0.0498   -0.8280   -0.5586
    0.0725   -0.8041   -0.5900
    0.0220    0.5772   -0.8163
   -0.1002   -0.1994   -0.9748
    0.0457   -0.8667   -0.4967
    0.1397   -0.8925   -0.4288
    0.2301   -0.9080   -0.3500
    0.0824   -0.9724   -0.2184
    0.1784   -0.9732   -0.1449
    0.0652   -0.9978    0.0141
   -0.1635   -0.9306    0.3275
    0.1691   -0.9823    0.0811
    0.0590   -0.9898    0.1300
    0.1603   -0.9671    0.1976
   -0.8609   -0.2341   -0.4517
    0.1467   -0.9377    0.3149
    0.1258   -0.8945    0.4290
   -0.5201    0.3190    0.7923
    0.0987   -0.8378    0.5370
    0.1813   -0.7840    0.5937
    0.0708   -0.7659    0.6390
    0.1533   -0.7060    0.6914
    0.0418   -0.6832    0.7290
   -0.0040   -0.4935    0.8697
    0.1100   -0.5226    0.8455
   -0.0854   -0.0362    0.9957
   -0.9573   -0.2404   -0.1603
    0.0732   -0.4517   -0.8892
    0.1894   -0.4854   -0.8535
    0.2057   -0.5827   -0.7862
    0.1020   -0.7311   -0.6746
    0.1950   -0.7634   -0.6158
    0.2848   -0.7876   -0.5464
    0.9667   -0.2206    0.1300
    0.2556   -0.8537   -0.4537
    0.3069   -0.9196   -0.2455
   -0.4356   -0.4065    0.8032
   -0.9165   -0.1621   -0.3658
    0.2811   -0.9530   -0.1128
    0.2758   -0.9611    0.0160
   -0.9243   -0.3671    0.1047
    0.1762   -0.9838   -0.0338
    0.2670   -0.9536    0.1392
    0.2534   -0.9316    0.2604
    0.3572   -0.9113    0.2049
    0.2336   -0.2057   -0.9503
   -0.0703    0.2818    0.9569
    0.2356   -0.8949    0.3791
    0.3205   -0.8390    0.4397
    0.2950   -0.7839    0.5463
    0.6090    0.3156    0.7276
    0.2617   -0.7197    0.6431
    0.2373   -0.6364    0.7340
    0.3336   -0.5625    0.7565
    0.1285   -0.6175    0.7760
    0.0913   -0.4211    0.9024
   -0.9823   -0.1656    0.0874
    0.1409   -0.2755   -0.9509
    0.1674   -0.3825   -0.9087
    0.2825   -0.4170   -0.8639
    0.3002   -0.5178   -0.8011
    0.3053   -0.6157   -0.7264
    0.4160    0.4393   -0.7962
    0.3978   -0.6410   -0.6564
    0.4836   -0.6581   -0.5771
    0.3357   -0.8673   -0.3675
    0.4483   -0.8108   -0.3764
    0.3766   -0.9131   -0.1564
    0.5231   -0.8049   -0.2802
    0.4717   -0.8599   -0.1952
    0.4709   -0.8785   -0.0807
    0.5626   -0.8263   -0.0268
    0.4680   -0.8831    0.0342
   -0.2701   -0.0820    0.9593
    0.6463   -0.7581   -0.0868
    0.4592   -0.8755    0.1505
    0.9705    0.0071    0.2409
    0.4429   -0.8560    0.2666
    0.4218   -0.8223    0.3820
    0.6836   -0.0874   -0.7246
    0.5943   -0.7131    0.3719
    0.4158    0.6789    0.6051
    0.4723   -0.6849    0.5548
    0.3433   -0.6455    0.6823
    0.4402   -0.6000    0.6679
   -0.4640   -0.8747    0.1404
    0.2225   -0.5455    0.8080
    0.1846   -0.3431    0.9210
    0.0725   -0.3126    0.9471
    0.1134   -0.1624   -0.9802
    0.2599   -0.3125   -0.9137
    0.3893   -0.4438   -0.8072
    0.3995   -0.5460   -0.7364
    0.4907   -0.5678   -0.6610
    0.5750   -0.5816   -0.5754
    0.5633   -0.6654   -0.4898
    0.4649   -0.7401   -0.4860
    0.6381   -0.6607   -0.3954
    0.5379   -0.7421   -0.4001
    0.6284   -0.7501   -0.2060
   -0.0006    0.0683   -0.9977
    0.5603   -0.8152   -0.1468
    0.7129   -0.6832   -0.1581
    0.7250   -0.6877   -0.0371
    0.5569   -0.8256    0.0907
    0.6465   -0.7623    0.0301
   -0.6025   -0.6878    0.4049
    0.6377   -0.7564    0.1456
    0.5437   -0.8134    0.2069
    0.5226   -0.7896    0.3217
    0.6883   -0.6565    0.3087
    0.4963   -0.7508    0.4358
    0.5605   -0.6724    0.4834
    0.6172   -0.5855    0.5256
    0.5299   -0.5994    0.5999
    0.4262   -0.5026    0.7521
    0.3171   -0.4712    0.8230
    0.2960   -0.3699    0.8806
    0.3254    0.3706    0.8700
    0.2734   -0.2613    0.9257
    0.0227   -0.2456   -0.9691
    0.3466   -0.2298   -0.9094
    0.3707   -0.3385   -0.8648
    0.4852   -0.4675   -0.7389
    0.5656   -0.3816   -0.7310
    0.5722   -0.4854   -0.6611
    0.6507   -0.4961   -0.5748
   -0.6469   -0.5997   -0.4710
    0.6536   -0.5861   -0.4788
    0.7227   -0.5897   -0.3604
    0.6922   -0.6657   -0.2786
    0.5536    0.7568   -0.3475
    0.7668   -0.6005   -0.2270
   -0.3374   -0.6887   -0.6418
    0.7870   -0.6081   -0.1043
    0.7939   -0.6078    0.0170
    0.8520   -0.5182    0.0741
   -0.0560   -0.1604    0.9855
    0.6203   -0.7401    0.2597
   -0.5210   -0.4451    0.7283
   -0.3986   -0.8014    0.4459
   -0.6233   -0.7740   -0.1118
    0.6569   -0.6272    0.4184
    0.6161   -0.5079    0.6020
    0.8124   -0.0097   -0.5830
    0.8995   -0.3259   -0.2910
    0.5899   -0.4194    0.6900
    0.4033   -0.3977    0.8241
    0.3820   -0.2891    0.8778
    0.3559   -0.1772    0.9176
    0.0528   -0.1969    0.9790
    0.3185   -0.1174   -0.9406
    0.4526   -0.2528   -0.8551
    0.4730   -0.3616   -0.8034
    0.7257   -0.4040   -0.5570
    0.5507   -0.2732   -0.7887
    0.6498   -0.3962   -0.6487
   -0.5597    0.1185   -0.8202
    0.8513   -0.2198   -0.4765
    0.5208   -0.5129    0.6824
    0.7924   -0.4048   -0.4563
    0.0445    0.6696   -0.7414
    0.7757   -0.4992   -0.3861
    0.8755   -0.4266   -0.2268
   -0.1600   -0.7031    0.6929
    0.8962   -0.4305   -0.1073
    0.8379   -0.5206   -0.1639
    0.9033   -0.4288    0.0128
    0.3760   -0.7087    0.5969
    0.8979   -0.4199    0.1319
    0.8503   -0.3829    0.3610
    0.8178   -0.4883    0.3046
    0.5998    0.0042    0.8001
    0.7826   -0.4640    0.4151
    0.7314   -0.4393    0.5217
    0.7479   -0.3310    0.5753
    0.6734   -0.4159    0.6112
    0.6680   -0.3180    0.6728
    0.5797   -0.3178    0.7503
    0.4998   -0.4132    0.7612
   -0.5288    0.5726    0.6265
    0.4338   -0.0891    0.8966
    0.2458   -0.1465    0.9582
    0.0798   -0.0428   -0.9959
    0.4256   -0.1407   -0.8939
    0.9894   -0.1356   -0.0516
    0.3743    0.9271    0.0177
    0.6213   -0.1816   -0.7622
    0.7071   -0.1975   -0.6790
    0.7839   -0.2094   -0.5845
    0.7935   -0.3097   -0.5239
    0.8974   -0.1292   -0.4220
    0.9054   -0.2280   -0.3581
    0.8548   -0.3171   -0.4108
    0.9433   -0.2341   -0.2352
    0.9269   -0.3341   -0.1711
    0.9649   -0.2374   -0.1122
    0.8805   -0.4041    0.2479
    0.9725   -0.2328    0.0104
    0.9411   -0.3345   -0.0494
    0.9899   -0.1241    0.0687
    0.9419   -0.3281    0.0716
    0.4439    0.0755   -0.8929
    0.9302   -0.3143    0.1898
   -0.2588   -0.9654    0.0323
    0.9053   -0.2956    0.3051
    0.8057   -0.3593    0.4710
    0.8132   -0.2509    0.5251
    0.7396   -0.2305    0.6324
    0.7213   -0.1275    0.6807
    0.6542   -0.2159    0.7249
   -0.7617    0.0246    0.6475
    0.5081    0.0016    0.8613
    0.9005    0.3921   -0.1881
    0.2894   -0.0006   -0.9572
    0.3935   -0.0238   -0.9190
    0.4940   -0.0464   -0.8682
    0.5929   -0.0697   -0.8023
    0.7363    0.0076   -0.6766
    0.7649   -0.1030   -0.6358
    0.8366   -0.1180   -0.5349
    0.7713    0.4042   -0.4916
    0.8043    0.3558    0.4760
   -0.1240   -0.9609   -0.2477
    0.9440   -0.1359   -0.3007
    0.9701   -0.0408   -0.2393
    0.9747   -0.1385   -0.1756
    0.9928   -0.0379   -0.1140
    0.9996   -0.0261    0.0061
    0.9957    0.0727   -0.0575
   -0.1601   -0.9633    0.2154
    0.9919   -0.0126    0.1261
    0.9762   -0.1091    0.1874
    0.9473   -0.2038    0.2472
    0.9144   -0.1837    0.3607
    0.9491   -0.0894    0.3019
    0.8665   -0.2742    0.4171
    0.8670   -0.1637    0.4707
    0.8020   -0.1479    0.5787
    0.8877    0.3550   -0.2931
    0.6933   -0.0221    0.7203
    0.6313   -0.1092    0.7678
   -0.0455   -0.9973    0.0585
    0.3250   -0.0616    0.9437
    0.1355   -0.1114    0.9845

================================================
FILE: adjust.m
================================================
function adj = adjust(img,percen)
%Contrast stretch utility function. Clip percen percentages of the pixels,
%while avoiding a drastic change to the white-balance.
% 
% This is a utility function used by the non-local image dehazing algorithm
% described in the paper:
% Non-Local Image Dehazing. Berman, D. and Treibitz, T. and Avidan S., CVPR2016,
% which can be found at:
% www.eng.tau.ac.il/~berman/NonLocalDehazing/NonLocalDehazing_CVPR2016.pdf
% If you use this code, please cite our paper.
% 
% The software code of the Non-Local Image Dehazing algorithm is provided
% under the attached LICENSE.md

if ~exist('percen','var') || isempty(percen), percen=[0.01 0.99]; end;

% linear contrast stretch to [0,1], identical on all colors
minn=min(img(:));
img=img-minn;
img=img./max(img(:));

% limit the change magnitude so the WB would not be drastically changed
contrast_limit = stretchlim(img,percen);
val = 0.2;
contrast_limit(2,:) = max(contrast_limit(2,:), 0.2);
contrast_limit(2,:) = val*contrast_limit(2,:) + (1-val)*max(contrast_limit(2,:), mean(contrast_limit(2,:)));
contrast_limit(1,:) = val*contrast_limit(1,:) + (1-val)*min(contrast_limit(1,:), mean(contrast_limit(1,:)));
adj=imadjust(img,contrast_limit,[],1);


================================================
FILE: demo_non_local_dehazing.m
================================================
% This is a demo script demonstrating the non-local image dehazing algorithm
% described in the paper:
% Non-Local Image Dehazing. Berman, D. and Treibitz, T. and Avidan S., CVPR2016,
% which can be found at:
% www.eng.tau.ac.il/~berman/NonLocalDehazing/NonLocalDehazing_CVPR2016.pdf
% If you use this code, please cite our paper.
% 
% Please read the instructions on README.md in order to use this code.
%
% Author: Dana Berman, 2016. 
% 
% The software code of the Non-Local Image Dehazing algorithm is provided
% under the attached LICENSE.md


% Choose image to use, four example image are supplied with the code in the
% sub-folder "images":
image_name = 'pumpkins'; % 'train'; % 'cityscape'; % 'forest'; % 
img_hazy = imread(['images/',image_name,'_input.png']);

% Load the gamma from the param file. 
% These values were given by Ra'anan Fattal, along with each image:
% http://www.cs.huji.ac.il/~raananf/projects/dehaze_cl/results/
fid = fopen(['images/',image_name,'_params.txt'],'r');
[C] = textscan(fid,'%s %f');
fclose(fid);
gamma = C{2}(1);

% Estimate air-light using our method described in:
% Air-light Estimation using Haze-Lines. Berman, D. and Treibitz, T. and 
% Avidan S., ICCP 2017
A = reshape(estimate_airlight(im2double(img_hazy).^(gamma)),1,1,3);

% Dehaze the image	
[img_dehazed, trans_refined] = non_local_dehazing(img_hazy, A, gamma );

% Display results
figure('Position',[50,50, size(img_hazy,2)*3 , size(img_hazy,1)]);
subplot(1,3,1); imshow(img_hazy);    title('Hazy input')
subplot(1,3,2); imshow(img_dehazed); title('De-hazed output')
subplot(1,3,3); imshow(trans_refined); colormap('jet'); title('Transmission')


================================================
FILE: estimate_airlight.m
================================================
function [ Aout ] = estimate_airlight( img, Amin, Amax, N, spacing, K, thres )
%Estimate airlight of an image, using a 3*2D Hough transform, where each
%point votes for a given location using a fixed set of angles.
%
%   This is an implementation of our paper:
%   Dana Berman, Tali Treibitz, Shai Avidan,
%   "Air-light Estimation using Haze-Lines", ICCP 2017
%   
%   Input arguments:
%   img - input image (mandatory)
%   Amin (Amax) - minimal (maximal) value if the air-light. Optional
%               Can be used to reduce the search space and save time
%               Either a scalar (identical for all color channels) or a 3
%               value vector (different range for each color channel)
%   N - number of colors clusters to use (the image is converted to an
%       indexed image of at most N different cluster). Optional
%   spacing - air-light candidates' resolution, 1/M in the paper. Optional
%   K - angular resolution. Optional
%   thres - cone resolution, optional, default recommended


%% Verify input params, set defaults when necessary (same as published results)
if ~exist('thres','var') || isempty(thres), thres = 0.01 ; end;
if ~exist('spacing','var') || isempty(spacing), spacing = 0.02 ; end; %1/M in the paper
if ~exist('n_colors','var') || isempty(N), N = 1000 ; end; %number of colors clusters
if ~exist('K','var') || isempty(K), K = 40 ; end; %number of angles

% Define search range for the air-light. The search range is different for each 
% color channel. These values were used in all of our experiments.
if ~exist('Amin','var') || isempty(Amin), Amin = [0,0.05,0.1]; end;
if ~exist('Amax','var') || isempty(Amax), Amax = 1; end;

% Air-light search range, accept a scalar if identical for all color channels
if isscalar(Amin), Amin = repmat(Amin,1,3); end 
if isscalar(Amax), Amax = repmat(Amax,1,3); end

%% Convert input image to an indexed image
[img_ind, points] = rgb2ind(img, N);
[h,w,~] = size(img);
% Remove empty clusters
idx_in_use = unique(img_ind(:));
idx_to_remove = setdiff(0:(size(points,1)-1),idx_in_use);
points(idx_to_remove+1,:) = [];
img_ind_sequential = zeros(h,w);
for kk = 1:length(idx_in_use)
    img_ind_sequential(img_ind==idx_in_use(kk)) = kk;
end
% Now the min value of img_ind_sequential is 1 rather then 0, and the indices
% correspond to points

% Count the occurences if each index - this is the clusters' weight
[points_weight,~] = histcounts(img_ind_sequential(:),size(points,1));
points_weight = points_weight./(h*w);
if ~ismatrix(points), points = reshape(points,[],3); end % verify dim

%% Define arrays of candidate air-light values and angles
angle_list = reshape(linspace(0, pi, K),[],1);
% Use angle_list(1:end-1) since angle_list(end)==pi, which is the same line
% in 2D as since angle_list(1)==0
directions_all = [sin(angle_list(1:end-1)) , cos(angle_list(1:end-1)) ];

% Air-light candidates in each color channel
ArangeR = Amin(1):spacing:Amax(1);
ArangeG = Amin(2):spacing:Amax(2);
ArangeB = Amin(3):spacing:Amax(3);

%% Estimate air-light in each pair of color channels
% Estimate RG
Aall = generate_Avals(ArangeR, ArangeG);
[~, AvoteRG] = vote_2D(points(:,1:2), points_weight, directions_all, Aall, thres );
% Estimate GB
Aall = generate_Avals(ArangeG, ArangeB);
[~, AvoteGB] = vote_2D(points(:,2:3), points_weight, directions_all, Aall, thres );
% Estimate RB
Aall = generate_Avals(ArangeR, ArangeB);
[~, AvoteRB] = vote_2D(points(:,[1,3]), points_weight, directions_all, Aall, thres);

%% Find most probable airlight from marginal probabilities (2D arrays)
% Normalize (otherwise the numbers are quite large)
max_val = max( [max(AvoteRB(:)) , max(AvoteRG(:)) , max(AvoteGB(:)) ]);
AvoteRG2 = AvoteRG./max_val;
AvoteGB2 = AvoteGB./max_val;
AvoteRB2 = AvoteRB./max_val;
% Generate 3D volumes from 3 different 2D arrays
A11 = repmat( reshape(AvoteRG2, length(ArangeG),length(ArangeR))', 1,1,length(ArangeB));
tmp = reshape(AvoteRB2, length(ArangeB),length(ArangeR))';
A22 = repmat(reshape(tmp, length(ArangeR),1,length(ArangeB)) , 1,length(ArangeG),1);
tmp2 = reshape(AvoteGB2, length(ArangeB),length(ArangeG))';
A33 = repmat(reshape(tmp2, 1, length(ArangeG),length(ArangeB)) , length(ArangeR),1,1);
AvoteAll = A11.*A22.*A33;
[~, idx] = max(AvoteAll(:));
[idx_r,idx_g,idx_b] = ind2sub([length(ArangeR),length(ArangeG),length(ArangeB)],idx);
Aout = [ArangeR(idx_r), ArangeG(idx_g), ArangeB(idx_b)];


end % function estimate_airlight_2D

%% Sub functions

function Aall = generate_Avals(Avals1, Avals2)
%Generate a list of air-light candidates of 2-channels, using two lists of
%values in a single channel each
%Aall's length is length(Avals1)*length(Avals2)
Avals1 = reshape(Avals1,[],1);
Avals2 = reshape(Avals2,[],1);
A1 = kron(Avals1, ones(length(Avals2),1));
A2 = kron(ones(length(Avals1),1), Avals2);
Aall = [A1, A2];
end % function generate_Avals

function [Aout, Avote2] = vote_2D(points, points_weight, directions_all, Aall, thres)
n_directions = size(directions_all,1);
accumulator_votes_idx = false(size(Aall,1), size(points,1), n_directions);
for i_point = 1:size(points,1)
    for i_direction = 1:n_directions
		 % save time and ignore irelevant points from the get-go
        idx_to_use = find( (Aall(:, 1) > points(i_point, 1)) & (Aall(:, 2) > points(i_point, 2)));
        if isempty(idx_to_use), continue; end
		
        % calculate distance between all A options and the line defined by
        % i_point and i_direction. If the distance is smaller than a thres,
        % increase the cell in accumulator
        dist1 = sqrt(sum([Aall(idx_to_use, 1)-points(i_point, 1), Aall(idx_to_use, 2)-points(i_point, 2)].^2,2));
        %dist1 = dist1 - min(dist1);
        dist1 = dist1./sqrt(2) + 1;
        
        dist =  -points(i_point, 1)*directions_all(i_direction,2) + ...
            points(i_point, 2)*directions_all(i_direction,1) + ...
            Aall(idx_to_use, 1)*directions_all(i_direction,2) - ...
            Aall(idx_to_use, 2)*directions_all(i_direction,1);
        idx = abs(dist)<2*thres.*dist1;
        if ~any(idx), continue; end

        idx_full = idx_to_use(idx);
        accumulator_votes_idx(idx_full, i_point,i_direction) = true;
    end
end
% use only haze-lined that are supported by 2 points or more
accumulator_votes_idx2 = (sum(uint8(accumulator_votes_idx),2))>=2; 
accumulator_votes_idx = bsxfun(@and, accumulator_votes_idx ,accumulator_votes_idx2);
accumulator_unique = zeros(size(Aall,1),1);
for iA = 1:size(Aall,1)
    idx_to_use = find(Aall(iA, 1) > points(:, 1) & (Aall(iA, 2) > points(:, 2)));
    points_dist = sqrt((Aall(iA,1) - points(idx_to_use,1)).^2+(Aall(iA,2) - points(idx_to_use,2)).^2);
    points_weight_dist = points_weight(idx_to_use).*(5.*exp(-reshape(points_dist,1,[]))+1); 
    accumulator_unique(iA) = sum(points_weight_dist(any(accumulator_votes_idx(iA,idx_to_use,:),3)));
end
[~, Aestimate_idx] = max(accumulator_unique);
Aout = Aall(Aestimate_idx,:);
Avote2 = accumulator_unique; 

end % function vote_2D


================================================
FILE: images/cityscape_params.txt
================================================
gamma 1.6
A1 0.81
A2 0.81
A3 0.82

================================================
FILE: images/forest_params.txt
================================================
gamma 1
A1 0.805
A2 0.817
A3 0.83

================================================
FILE: images/pumpkins_params.txt
================================================
gamma 1
A1 0.72
A2 0.785
A3 0.81

================================================
FILE: images/train_params.txt
================================================
gamma 1.5
A1 0.53
A2 0.53
A3 0.53

================================================
FILE: non_local_dehazing.m
================================================
function [img_dehazed, transmission] = non_local_dehazing(img_hazy, air_light, gamma)
%The core implementation of "Non-Local Image Dehazing", CVPR 2016
% 
% The details of the algorithm are described in our paper: 
% Non-Local Image Dehazing. Berman, D. and Treibitz, T. and Avidan S., CVPR2016,
% which can be found at:
% www.eng.tau.ac.il/~berman/NonLocalDehazing/NonLocalDehazing_CVPR2016.pdf
% If you use this code, please cite the paper.
%
%   Input arguments:
%   ----------------
%	img_hazy     - A hazy image in the range [0,255], type: uint8
%	air_light    - As estimated by prior methods, normalized to the range [0,1]
%	gamma        - Radiometric correction. If empty, 1 is assumed
%
%   Output arguments:
%   ----------------
%   img_dehazed  - The restored radiance of the scene (uint8)
%   transmission - Transmission map of the scene, in the range [0,1]
%
% Author: Dana Berman, 2016. 
%
% The software code of the Non-Local Image Dehazing algorithm is provided
% under the attached LICENSE.md


%% Validate input
[h,w,n_colors] = size(img_hazy);
if (n_colors ~= 3) % input verification
    error(['Non-Local Dehazing reuires an RGB image, while input ',...
        'has only ',num2str(n_colors),' dimensions']);
end

if ~exist('air_light','var') || isempty(air_light) || (numel(air_light)~=3)
    error('Dehazing on sphere requires an RGB airlight');
end

if ~exist('gamma','var') || isempty(gamma), gamma = 1; end

img_hazy = im2double(img_hazy);
img_hazy_corrected = img_hazy.^gamma; % radiometric correction


%% Find Haze-lines
% Translate the coordinate system to be air_light-centric (Eq. (3))
dist_from_airlight = double(zeros(h,w,n_colors));
for color_idx=1:n_colors
    dist_from_airlight(:,:,color_idx) = img_hazy_corrected(:,:,color_idx) - air_light(:,:,color_idx);
end

% Calculate radius (Eq. (5))
radius = sqrt( dist_from_airlight(:,:,1).^2 + dist_from_airlight(:,:,2).^2 +dist_from_airlight(:,:,3).^2 );

% Cluster the pixels to haze-lines
% Use a KD-tree impementation for fast clustering according to their angles
dist_unit_radius = reshape(dist_from_airlight,[h*w,n_colors]);
dist_norm = sqrt(sum(dist_unit_radius.^2,2));
dist_unit_radius = bsxfun(@rdivide, dist_unit_radius, dist_norm);
n_points = 1000;
% load pre-calculated uniform tesselation of the unit-sphere
fid = fopen(['TR',num2str(n_points),'.txt']);
points = cell2mat(textscan(fid,'%f %f %f')) ;
fclose(fid);
mdl = KDTreeSearcher(points);
ind = knnsearch(mdl, dist_unit_radius);


%% Estimating Initial Transmission

% Estimate radius as the maximal radius in each haze-line (Eq. (11))
K = accumarray(ind,radius(:),[n_points,1],@max);
radius_new = reshape( K(ind), h, w);
    
% Estimate transmission as radii ratio (Eq. (12))
transmission_estimation = radius./radius_new;

% Limit the transmission to the range [trans_min, 1] for numerical stability
trans_min = 0.1;
transmission_estimation = min(max(transmission_estimation, trans_min),1);


%% Regularization

% Apply lower bound from the image (Eqs. (13-14))
trans_lower_bound = 1 - min(bsxfun(@rdivide,img_hazy_corrected,reshape(air_light,1,1,3)) ,[],3);
transmission_estimation = max(transmission_estimation, trans_lower_bound);
 
% Solve optimization problem (Eq. (15))
% find bin counts for reliability - small bins (#pixels<50) do not comply with 
% the model assumptions and should be disregarded
bin_count       = accumarray(ind,1,[n_points,1]);
bin_count_map   = reshape(bin_count(ind),h,w);
bin_eval_fun    = @(x) min(1, x/50);

% Calculate std - this is the data-term weight of Eq. (15)
K_std = accumarray(ind,radius(:),[n_points,1],@std);
radius_std = reshape( K_std(ind), h, w);
radius_eval_fun = @(r) min(1, 3*max(0.001, r-0.1));
radius_reliability = radius_eval_fun(radius_std./max(radius_std(:)));
data_term_weight   = bin_eval_fun(bin_count_map).*radius_reliability;
lambda = 0.1;
transmission = wls_optimization(transmission_estimation, data_term_weight, img_hazy, lambda);


%% Dehazing
% (Eq. (16))
img_dehazed = zeros(h,w,n_colors);
leave_haze = 1.06; % leave a bit of haze for a natural look (set to 1 to reduce all haze)
for color_idx = 1:3
    img_dehazed(:,:,color_idx) = ( img_hazy_corrected(:,:,color_idx) - ...
        (1-leave_haze.*transmission).*air_light(color_idx) )./ max(transmission,trans_min);
end

% Limit each pixel value to the range [0, 1] (avoid numerical problems)
img_dehazed(img_dehazed>1) = 1;
img_dehazed(img_dehazed<0) = 0;
img_dehazed = img_dehazed.^(1/gamma); % radiometric correction

% For display, we perform a global linear contrast stretch on the output, 
% clipping 0.5% of the pixel values both in the shadows and in the highlights 
adj_percent = [0.005, 0.995];
img_dehazed = adjust(img_dehazed,adj_percent);

img_dehazed = im2uint8(img_dehazed);

end % function non_local_dehazing


================================================
FILE: wls_optimization.m
================================================
function out = wls_optimization(in, data_weight, guidance, lambda)
%Weighted Least Squares optimization solver.
% Given an input image IN, we seek a new image OUT, which, on the one hand,
% is as close as possible to IN, and, at the same time, is as smooth as
% possible everywhere, except across significant gradients in the hazy image.
%
%  Input arguments:
%  ----------------
%  in             - Input image (2-D, double, N-by-M matrix).   
%  data_weight    - High values indicate it is accurate, small values
%                   indicate it's not.
%  guidance       - Source image for the affinity matrix. Same dimensions
%                   as the input image IN. Default: log(IN)
%  lambda         - Balances between the data term and the smoothness
%                   term. Increasing lambda will produce smoother images.
%                   Default value is 0.05 
%
% This function is based on the implementation of the WLS Filer by Farbman,
% Fattal, Lischinski and Szeliski, "Edge-Preserving Decompositions for 
% Multi-Scale Tone and Detail Manipulation", ACM Transactions on Graphics, 2008
% The original function can be downloaded from: 
% http://www.cs.huji.ac.il/~danix/epd/wlsFilter.m


small_num = 0.00001;

if ~exist('lambda','var') || isempty(lambda), lambda = 0.05; end

[h,w,~] = size(guidance);
k = h*w;
guidance = rgb2gray(guidance);

% Compute affinities between adjacent pixels based on gradients of guidance
dy = diff(guidance, 1, 1);
dy = -lambda./(sum(abs(dy).^2,3) + small_num);
dy = padarray(dy, [1 0], 'post');
dy = dy(:);

dx = diff(guidance, 1, 2); 
dx = -lambda./(sum(abs(dx).^2,3) + small_num);
dx = padarray(dx, [0 1], 'post');
dx = dx(:);


% Construct a five-point spatially inhomogeneous Laplacian matrix
B = [dx, dy];
d = [-h,-1];
tmp = spdiags(B,d,k,k);

ea = dx;
we = padarray(dx, h, 'pre'); we = we(1:end-h);
so = dy;
no = padarray(dy, 1, 'pre'); no = no(1:end-1);

D = -(ea+we+so+no);
Asmoothness = tmp + tmp' + spdiags(D, 0, k, k);

% Normalize data weight
data_weight = data_weight - min(data_weight(:)) ;
data_weight = 1.*data_weight./(max(data_weight(:))+small_num);

% Make sure we have a boundary condition for the top line:
% It will be the minimum of the transmission in each column
% With reliability 0.8
reliability_mask = data_weight(1,:) < 0.6; % find missing boundary condition
in_row1 = min( in,[], 1);
data_weight(1,reliability_mask) = 0.8;
in(1,reliability_mask) = in_row1(reliability_mask);

Adata = spdiags(data_weight(:), 0, k, k);

A = Adata + Asmoothness;
b = Adata*in(:);

% Solve
% out = lsqnonneg(A,b);
out = A\b;
out = reshape(out, h, w);
Download .txt
gitextract_35gc0cc4/

├── .gitignore
├── LICENSE.md
├── README.md
├── TR1000.txt
├── adjust.m
├── demo_non_local_dehazing.m
├── estimate_airlight.m
├── images/
│   ├── cityscape_params.txt
│   ├── forest_params.txt
│   ├── pumpkins_params.txt
│   └── train_params.txt
├── non_local_dehazing.m
└── wls_optimization.m
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (67K chars).
[
  {
    "path": ".gitignore",
    "chars": 5,
    "preview": "*.asv"
  },
  {
    "path": "LICENSE.md",
    "chars": 14058,
    "preview": "#LICENSE\nBy exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions"
  },
  {
    "path": "README.md",
    "chars": 2403,
    "preview": "# Non-Local Image Dehazing\n\n<img height=\"285px\" width=\"200px\" align=\"right\" src=\"http://www.eng.tau.ac.il/~berman/images"
  },
  {
    "path": "TR1000.txt",
    "chars": 30999,
    "preview": "   -0.9425   -0.2041   -0.2648\n    0.5224    0.7539    0.3985\n    0.5528    0.0429   -0.8322\n    0.6499    0.0243   -0.7"
  },
  {
    "path": "adjust.m",
    "chars": 1228,
    "preview": "function adj = adjust(img,percen)\n%Contrast stretch utility function. Clip percen percentages of the pixels,\n%while avoi"
  },
  {
    "path": "demo_non_local_dehazing.m",
    "chars": 1649,
    "preview": "% This is a demo script demonstrating the non-local image dehazing algorithm\n% described in the paper:\n% Non-Local Image"
  },
  {
    "path": "estimate_airlight.m",
    "chars": 6967,
    "preview": "function [ Aout ] = estimate_airlight( img, Amin, Amax, N, spacing, K, thres )\n%Estimate airlight of an image, using a 3"
  },
  {
    "path": "images/cityscape_params.txt",
    "chars": 34,
    "preview": "gamma 1.6\nA1 0.81\nA2 0.81\nA3 0.82"
  },
  {
    "path": "images/forest_params.txt",
    "chars": 34,
    "preview": "gamma 1\nA1 0.805\nA2 0.817\nA3 0.83"
  },
  {
    "path": "images/pumpkins_params.txt",
    "chars": 33,
    "preview": "gamma 1\nA1 0.72\nA2 0.785\nA3 0.81"
  },
  {
    "path": "images/train_params.txt",
    "chars": 34,
    "preview": "gamma 1.5\nA1 0.53\nA2 0.53\nA3 0.53"
  },
  {
    "path": "non_local_dehazing.m",
    "chars": 4789,
    "preview": "function [img_dehazed, transmission] = non_local_dehazing(img_hazy, air_light, gamma)\n%The core implementation of \"Non-L"
  },
  {
    "path": "wls_optimization.m",
    "chars": 2611,
    "preview": "function out = wls_optimization(in, data_weight, guidance, lambda)\n%Weighted Least Squares optimization solver.\n% Given "
  }
]

About this extraction

This page contains the full source code of the danaberman/non-local-dehazing GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (63.3 KB), approximately 28.1k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!