Bitwise OR Operation

Introduction

Say, we’re given with two binary strings of equal width ( take it 8-bit ) and asked to perform bitwise OR operation.

Bit String One Bit String Two OR-ed
00010010 00100001 00110011

We know for a 24-bit image ( where each color component R, G & B of 8-bit width ), it can have ~16M ( 2^24 ) unique color values. And also we understand each pixel intensity value must be lying with in [0, 255] range. Even if we take two binary strings of 8-bit width, after application of OR operator resulting bitstring will be of width 8-bit, so its value will also lie in [0, 255] range i.e. after application of bitwise OR operator we don’t need to scale pixel intensity value in [0, 255] range seperately.

Now we’re given with two images of equal dimension, and asked to apply bitwise OR operator, how do we do that ?

Implementation

So currently we’ve two images ( of course different ) of equal dimension and we’ll pick pixel intensity at P[i, j] from each of those two images & apply OR operator on those two 8-bit values. As we’ll also allow color images, we need to consider three color components ( R, G & B ) seperately for each pixel P[i, j].

Usage

Make sure you set classpath during compilation & running.

import in.itzmeanjan.filterit.ImportExportImage;
import in.itzmeanjan.filterit.bitwise.BitwiseOR;

class Main{
    public static void main(String [] args){
        ImportExportImage.exportImage(
        new BitwiseOR().operate("cloud.jpg", "gradient.jpg"),
        "bitwiseORed.jpg");
    }
}

Operand Images

Image 1 Image 2
operandOne operandTwo

Resuling Image = Image_1 | Image_2

bitwiseORed