pyllusion


Namepyllusion JSON
Version 1.3 PyPI version JSON
download
home_pagehttps://github.com/RealityBending/Pyllusion/
SummaryA Parametric Framework to Generate Visual Illusions.
upload_time2024-08-29 09:43:00
maintainerDominique Makowski
docs_urlNone
authorDominique Makowski
requires_pythonNone
licenseMozilla Public License Version 2.0
keywords python pyllusion visual optical illusions
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            
![](https://github.com/RealityBending/Pyllusion/blob/master/docs/img/logo.png)
![](https://img.shields.io/pypi/pyversions/pyllusion.svg?logo=python&logoColor=FFE873)
[![Tests](https://github.com/RealityBending/Pyllusion/actions/workflows/tests.yml/badge.svg)](https://github.com/RealityBending/Pyllusion/actions/workflows/tests.yml)
[![](https://img.shields.io/badge/paper-Pyllusion-9C27B0)](https://journals.sagepub.com/doi/10.1177/03010066211057347)

**A Parametric Framework to Generate Visual Illusions using Python**

# Overview

Visual illusions are fascinating phenomena that have been used and
studied by artists and scientists for centuries, leading to important
discoveries about how conscious perception is generated by the brain.
Instead of crafting them by hand, **Pyllusion** offers a framework to
manipulate and generate illusions in a systematic way.

The parametric approach implemented in this software proposes to
**describe illusions using a set of parameters**, such as for instance
the *difference* and *illusion strength*. These two parameters can be
modulated to independently impact either the objective difference of the
core components of the illusion (e.g., the difference between the two
segments in the [Müller-Lyer](#müller-lyer-illusion-illusion) illusion)
or the intensity of the illusion effect (e.g., the angle of the
“distractors” arrows).

Describing illusions using a set of parameters aims at fostering
**reproducible science**, allowing neuroscientists to easily report,
generate and manipulate similar stimuli regardless of the display format
and software.

## Installation

    pip install https://github.com/RealityBending/Pyllusion/zipball/master

You can also find the installation instructions for Python 3
[here](https://realpython.com/installing-python/).

## Contribution

You have some ideas? Want to improve things, add new illusions, and help
us shake people’s brain? Let us know, we would be very happy to have you
on board :relaxed:.

## Share Your Data

If you have used **Pyllusion** in your experiments, and have made your
scripts and data open access, feel free to also reference the link to
your data by opening [an
issue](https://github.com/RealityBending/Pyllusion/issues) with the
**Experiment Report** template.

## Citation

You can cite the package as follows:

- Makowski, D., Lau, Z. J., Pham, T., Paul Boyce, W., & Annabel Chen, S. H. (2021). [A Parametric Framework to Generate Visual Illusions Using Python](https://journals.sagepub.com/doi/abs/10.1177/03010066211057347). Perception, 50(11), 950-965.

## Features

### Delboeuf Illusion

The **[Delboeuf
illusion](https://en.wikipedia.org/wiki/Delboeuf_illusion)** is an
optical illusion of relative size perception, where circles of identical
size appear as different because of their surrounding context. The
illusion was named for the Belgian philosopher, mathematician,
experimental psychologist, hypnotist, and psychophysicist Joseph Remi
Leopold Delboeuf (1831–1896), who created it in 1865.

``` python
import pyllusion

delboeuf = pyllusion.Delboeuf(illusion_strength=3)
delboeuf.to_image()
```

![](docs/img/README_delboeuf1.png)

### Ebbinghaus Illusion

The **[Ebbinghaus
illusion](https://en.wikipedia.org/wiki/Ebbinghaus_illusion)** is an
optical illusion of relative size perception, where circles of identical
size appear as different because of their surrounding context (the right
red circle appears as smaller because its surrounding circle is larger).
The illusion was named after its creator the German psychologist Hermann
Ebbinghaus (1850–1909), though it got popularized by Edward B. Titchener
in a 1901 textbook of experimental psychology.

The Ebbinghaus illusion is considered a high-level integration illusion
(King et al., 2017) which has been considered relatively unaffected
amongst schizophrenics (as compared to healthy controls), who have
problems in contextual processing of visual stimuli. Specifically,
greater disorganized schizophrenia symptoms are related to a higher
resistance towards the Ebbinghaus illusion (Uhlhaas et al., 2006).
Reduced sensitivity of schizophrenics to this illusion has been used to
reflect how prior knowledge influences perceptual organization to a
lesser extent, i.e., reduced top-down influence, in schizophrenia
(Silverstein & Keane, 2011).

``` python
ebbinghaus = pyllusion.Ebbinghaus(illusion_strength=2)
ebbinghaus.to_image()
```

![](docs/img/README_ebbinghaus1.png)

### Müller-Lyer Illusion

The **[Müller-Lyer
illusion](https://en.wikipedia.org/wiki/M%C3%BCller-Lyer_illusion)** is
an optical illusion causing the participant to perceive two segments as
being of different length depending on the shape of the arrows. The
illusion was named after its creator the erman sociologist Franz Carl
Müller-Lyer (1857–1916) in 1889.

The Müller-Lyer illusion is a high-level integration illusion requiring
contextual processing by the brain (King et al., 2017). The effect of
this illusion in schizophrenics appears to be more mixed, with some
studies finding greater resistance to it (e.g., Parnas et al., 2001) and
others showing increased susceptibility (e.g., Kantrowitz et al., 2009).
There is some evidence that susceptibility to the Müller-Lyer illusion
is negatively correlated with autistic traits in the typical population
(but not with the Ebbinghaus nor the Ponzo illusion) (Chouinard et al.,
2013).

``` python
mullerlyer = pyllusion.MullerLyer(illusion_strength=30)
mullerlyer.to_image()
```

![](docs/img/README_mullerlyer1.png)

### Ponzo Illusion

The **[Ponzo illusion](https://en.wikipedia.org/wiki/Ponzo_illusion)**
is an optical illusion of relative size perception, where horizontal
lines of identical size appear as different because of their surrounding
context (the top line appear as longer, as it is interepreted as being
in the distance). The illusion was named after its creator the Italian
psychologist Mario Ponzo (1882–1960) in 1911, who suggested that the
human mind judges an object’s size based on its background.

Ponzo illusion is considered a high-level integration illusion as it is
cognitively demanding in the sense that depth cues have to be correctly
interpreted to signal changes in visual distance (King et al., 2017),
requiring higher-level cortical processes (Song et al., 2011). Similar
to the Ebbinghaus illusion, it is also shown to have less effect in
biasing perception in schizophrenic subjects (Kantrowitz et al., 2009).

``` python
ponzo = pyllusion.Ponzo(illusion_strength=20)
ponzo.to_image()
```

![](docs/img/README_ponzo1.png)

### Vertical–horizontal Illusion

The **[vertical–horizontal
illusion](https://en.wikipedia.org/wiki/Vertical%E2%80%93horizontal_illusion)**
illustrates the tendency for observers to overestimate the length of a
vertical line relative to a horizontal line of the same length (Shipley
et al., 1949).

``` python
verticalhorizontal = pyllusion.VerticalHorizontal(illusion_strength=-90)
verticalhorizontal.to_image()
```

![](docs/img/README_verticalhorizontal1.png)

### Zöllner Illusion

The **[Zöllner
illusion](https://en.wikipedia.org/wiki/Z%C3%B6llner_illusion)** is an
optical illusion, where horizontal lines are perceived as not parallel
because of their background. It is named after its discoverer, the
German astrophysicist Johann Karl Friedrich Zöllner in 1860.

``` python
zollner = pyllusion.Zollner(illusion_strength=75)
zollner.to_image()
```

![](docs/img/README_zollner1.png)

### Rod and Frame Illusion

The **[Rod and frame
illusion](https://en.wikipedia.org/wiki/Rod_and_frame_test#Rod_and_frame_illusion)**
is an optical illusion causing the participant to perceive the rod to be
oriented congruent with the orientation of the frame.

``` python
rodframe = pyllusion.RodFrame(illusion_strength=-11)
rodframe.to_image()
```

![](docs/img/README_rodframe1.png)

### Poggendorff Illusion

The **[Poggendorff
illusion](https://en.wikipedia.org/wiki/Poggendorff_illusion)** is an
optical illusion that involves the misperception of the position of one
segment of a transverse line that has been interrupted by the contour of
an intervening structure. It is named after Johann Christian Poggendorff
who discovered in Zöllner’s illusion after 1860. The magnitude of the
illusion depends on the properties of the obscuring pattern and the
nature of its borders.

``` python
poggendorff = pyllusion.Poggendorff(illusion_strength=-50)
poggendorff.to_image()
```

![](docs/img/README_poggendorff1.png)

### Simultaneous Contrast illusion

A neutral gray target will appear lighter or darker than it does in
isolation when compared to, respectively, a dark gray or light gray
target. **[Simultaneous
contrast](https://en.wikipedia.org/wiki/Contrast_effect)**, identified
by Michel Eugène Chevreul, refers to the manner in which the colors of
two different objects affect each other.

In the image here, the two inner rectangles are exactly the same shade
of grey, but the upper one appears to be a lighter grey than the lower
one due to the background provided by the outer rectangles.

``` python
contrast = pyllusion.Contrast(illusion_strength=-50)
contrast.to_image()
```

![](docs/img/README_contrast1.png)

### White Illusion

**[White’s illusion](https://en.wikipedia.org/wiki/White%27s_illusion)**
is a brightness illusion in which rectangles of the same grey color are
perceived of different luminance depending on their background.

``` python
white = pyllusion.White(illusion_strength=100)
white.to_image()
```

![](docs/img/README_white1.png)

<!-- ### Chubb illusion -->

<!-- The **[Chubb illusion](https://en.wikipedia.org/wiki/Chubb_illusion)** is an optical illusion or error in visual perception in which the apparent contrast of an object varies substantially to most viewers depending on its relative contrast to the field on which it is displayed. -->

<!-- ![](https://lh5.googleusercontent.com/-EH2_hl1xbE4/TxNmsYaQ5uI/AAAAAAAAEUE/ZqdI5414b1I/s280/chubbillusion.gif) -->

<!-- - **TO DO** *(consider helping!)* -->

### Kanizsa Square

The **Kanizsa Square** is an [illusory
contour](https://en.wikipedia.org/wiki/Illusory_contours) illusion. See
[Keane et
al., 2019](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6667222/).

Some studies have tested the effect of the Kanizsa Square in individuals
with schizophrenia, but the finding of greater resistance to the
illusion is not robust (King et al., 2017).

![](https://www.researchgate.net/profile/Ken_Manktelow/publication/6821211/figure/fig2/AS:277716826902534@1443224259391/Kanizsa-square-An-illusory-figure-induced-by-edges-showing-an-illusory-contour-and-an.png)

  - **TO DO** *(consider helping\!)*

### Autostereograms

**[Autostereograms](https://en.wikipedia.org/wiki/Autostereogram)** are
images made of a pattern that is horizontally repeated (with slight
variations) which, when watched with the appropriate focus, will
generate an illusion of depth.

For instance, in the image below, the `autostereogram` automatically
adds a guide (you can disable it by setting `guide=False`), the two red
dots. Look at them and relax your eyes until you see a new red dot
between them two. Then, try focusing on this new red dot until it gets
very sharp and until your eyes stabilize. You should then be able to
perceive the letters **3D** as carved in the figure

It can take a bit of time to “get there”, but once you are used to it,
it’s a mind-blowing experience 🤯

    autostereograms = pyllusion.Autostereogram(stimulus="3D", width=1600, height=900)
    autostereograms.draw()

<!-- ```{python message=FALSE, warning=FALSE, echo=FALSE} -->

<!-- img = pyllusion.autostereogram(stimulus="3D", width=1600, height=900) -->

<!-- img.save("docs/img/README_autostereogram1.png") -->

<!-- ``` -->

![](docs/img/README_autostereogram1.png)

The function is highly customisable, and we can use a black and white
image as a **depth mask** (in this case, the [picture of a
skull](https://github.com/DominiqueMakowski/Pyllusion/docs/img/depthmask.png)
that you will see as emerging from the background), and customise the
pattern used by providing another function (here, the `image_circles()`
function to which we can provide additional arguments like `blackwhite`,
the number of circles `n`, their size range and their transparency with
`alpha`).

![](docs/img/depthmask.png)

    autostereograms = pyllusion.Autostereogram(stimulus="docs/img/depthmask.png",
                       pattern=pyllusion.image_circles,
                       color="blackwhite",
                       alpha=0.75,
                       size_min=0.005,
                       size_max=0.03,
                       n=1000)
    autostereograms.draw()

<!-- ```{python message=FALSE, warning=FALSE, echo=FALSE} -->

<!-- img = pyllusion.autostereogram(stimulus="docs/img/depthmask.png", -->

<!--                    pattern=pyllusion.image_circles, -->

<!--                    color="blackwhite", -->

<!--                    alpha=0.75, -->

<!--                    size_min=0.005, -->

<!--                    size_max=0.03, -->

<!--                    n=1000) -->

<!-- img.save("docs/img/README_autostereogram2.png") -->

<!-- ``` -->

![](docs/img/README_autostereogram2.png)

### Pareidolia

Pareidolia is the tendency to incorrectly perceive of a stimulus as an
object pattern or meaning known to the observer. [Liu et
al. (2014)](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3980010/?mod=article_inline),
in their study *“Seeing Jesus in toast”*, famously (the study got
awarded an Ignobel prize) investigated the correlates of face pareidolia
by blending images of faces with noise-like images.

Blending of images can be achieved: as followed

``` python
pareidolia = pyllusion.Pareidolia(pattern="docs/img/snake.png",
                                 n=[20, 300, 4000],
                                 sd=[4, 2, 1],
                                 weight=[3, 2, 1],
                                 alpha=80,
                                 blur=0.5)
pareidolia.draw()
```

![](docs/img/README_pareidolia.png)

### Transparency From Motion (TFM)

In visual perception, the **[kinetic depth
effect](https://en.wikipedia.org/wiki/Kinetic_depth_effect)** refers to
the phenomenon whereby the three-dimensional structural form of an
object can be perceived when the object is moving (Wallach & O’Connell,
1953; [Mamassian &
Wallace, 2010](https://jov.arvojournals.org/article.aspx?articleid=2191769)).
One of its derivative is the **Transparency-From-Motion** illusion,
consisting in the superposition of two dot clouds moving in different
directions that results in the perception of two transparent layers (See
;
[Schütz, 2014](https://jov.arvojournals.org/article.aspx?articleid=2193903);
[Wexler et
al., 2015](https://www.pnas.org/content/pnas/112/48/14990.full.pdf);
[Schütz &
Mamassian, 2016](https://jov.arvojournals.org/article.aspx?articleid=2548036)
and <http://lab-perception.org/demo/p/tfm> for a demo).

``` python
parameters = pyllusion.motiontransparency_parameters(angle=45)
images = pyllusion.motiontransparency_images(parameters)

pyllusion.images_to_gif(images, path="Transparency_From_Motion.gif", fps=parameters["FPS"])
```

![](docs/img/README_TFM1.gif)

<!-- ### Pattern Detection in Motion  -->

<!-- - **TO DO** *(consider helping!)* -->

### Pinna illusion

See also **[Zeljic et
al., 2021](https://www.sciencedirect.com/science/article/pii/S0278584620303717)**.

  - **TO DO** *(consider helping\!)*

![](http://psychedelic-information-theory.com/upload/img/pinna-illusion-image.jpg)

### Monnier-Shevell illusion

See also [David Novick’s](https://twitter.com/NovickProf) tweets
[**here**](https://twitter.com/NovickProf/status/1348653264645009408),
and
[**here**](https://twitter.com/NovickProf/status/1358787676326031360).

  - **TO DO** *(consider helping\!)*

![](https://pbs.twimg.com/media/Erdge3AXIAcisZj.png)

<!-- ### Exctinction illusion -->

<!-- See also [this tweet](https://twitter.com/AkiyoshiKitaoka/status/1351867885493211138/photo/1 by Akiyoshi Kitaoka). -->

<!-- - **TO DO** *(consider helping!)* -->

<!-- ![](docs/img/extinction_illusion.png) -->

## PsychoPy Integration

Pyllusion can be easily integrated into
[PsychoPy](https://www.psychopy.org/) for running experiments as well\!

    # Load packages
    import pyllusion
    from psychopy import visual, event

    # Create parameters
    delboeuf = pyllusion.Delboeuf(illusion_strength=1, difference=2)

    # Initiate Window
    window = visual.Window(size=[1920, 1080], winType='pygame',
                           color='white', fullscr=False)

    # Display illusion
    delboeuf.to_psychopy(window)

    # Refresh and close window
    window.flip()
    event.waitKeys()  # Press any key to close
    window.close()

![](docs/img/image_example.gif)

## References

Bertamini, M. (2017). *[Programming visual illusions for
everyone](https://www.programmingvisualillusionsforeveryone.online)*.
Springer.

Chouinard, P. A., Noulty, W. A., Sperandio, I., & Landry, O. (2013).
Global processing during the Müller-Lyer illusion is distinctively
affected by the degree of autistic traits in the typical population.
Experimental Brain Research, 230(2), 219–231.

Kantrowitz, J. T., Butler, P. D., Schecter, I., Silipo, G., & Javitt, D.
C. (2009). Seeing the world dimly: The impact of early visual deficits
on visual experience in schizophrenia. Schizophrenia Bulletin, 35(6),
1085–1094. <doi:10.1093/schbul/sbp100>

King, D. J., Hodgekins, J., Chouinard, P. A., Chouinard, V. A., &
Sperandio, I. (2017). A review of abnormalities in the perception of
visual illusions in schizophrenia. Psychonomic bulletin & review, 24(3),
734-751.

Parnas, J., Vianin, P., Saebye, D., Jansson, L., Volmer-Larsen, a, &
Bovet, P. (2001). Visual binding abilities in the initial and advanced
stages of schizophrenia. Acta Psychiatrica Scandinavica, 103(3),
171–180. <doi:10.1034/j.1600-0447.2001.00160.x>

Silverstein, S. M., & Keane, B. P. (2011). Perceptual organization
impairment in schizophrenia and associated brain mechanisms: Review of
research from 2005 to 2010. Schizophrenia Bulletin, 37(4), 690–699.
<doi:10.1093/schbul/sbr052>

Song, C., Schwarzkopf, D. S., & Rees, G. (2011). Interocular induction
of illusory size perception. BMC Neuroscience 27, 12(1).

Uhlhaas, P. J., Phillips, W. A., Schenkel, L. S., & Silverstein, S. M.
(2006b). Theory of mind and perceptual context‐processing in
schizophrenia. Cognitive Neuropsychiatry, 11(4), 416–436.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RealityBending/Pyllusion/",
    "name": "pyllusion",
    "maintainer": "Dominique Makowski",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "dom.makowski@gmail.com",
    "keywords": "python pyllusion visual optical illusions",
    "author": "Dominique Makowski",
    "author_email": "dom.makowski@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/d2/2ff8b7790939685f31a84aefa71dec116fa088e7cae7b0cba7bc6874ff59/pyllusion-1.3.tar.gz",
    "platform": null,
    "description": "\n![](https://github.com/RealityBending/Pyllusion/blob/master/docs/img/logo.png)\n![](https://img.shields.io/pypi/pyversions/pyllusion.svg?logo=python&logoColor=FFE873)\n[![Tests](https://github.com/RealityBending/Pyllusion/actions/workflows/tests.yml/badge.svg)](https://github.com/RealityBending/Pyllusion/actions/workflows/tests.yml)\n[![](https://img.shields.io/badge/paper-Pyllusion-9C27B0)](https://journals.sagepub.com/doi/10.1177/03010066211057347)\n\n**A Parametric Framework to Generate Visual Illusions using Python**\n\n# Overview\n\nVisual illusions are fascinating phenomena that have been used and\nstudied by artists and scientists for centuries, leading to important\ndiscoveries about how conscious perception is generated by the brain.\nInstead of crafting them by hand, **Pyllusion** offers a framework to\nmanipulate and generate illusions in a systematic way.\n\nThe parametric approach implemented in this software proposes to\n**describe illusions using a set of parameters**, such as for instance\nthe *difference* and *illusion strength*. These two parameters can be\nmodulated to independently impact either the objective difference of the\ncore components of the illusion (e.g., the difference between the two\nsegments in the [M\u00fcller-Lyer](#m\u00fcller-lyer-illusion-illusion) illusion)\nor the intensity of the illusion effect (e.g., the angle of the\n\u201cdistractors\u201d arrows).\n\nDescribing illusions using a set of parameters aims at fostering\n**reproducible science**, allowing neuroscientists to easily report,\ngenerate and manipulate similar stimuli regardless of the display format\nand software.\n\n## Installation\n\n    pip install https://github.com/RealityBending/Pyllusion/zipball/master\n\nYou can also find the installation instructions for Python 3\n[here](https://realpython.com/installing-python/).\n\n## Contribution\n\nYou have some ideas? Want to improve things, add new illusions, and help\nus shake people\u2019s brain? Let us know, we would be very happy to have you\non board :relaxed:.\n\n## Share Your Data\n\nIf you have used **Pyllusion** in your experiments, and have made your\nscripts and data open access, feel free to also reference the link to\nyour data by opening [an\nissue](https://github.com/RealityBending/Pyllusion/issues) with the\n**Experiment Report** template.\n\n## Citation\n\nYou can cite the package as follows:\n\n- Makowski, D., Lau, Z. J., Pham, T., Paul Boyce, W., & Annabel Chen, S. H. (2021). [A Parametric Framework to Generate Visual Illusions Using Python](https://journals.sagepub.com/doi/abs/10.1177/03010066211057347). Perception, 50(11), 950-965.\n\n## Features\n\n### Delboeuf Illusion\n\nThe **[Delboeuf\nillusion](https://en.wikipedia.org/wiki/Delboeuf_illusion)** is an\noptical illusion of relative size perception, where circles of identical\nsize appear as different because of their surrounding context. The\nillusion was named for the Belgian philosopher, mathematician,\nexperimental psychologist, hypnotist, and psychophysicist Joseph Remi\nLeopold Delboeuf (1831\u20131896), who created it in 1865.\n\n``` python\nimport pyllusion\n\ndelboeuf = pyllusion.Delboeuf(illusion_strength=3)\ndelboeuf.to_image()\n```\n\n![](docs/img/README_delboeuf1.png)\n\n### Ebbinghaus Illusion\n\nThe **[Ebbinghaus\nillusion](https://en.wikipedia.org/wiki/Ebbinghaus_illusion)** is an\noptical illusion of relative size perception, where circles of identical\nsize appear as different because of their surrounding context (the right\nred circle appears as smaller because its surrounding circle is larger).\nThe illusion was named after its creator the German psychologist Hermann\nEbbinghaus (1850\u20131909), though it got popularized by Edward B. Titchener\nin a 1901 textbook of experimental psychology.\n\nThe Ebbinghaus illusion is considered a high-level integration illusion\n(King et al., 2017) which has been considered relatively unaffected\namongst schizophrenics (as compared to healthy controls), who have\nproblems in contextual processing of visual stimuli. Specifically,\ngreater disorganized schizophrenia symptoms are related to a higher\nresistance towards the Ebbinghaus illusion (Uhlhaas et al., 2006).\nReduced sensitivity of schizophrenics to this illusion has been used to\nreflect how prior knowledge influences perceptual organization to a\nlesser extent, i.e., reduced top-down influence, in schizophrenia\n(Silverstein & Keane, 2011).\n\n``` python\nebbinghaus = pyllusion.Ebbinghaus(illusion_strength=2)\nebbinghaus.to_image()\n```\n\n![](docs/img/README_ebbinghaus1.png)\n\n### M\u00fcller-Lyer Illusion\n\nThe **[M\u00fcller-Lyer\nillusion](https://en.wikipedia.org/wiki/M%C3%BCller-Lyer_illusion)** is\nan optical illusion causing the participant to perceive two segments as\nbeing of different length depending on the shape of the arrows. The\nillusion was named after its creator the erman sociologist Franz Carl\nM\u00fcller-Lyer (1857\u20131916) in 1889.\n\nThe M\u00fcller-Lyer illusion is a high-level integration illusion requiring\ncontextual processing by the brain (King et al., 2017). The effect of\nthis illusion in schizophrenics appears to be more mixed, with some\nstudies finding greater resistance to it (e.g., Parnas et al., 2001) and\nothers showing increased susceptibility (e.g., Kantrowitz et al., 2009).\nThere is some evidence that susceptibility to the M\u00fcller-Lyer illusion\nis negatively correlated with autistic traits in the typical population\n(but not with the Ebbinghaus nor the Ponzo illusion) (Chouinard et al.,\n2013).\n\n``` python\nmullerlyer = pyllusion.MullerLyer(illusion_strength=30)\nmullerlyer.to_image()\n```\n\n![](docs/img/README_mullerlyer1.png)\n\n### Ponzo Illusion\n\nThe **[Ponzo illusion](https://en.wikipedia.org/wiki/Ponzo_illusion)**\nis an optical illusion of relative size perception, where horizontal\nlines of identical size appear as different because of their surrounding\ncontext (the top line appear as longer, as it is interepreted as being\nin the distance). The illusion was named after its creator the Italian\npsychologist Mario Ponzo (1882\u20131960) in 1911, who suggested that the\nhuman mind judges an object\u2019s size based on its background.\n\nPonzo illusion is considered a high-level integration illusion as it is\ncognitively demanding in the sense that depth cues have to be correctly\ninterpreted to signal changes in visual distance (King et al., 2017),\nrequiring higher-level cortical processes (Song et al., 2011). Similar\nto the Ebbinghaus illusion, it is also shown to have less effect in\nbiasing perception in schizophrenic subjects (Kantrowitz et al., 2009).\n\n``` python\nponzo = pyllusion.Ponzo(illusion_strength=20)\nponzo.to_image()\n```\n\n![](docs/img/README_ponzo1.png)\n\n### Vertical\u2013horizontal Illusion\n\nThe **[vertical\u2013horizontal\nillusion](https://en.wikipedia.org/wiki/Vertical%E2%80%93horizontal_illusion)**\nillustrates the tendency for observers to overestimate the length of a\nvertical line relative to a horizontal line of the same length (Shipley\net al., 1949).\n\n``` python\nverticalhorizontal = pyllusion.VerticalHorizontal(illusion_strength=-90)\nverticalhorizontal.to_image()\n```\n\n![](docs/img/README_verticalhorizontal1.png)\n\n### Z\u00f6llner Illusion\n\nThe **[Z\u00f6llner\nillusion](https://en.wikipedia.org/wiki/Z%C3%B6llner_illusion)** is an\noptical illusion, where horizontal lines are perceived as not parallel\nbecause of their background. It is named after its discoverer, the\nGerman astrophysicist Johann Karl Friedrich Z\u00f6llner in 1860.\n\n``` python\nzollner = pyllusion.Zollner(illusion_strength=75)\nzollner.to_image()\n```\n\n![](docs/img/README_zollner1.png)\n\n### Rod and Frame Illusion\n\nThe **[Rod and frame\nillusion](https://en.wikipedia.org/wiki/Rod_and_frame_test#Rod_and_frame_illusion)**\nis an optical illusion causing the participant to perceive the rod to be\noriented congruent with the orientation of the frame.\n\n``` python\nrodframe = pyllusion.RodFrame(illusion_strength=-11)\nrodframe.to_image()\n```\n\n![](docs/img/README_rodframe1.png)\n\n### Poggendorff Illusion\n\nThe **[Poggendorff\nillusion](https://en.wikipedia.org/wiki/Poggendorff_illusion)** is an\noptical illusion that involves the misperception of the position of one\nsegment of a transverse line that has been interrupted by the contour of\nan intervening structure. It is named after Johann Christian Poggendorff\nwho discovered in Z\u00f6llner\u2019s illusion after 1860. The magnitude of the\nillusion depends on the properties of the obscuring pattern and the\nnature of its borders.\n\n``` python\npoggendorff = pyllusion.Poggendorff(illusion_strength=-50)\npoggendorff.to_image()\n```\n\n![](docs/img/README_poggendorff1.png)\n\n### Simultaneous Contrast illusion\n\nA neutral gray target will appear lighter or darker than it does in\nisolation when compared to, respectively, a dark gray or light gray\ntarget. **[Simultaneous\ncontrast](https://en.wikipedia.org/wiki/Contrast_effect)**, identified\nby Michel Eug\u00e8ne Chevreul, refers to the manner in which the colors of\ntwo different objects affect each other.\n\nIn the image here, the two inner rectangles are exactly the same shade\nof grey, but the upper one appears to be a lighter grey than the lower\none due to the background provided by the outer rectangles.\n\n``` python\ncontrast = pyllusion.Contrast(illusion_strength=-50)\ncontrast.to_image()\n```\n\n![](docs/img/README_contrast1.png)\n\n### White Illusion\n\n**[White\u2019s illusion](https://en.wikipedia.org/wiki/White%27s_illusion)**\nis a brightness illusion in which rectangles of the same grey color are\nperceived of different luminance depending on their background.\n\n``` python\nwhite = pyllusion.White(illusion_strength=100)\nwhite.to_image()\n```\n\n![](docs/img/README_white1.png)\n\n<!-- ### Chubb illusion -->\n\n<!-- The **[Chubb illusion](https://en.wikipedia.org/wiki/Chubb_illusion)** is an optical illusion or error in visual perception in which the apparent contrast of an object varies substantially to most viewers depending on its relative contrast to the field on which it is displayed. -->\n\n<!-- ![](https://lh5.googleusercontent.com/-EH2_hl1xbE4/TxNmsYaQ5uI/AAAAAAAAEUE/ZqdI5414b1I/s280/chubbillusion.gif) -->\n\n<!-- - **TO DO** *(consider helping!)* -->\n\n### Kanizsa Square\n\nThe **Kanizsa Square** is an [illusory\ncontour](https://en.wikipedia.org/wiki/Illusory_contours) illusion. See\n[Keane et\nal., 2019](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6667222/).\n\nSome studies have tested the effect of the Kanizsa Square in individuals\nwith schizophrenia, but the finding of greater resistance to the\nillusion is not robust (King et al., 2017).\n\n![](https://www.researchgate.net/profile/Ken_Manktelow/publication/6821211/figure/fig2/AS:277716826902534@1443224259391/Kanizsa-square-An-illusory-figure-induced-by-edges-showing-an-illusory-contour-and-an.png)\n\n  - **TO DO** *(consider helping\\!)*\n\n### Autostereograms\n\n**[Autostereograms](https://en.wikipedia.org/wiki/Autostereogram)** are\nimages made of a pattern that is horizontally repeated (with slight\nvariations) which, when watched with the appropriate focus, will\ngenerate an illusion of depth.\n\nFor instance, in the image below, the `autostereogram` automatically\nadds a guide (you can disable it by setting `guide=False`), the two red\ndots. Look at them and relax your eyes until you see a new red dot\nbetween them two. Then, try focusing on this new red dot until it gets\nvery sharp and until your eyes stabilize. You should then be able to\nperceive the letters **3D** as carved in the figure\n\nIt can take a bit of time to \u201cget there\u201d, but once you are used to it,\nit\u2019s a mind-blowing experience \ud83e\udd2f\n\n    autostereograms = pyllusion.Autostereogram(stimulus=\"3D\", width=1600, height=900)\n    autostereograms.draw()\n\n<!-- ```{python message=FALSE, warning=FALSE, echo=FALSE} -->\n\n<!-- img = pyllusion.autostereogram(stimulus=\"3D\", width=1600, height=900) -->\n\n<!-- img.save(\"docs/img/README_autostereogram1.png\") -->\n\n<!-- ``` -->\n\n![](docs/img/README_autostereogram1.png)\n\nThe function is highly customisable, and we can use a black and white\nimage as a **depth mask** (in this case, the [picture of a\nskull](https://github.com/DominiqueMakowski/Pyllusion/docs/img/depthmask.png)\nthat you will see as emerging from the background), and customise the\npattern used by providing another function (here, the `image_circles()`\nfunction to which we can provide additional arguments like `blackwhite`,\nthe number of circles `n`, their size range and their transparency with\n`alpha`).\n\n![](docs/img/depthmask.png)\n\n    autostereograms = pyllusion.Autostereogram(stimulus=\"docs/img/depthmask.png\",\n                       pattern=pyllusion.image_circles,\n                       color=\"blackwhite\",\n                       alpha=0.75,\n                       size_min=0.005,\n                       size_max=0.03,\n                       n=1000)\n    autostereograms.draw()\n\n<!-- ```{python message=FALSE, warning=FALSE, echo=FALSE} -->\n\n<!-- img = pyllusion.autostereogram(stimulus=\"docs/img/depthmask.png\", -->\n\n<!--                    pattern=pyllusion.image_circles, -->\n\n<!--                    color=\"blackwhite\", -->\n\n<!--                    alpha=0.75, -->\n\n<!--                    size_min=0.005, -->\n\n<!--                    size_max=0.03, -->\n\n<!--                    n=1000) -->\n\n<!-- img.save(\"docs/img/README_autostereogram2.png\") -->\n\n<!-- ``` -->\n\n![](docs/img/README_autostereogram2.png)\n\n### Pareidolia\n\nPareidolia is the tendency to incorrectly perceive of a stimulus as an\nobject pattern or meaning known to the observer. [Liu et\nal.\u00a0(2014)](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3980010/?mod=article_inline),\nin their study *\u201cSeeing Jesus in toast\u201d*, famously (the study got\nawarded an Ignobel prize) investigated the correlates of face pareidolia\nby blending images of faces with noise-like images.\n\nBlending of images can be achieved: as followed\n\n``` python\npareidolia = pyllusion.Pareidolia(pattern=\"docs/img/snake.png\",\n                                 n=[20, 300, 4000],\n                                 sd=[4, 2, 1],\n                                 weight=[3, 2, 1],\n                                 alpha=80,\n                                 blur=0.5)\npareidolia.draw()\n```\n\n![](docs/img/README_pareidolia.png)\n\n### Transparency From Motion (TFM)\n\nIn visual perception, the **[kinetic depth\neffect](https://en.wikipedia.org/wiki/Kinetic_depth_effect)** refers to\nthe phenomenon whereby the three-dimensional structural form of an\nobject can be perceived when the object is moving (Wallach & O\u2019Connell,\n1953; [Mamassian &\nWallace, 2010](https://jov.arvojournals.org/article.aspx?articleid=2191769)).\nOne of its derivative is the **Transparency-From-Motion** illusion,\nconsisting in the superposition of two dot clouds moving in different\ndirections that results in the perception of two transparent layers (See\n;\n[Sch\u00fctz, 2014](https://jov.arvojournals.org/article.aspx?articleid=2193903);\n[Wexler et\nal., 2015](https://www.pnas.org/content/pnas/112/48/14990.full.pdf);\n[Sch\u00fctz &\nMamassian, 2016](https://jov.arvojournals.org/article.aspx?articleid=2548036)\nand <http://lab-perception.org/demo/p/tfm> for a demo).\n\n``` python\nparameters = pyllusion.motiontransparency_parameters(angle=45)\nimages = pyllusion.motiontransparency_images(parameters)\n\npyllusion.images_to_gif(images, path=\"Transparency_From_Motion.gif\", fps=parameters[\"FPS\"])\n```\n\n![](docs/img/README_TFM1.gif)\n\n<!-- ### Pattern Detection in Motion  -->\n\n<!-- - **TO DO** *(consider helping!)* -->\n\n### Pinna illusion\n\nSee also **[Zeljic et\nal., 2021](https://www.sciencedirect.com/science/article/pii/S0278584620303717)**.\n\n  - **TO DO** *(consider helping\\!)*\n\n![](http://psychedelic-information-theory.com/upload/img/pinna-illusion-image.jpg)\n\n### Monnier-Shevell illusion\n\nSee also [David Novick\u2019s](https://twitter.com/NovickProf) tweets\n[**here**](https://twitter.com/NovickProf/status/1348653264645009408),\nand\n[**here**](https://twitter.com/NovickProf/status/1358787676326031360).\n\n  - **TO DO** *(consider helping\\!)*\n\n![](https://pbs.twimg.com/media/Erdge3AXIAcisZj.png)\n\n<!-- ### Exctinction illusion -->\n\n<!-- See also [this tweet](https://twitter.com/AkiyoshiKitaoka/status/1351867885493211138/photo/1 by Akiyoshi Kitaoka). -->\n\n<!-- - **TO DO** *(consider helping!)* -->\n\n<!-- ![](docs/img/extinction_illusion.png) -->\n\n## PsychoPy Integration\n\nPyllusion can be easily integrated into\n[PsychoPy](https://www.psychopy.org/) for running experiments as well\\!\n\n    # Load packages\n    import pyllusion\n    from psychopy import visual, event\n\n    # Create parameters\n    delboeuf = pyllusion.Delboeuf(illusion_strength=1, difference=2)\n\n    # Initiate Window\n    window = visual.Window(size=[1920, 1080], winType='pygame',\n                           color='white', fullscr=False)\n\n    # Display illusion\n    delboeuf.to_psychopy(window)\n\n    # Refresh and close window\n    window.flip()\n    event.waitKeys()  # Press any key to close\n    window.close()\n\n![](docs/img/image_example.gif)\n\n## References\n\nBertamini, M. (2017). *[Programming visual illusions for\neveryone](https://www.programmingvisualillusionsforeveryone.online)*.\nSpringer.\n\nChouinard, P. A., Noulty, W. A., Sperandio, I., & Landry, O. (2013).\nGlobal processing during the M\u00fcller-Lyer illusion is distinctively\naffected by the degree of autistic traits in the typical population.\nExperimental Brain Research, 230(2), 219\u2013231.\n\nKantrowitz, J. T., Butler, P. D., Schecter, I., Silipo, G., & Javitt, D.\nC. (2009). Seeing the world dimly: The impact of early visual deficits\non visual experience in schizophrenia. Schizophrenia Bulletin, 35(6),\n1085\u20131094. <doi:10.1093/schbul/sbp100>\n\nKing, D. J., Hodgekins, J., Chouinard, P. A., Chouinard, V. A., &\nSperandio, I. (2017). A review of abnormalities in the perception of\nvisual illusions in schizophrenia. Psychonomic bulletin & review, 24(3),\n734-751.\n\nParnas, J., Vianin, P., Saebye, D., Jansson, L., Volmer-Larsen, a, &\nBovet, P. (2001). Visual binding abilities in the initial and advanced\nstages of schizophrenia. Acta Psychiatrica Scandinavica, 103(3),\n171\u2013180. <doi:10.1034/j.1600-0447.2001.00160.x>\n\nSilverstein, S. M., & Keane, B. P. (2011). Perceptual organization\nimpairment in schizophrenia and associated brain mechanisms: Review of\nresearch from 2005 to 2010. Schizophrenia Bulletin, 37(4), 690\u2013699.\n<doi:10.1093/schbul/sbr052>\n\nSong, C., Schwarzkopf, D. S., & Rees, G. (2011). Interocular induction\nof illusory size perception. BMC Neuroscience 27, 12(1).\n\nUhlhaas, P. J., Phillips, W. A., Schenkel, L. S., & Silverstein, S. M.\n(2006b). Theory of mind and perceptual context\u2010processing in\nschizophrenia. Cognitive Neuropsychiatry, 11(4), 416\u2013436.\n",
    "bugtrack_url": null,
    "license": "Mozilla Public License Version 2.0",
    "summary": "A Parametric Framework to Generate Visual Illusions.",
    "version": "1.3",
    "project_urls": {
        "Download": "https://github.com/RealityBending/Pyllusion/zipball/master",
        "Homepage": "https://github.com/RealityBending/Pyllusion/"
    },
    "split_keywords": [
        "python",
        "pyllusion",
        "visual",
        "optical",
        "illusions"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a39a4c194233918c9ce03a8183ea3c8a9ce5b18f0faa889df521abb99e2dc270",
                "md5": "a16e549ceefadc1d8b0dbb23a530523b",
                "sha256": "ad03841a9b45d564f508f7ca19b5497be54661416f98f372807a7e6ca80fb77e"
            },
            "downloads": -1,
            "filename": "pyllusion-1.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a16e549ceefadc1d8b0dbb23a530523b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 86422,
            "upload_time": "2024-08-29T09:42:59",
            "upload_time_iso_8601": "2024-08-29T09:42:59.462899Z",
            "url": "https://files.pythonhosted.org/packages/a3/9a/4c194233918c9ce03a8183ea3c8a9ce5b18f0faa889df521abb99e2dc270/pyllusion-1.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3dd22ff8b7790939685f31a84aefa71dec116fa088e7cae7b0cba7bc6874ff59",
                "md5": "05cfe2cfdd0fd949e8143493c8b0c78f",
                "sha256": "5dccdc799ad780da0f81748cca3a01239d42e4ea2aa627f7ebe77d2fab045e38"
            },
            "downloads": -1,
            "filename": "pyllusion-1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "05cfe2cfdd0fd949e8143493c8b0c78f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 54564,
            "upload_time": "2024-08-29T09:43:00",
            "upload_time_iso_8601": "2024-08-29T09:43:00.618702Z",
            "url": "https://files.pythonhosted.org/packages/3d/d2/2ff8b7790939685f31a84aefa71dec116fa088e7cae7b0cba7bc6874ff59/pyllusion-1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-29 09:43:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RealityBending",
    "github_project": "Pyllusion",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "pyllusion"
}
        
Elapsed time: 0.29376s