Advanced Algorithms

Lab #1: Steganography

Objective

During this activity, students will be able to:

IMPORTANT

For this programming assignment, students are required to complete all work by themselves and are not permitted to automatically generate code by using AI-assisted tools such as GitHub Copilot, ChatGPT, Gemini, or any similar platforms. Using AI tools in this way would undermine the learning process and violate academic integrity policies. The purpose of this assignment is to assess your understanding and application of the concepts covered in class. Failure to comply with these guidelines may result in academic penalties, including but not limited to, a lower grade.

If you have any questions about the assignment or need clarification on any concepts, please do not hesitate to visit your instructor during office hours. Rely solely on your own knowledge, the course materials, and any authorized resources provided by the instructor.

Description

This activity must be developed in the pre-assigned teams of two.

ste·ga·no·graph·y (noun)
The practice of concealing messages or information within other nonsecret text or data.

For this lab you will need to use the Pillow library. If you have any question regarding it, check the Pillow documentation for more information.

We have the following processed PNG image file (click on the image to download it):

scarlett.png

Original image source: https://wallpaperaccess.com/full/5910215.jpg

There are three independent 1-bit images hidden in the least significant bit of every byte from each of the three color channels of the image.

Write a Python script called extract_hidden_images.py that:

  1. Takes as a command line argument the name of an RGB mode PNG file. The program should print an error message and quit under the following circumstances:
    1. The name of the file was not provided as a command line argument.
    2. The provided file name doesn’t have a .png extension.
    3. An exception is raised when trying to open the image file. It’s important to specify the reason as part of the error message.
    4. The mode of the file is not RGB.
  2. Extracts from the red, green, and blue channels the corresponding hidden 1-bit images placing the result in three 1-bit PNG images with the following suffixes after the original extensionless file-name :
    • file-name_channel_1_red.png
    • file-name_channel_2_green.png
    • file-name_channel_3_blue.png

Example

Assuming the above image (scarlett.png) is stored in the same directory as your script you should be able to type at the terminal the following command:

python extract_hidden_images.py scarlett.png

The following three files should be created in the same directory where the scarlett.png file is located:

scarlett_channel_1_red.png
scarlett_channel_2_green.png
scarlett_channel_3_blue.png

Deliverables

Place in a comment at the top of the extract_hidden_images.py source file the authors’ personal information (student ID and name), for example:

#----------------------------------------------------------
# Lab #1: Steganography
# Image processing through bit manipulation.
#
# Date: 23-Aug-2024
# Authors:
#           A01770771 James Howlett
#           A01777771 Wade Wilson
#----------------------------------------------------------

Upload Instructions

To deliver the extract_hidden_images.py file, please provide the following information:

Request PIN

Only one team member needs to upload the file.

Due date is Friday, August 23.