Skip to main content
deleted 149 characters in body
Source Link
Daniel T
  • 1.4k
  • 15
  • 22

Task 2 was a similar conversion as described. Knowing the Netpbm format exists allowed me to skip a "map 0 -> 0 and 1 -> 255" step and print the image directly. I tried using Unicode without Netpbm, but my terminal wouldn't let me zoom out far enough, so I used Netpbm and GIMP. Either because Netpbm is weird or the suggested instructions were confusing, I originally outputtedfaced the bits directlychallenge of debugging that Netpbm, unlike others, uses has 0 as a white-on-black image not black, but I found thatrequiring me to invert the drawing looks better when invertedcolors back to be black-on-whitenormal.

Task 2 image (original (un)inverted version)

Task 2 was a similar conversion as described. Knowing the Netpbm format exists allowed me to skip a "map 0 -> 0 and 1 -> 255" step and print the image directly. I tried using Unicode without Netpbm, but my terminal wouldn't let me zoom out far enough, so I used Netpbm and GIMP. Either because Netpbm is weird or the suggested instructions were confusing, I originally outputted the bits directly as a white-on-black image, but I found that the drawing looks better when inverted to be black-on-white.

Task 2 image (original (un)inverted version)

Task 2 was a similar conversion as described. Knowing the Netpbm format exists allowed me to skip a "map 0 -> 0 and 1 -> 255" step and print the image directly. I tried using Unicode without Netpbm, but my terminal wouldn't let me zoom out far enough, so I used Netpbm and GIMP. I faced the challenge of debugging that Netpbm, unlike others, uses has 0 as white not black, requiring me to invert the colors back to normal.

Task 2 image

added 298 characters in body; deleted 1 character in body
Source Link
Daniel T
  • 1.4k
  • 15
  • 22

Task 2 was a similar conversion as described. Knowing the Netpbm format exists allowed me to skip a "map 0 -> 0 and 1 -> 255" step and print the image directly. I tried using Unicode without Netpbm, but my terminal wouldn't let me zoom out far enough, so I used Netpbm and GIMP. Either because Netpbm is weird or the suggested instructions were confusing, I originally outputted the bits directly as a white-on-black image, but I found that the drawing looks better when inverted to be black-on-white.

#!/usr/bin/env python3
# task2.py
from mylib import SteganographyBitstream, read_byte
def print_pbm(bitstream):
    assert next(bitstream) == 1
    assert next(bitstream) == 0
    width: int = (read_byte(bitstream) << 8) | read_byte(bitstream)
    height: int = (read_byte(bitstream) << 8) | read_byte(bitstream)
    print("P1")
    print(width, height)
    for _ in range(height):
        for _ in range(width):
            print(1 - next(bitstream), end="")
        print()
print_pbm(SteganographyBitstream("mCeETXDs.png"))

Task 2 image (Task 2 imageoriginal (un)inverted version)

Task 2 was a similar conversion as described. Knowing the Netpbm format exists allowed me to skip a "map 0 -> 0 and 1 -> 255" step and print the image directly. I tried using Unicode without Netpbm, but my terminal wouldn't let me zoom out far enough, so I used Netpbm and GIMP.

#!/usr/bin/env python3
# task2.py
from mylib import SteganographyBitstream, read_byte
def print_pbm(bitstream):
    assert next(bitstream) == 1
    assert next(bitstream) == 0
    width: int = (read_byte(bitstream) << 8) | read_byte(bitstream)
    height: int = (read_byte(bitstream) << 8) | read_byte(bitstream)
    print("P1")
    print(width, height)
    for _ in range(height):
        for _ in range(width):
            print(next(bitstream), end="")
        print()
print_pbm(SteganographyBitstream("mCeETXDs.png"))

Task 2 image

Task 2 was a similar conversion as described. Knowing the Netpbm format exists allowed me to skip a "map 0 -> 0 and 1 -> 255" step and print the image directly. I tried using Unicode without Netpbm, but my terminal wouldn't let me zoom out far enough, so I used Netpbm and GIMP. Either because Netpbm is weird or the suggested instructions were confusing, I originally outputted the bits directly as a white-on-black image, but I found that the drawing looks better when inverted to be black-on-white.

#!/usr/bin/env python3
# task2.py
from mylib import SteganographyBitstream, read_byte
def print_pbm(bitstream):
    assert next(bitstream) == 1
    assert next(bitstream) == 0
    width: int = (read_byte(bitstream) << 8) | read_byte(bitstream)
    height: int = (read_byte(bitstream) << 8) | read_byte(bitstream)
    print("P1")
    print(width, height)
    for _ in range(height):
        for _ in range(width):
            print(1 - next(bitstream), end="")
        print()
print_pbm(SteganographyBitstream("mCeETXDs.png"))

Task 2 image (original (un)inverted version)

added 746 characters in body
Source Link
Daniel T
  • 1.4k
  • 15
  • 22

Task 1 output:

The first part of the sentence is "Three may keep a secret, ...".

Task 2: Decode a binary image

A binary image is hidden in the least significant bits of the butterfly image, the encoding scheme is:

  • Simple LSB Encoding**
  • Header: [1, 0]
  • Next 16 bits: image width in pixels
  • Next 16 bits: image height in pixels
  • Raw pixels of the binary image

Hint: Create and fill an image array of the derived width and height with the encoded hidden pixels. In order to view your image in classic viewers, it might be helpful to map 0 -> 0 and 1 -> 255. Derive the second part of the sentence and answer the question about the image.

Task 2 image

Task 1 output:

The first part of the sentence is "Three may keep a secret, ...".

Task 2: Decode a binary image

A binary image is hidden in the least significant bits of the butterfly image, the encoding scheme is:

  • Simple LSB Encoding**
  • Header: [1, 0]
  • Next 16 bits: image width in pixels
  • Next 16 bits: image height in pixels
  • Raw pixels of the binary image

Hint: Create and fill an image array of the derived width and height with the encoded hidden pixels. In order to view your image in classic viewers, it might be helpful to map 0 -> 0 and 1 -> 255. Derive the second part of the sentence and answer the question about the image.

Task 2 image

added 88 characters in body; added 3 characters in body; added 21 characters in body
Source Link
Daniel T
  • 1.4k
  • 15
  • 22
Loading
Source Link
Daniel T
  • 1.4k
  • 15
  • 22
Loading