Skip to content

hazkaz/bitplaning-and-thresholding

Repository files navigation

Bitplaning in Python

Open In Colab

Bitplaning means to extract information of an image along only a single bit position. In case of multiple bit positions, you can choose to either binary threshold it to see more clearly the lower intensity bits. Bitplaning along all planes simultaneously without thresholding it will give you back the original image.

This module allows you to extract from single/multiple bit positions.

Installation

Copy the bitplaning module (bitplane.py) to your working directory and import it

import bitplane

Usage

Python usage
  1. Read the image using openCV in grayscale
  2. Pass the image to bitplane.bit_plane
  3. (Optional) perform intensity thresholding with bitplane.threshold_image
img = cv2.imread(args.image_file, 0)
bitplaned_img = bit_plane(img, planes)
Command-line interface
Usage
python bitplane.py <input-image> --bitplane [...planes to bitplane(0-7)]
Example
# bitplane along Most significant bit
python bitplane.py test2.png --bitplane 7

Sample output

Input Image

input-image

Bitplaned Output

bitplaned-output-image