ImageToBooleanFunction[i_Image] := BooleanFunction[Flatten[First[Binarize[i]]]]
BooleanFunctionToImage[b_BooleanFunction] := Image[Partition[Boole[BooleanTable[b]], 2^(BooleanVariables[b]/2)]]