stough 202-
A quick bit-slicing demo to show that the low-order bits often show little relevant information, while the high-order bits show more. We'll also show this off as an example of steganography.
%matplotlib widget
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as mcolors
import skimage.color as color
from ipywidgets import VBox, HBox, IntSlider
from scipy.interpolate import interp1d
# For importing from alternative directory sources
import sys
sys.path.insert(0, '../dip_utils')
from matrix_utils import (arr_info,
make_linmap)
from vis_utils import (vis_rgb_cube,
vis_hsv_cube,
vis_hists,
vis_pair,
lab_uniform)
I = plt.imread('../dip_pics/roadforest.jpg')
I = (255*color.rgb2gray(I)).astype('uint8')
#Load the message image
Im = plt.imread('../dip_pics/happy1BitPad.png')[...,0]
Im = Im.astype('uint8')
vis_pair(I, Im, show_ticks=False, cmap='gray')
print(arr_info(I))
print(arr_info(Im))
# Use bit-wise and (&0b) to view each plane of the image.
plt.figure(figsize=(6,3))
plt.imshow(I&0x08, cmap='gray');
# Use bit-wise and (&0b) to view each plane of the image.
plt.figure(figsize=(6,3))
plt.imshow(I|Im, cmap='gray');
J = I|Im
plt.figure(figsize=(6,3))
plt.imshow(J&0x01, cmap='gray');
vis_pair(I, J, cmap='gray')