3

I just found this image in the book I am studying for Computer Vision (Digital Image Processing by Rafael C. Gonzalez and Richard E. Woods):

image showing picture transformed in different ways

The book does not explain how to reach this result, and I was wondering how I could reach the same results on other images.

The context in which I found the picture on the book is "block transform coding with the DFT, WHT, and DCT". The text near the image says:

(a) A 256-bit monochrome image.
(b)–(h) The four most significant binary and Gray-coded bit planes of the image in (a).

Do you know any possible way to reach this weird result?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
nic
  • 105
  • 6
  • 1
    At a guess, the `256 bit` part is a thinko, and is meant to refer to 256 shades of grey (8 bits). At least as I interpret things, the subsequent images are the most significant bit, second most significant bit, and so on. – Jerry Coffin Jun 15 '23 at 15:59
  • @JerryCoffin that's actually the same I was getting from the text, but I thought it doesnt look like usual bit-plane "effect" . It looks like it has some added transformation on those "extracted bits" – nic Jun 15 '23 at 16:09
  • Could be, but without more to go on, it's next to impossible to even guess. – Jerry Coffin Jun 15 '23 at 16:12
  • anything "added" is either due to this being *a scan of a print*, or being gray code (unclear). also probably some funky dithering effect if the original image was seriously noisy. see my answer for what I mean by noise. when you squint, noise turns into gray. – Christoph Rackwitz Jun 15 '23 at 16:47

1 Answers1

2

Here are binary "bit planes".

If you have questions on Gray code, please first read up on it. Then we can discuss that. The ideas aren't much different from binary code.

That photo of a book page you have there... shows the planes of some source image. Noise in the source image becomes successively more apparent in the lower planes.

Noise, through various copying and printing steps that act like a lowpass, turns into grayscale. That's why only the highest planes show fairly clean edges and flat black/white.

Note that each plane is stretched to be fully black or white. If I didn't do that, you'd just get ever darker pictures, the further down the bits you go.

im = cv.imread(cv.samples.findFile("lena.jpg"), cv.IMREAD_GRAYSCALE)

for k in range(8):
    title = f"bit position {k}, value {2**k}"
    plane = ((im >> k) & 1)
    cv.imshow(title, plane * 255)
    cv.waitKey()
    cv.destroyWindow(title)

bit 7 bit 6

bit 5 bit 4

bit 3 bit 2

bit 1 bit 0


plane = (im & (1 << k)) # and no scaling by 255

bit 7 bit 6

bit 5 bit 4

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36