Bitwise AND Operation

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

Bit String One Bit String Two AND-ed
00010010 00100001 00000000

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 AND 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].

And result will be really interesting … :wink:

Usage

Make sure you set classpath during compilation & running.

// Main.java
import in.itzmeanjan.filterit.ImportExportImage;
import in.itzmeanjan.filterit.bitwise.BitwiseAND;

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

During compilation

# 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

Operand Images

Image 1 Image 2
operandOne operandTwo

Resuling Image = Image_1 & Image_2

bitwiseANDed