Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.52 KB

bitwiseXOROp.md

File metadata and controls

56 lines (39 loc) · 1.52 KB

Bitwise XOR Operation

Introduction

So we're given with two images of equal dimension & asked to XOR them, what do we do ?

We'll go through each pixel P[x, y] on both images & perform bitwise XOR operation on their corresponding intensity values, and result to be stored at P[x, y] on sink image.

As we're also interested in supporting color images, we need to perform aforementioned XOR op 3 times ( for R, G & B color component ) for each pixel location P[x, y].

Truth Table for XOR

c = a ^ b

a b c
0 0 0
0 1 1
1 0 1
1 1 0

Usage

  • Main.java in another project, where I'm leveraging filterIt.
// Main.java
import in.itzmeanjan.filterit.ImportExportImage;
import in.itzmeanjan.filterit.bitwise.BitwiseXOR;

class Main{
    public static void main(String [] args){
        ImportExportImage.exportImage(
        new BitwiseXOR().operate("cloud.jpg", "white.jpg"),
        "bitwiseXORedOne.jpg");
    }
}
  • Compilation & running
# in.itzmeanjan.filterit.jar & Main.java are present in same directory
$ javac -cp ".:in.itzmeanjan.filterit.jar" Main.java
$ java -cp ".:in.itzmeanjan.filterit.jar" Main

Resulting Images

Image 1 Image 2 Image_1 ^ Image_2
operandOne operandTwo bitwiseXORed
operandOne operandTwo bitwiseXORed

Thanking you, 😊