Skip to main content

A simple tool to scramble the background (=anything but people) in images.

Project description

Background Scrambler

This package contains a simple tool that allows to scramble the background of images. By background, we mean anything but the people in the image. This is practical for, e.g., psychology or neuroscience experiments dealing with human vision and/or social cognition.

As an example, it turns this image:

into this image:

Installation

To install this application, either clone this repository, or simply install using pip install bg-scrambler.

Usage

Note that the scrambler returns the processed image. By default, the output is NOT saved to disk.
To save the output (i.e., the processed image) to disk, specify out_file='path/to/output.jpg' (or png) when calling process_img().

When cloning the repo

See the example in scrambler.py, reprised here:

if __name__ == '__main__':
    # Create Scrambler instance
    proc = Scrambler()
    # Replace the line below to point at the image you want to parse
    _img = 'test_image_unsplash.jpg'
    # Parse image
    # block_size: size of the blocks (or patches if you prefer) that will be randomly swapped around
    # blur_radius: size of the blur to be applied to the scrambled part
    res = proc.process_img(_img, block_size=3, blur_radius=0, out_file=None, b_show=True)

When installing the package through pip:

A short demo:

from bg_scrambler import scrambler
import os


if __name__ == '__main__':
    proc = scrambler.Scrambler()
    _img = os.path.join(os.path.dirname(scrambler.__file__), 'test_image_unsplash.jpg')

    # Parse image
    # block_size: size of the blocks (or patches if you prefer) that will be randomly swapped around
    # blur_radius: size of the blur to be applied to the scrambled part
    res = proc.process_img(_img, block_size=3, blur_radius=0, out_file=None, b_show=True)

Licensing

This repository is made available under an MIT license (see LICENSE.md). This is in agreement with the original repository, which also uses an MIT license.

The test image is taken from Unsplash:
https://unsplash.com/photos/a-person-sitting-on-a-couch-with-a-laptop-X1GZqv-F7Tw
The image is distributed under the Unsplash license.

Author: Laurent Mertens
Mail: contact@laurentmertens.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bg_scrambler-1.0.0.tar.gz (11.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bg_scrambler-1.0.0-py3-none-any.whl (11.4 MB view details)

Uploaded Python 3

File details

Details for the file bg_scrambler-1.0.0.tar.gz.

File metadata

  • Download URL: bg_scrambler-1.0.0.tar.gz
  • Upload date:
  • Size: 11.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bg_scrambler-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0d2f1d0afc4ba39a38a4799959829311ae05a4fcc52066de8074a5491f143b73
MD5 0ec28b26ba356efcfa3e7f1268802471
BLAKE2b-256 9496a01674341082961807b05d8f89b1c5937b355603ce00c6b8b0e48140aa99

See more details on using hashes here.

File details

Details for the file bg_scrambler-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bg_scrambler-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bg_scrambler-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48b4b86be975e055a56140d21e118ba6ae392340f87a5c5c890eb8f57c00ab2f
MD5 549e31964ab3979290787a571b730046
BLAKE2b-256 3cd9de4ac41a8c8c6cbc22c499a68f9496b1e3fa70e46dca0699d08d357c5964

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page