Madeline Krajewski
This week, I thoroughly decoded my encoder and decoder. I tested for every bug I could conceive of, and fixed almost all of the ones I encountered. There is one bug left, as far as I can tell, and it’s in some ways only half of a bug. I’ll explain more later, but for now, the successes!
First, here is a table showing what each test is, and what images were used. I’ll restate it throughout my post, but I figured it might be handy to gather all the information in one location.
The “Normal” Tests:
| Test: | Host Image (bird): | Secret Image (bird): |
| Host & Secret have the same width and height | European Robin (HostBird in past blog posts) | Common Kingfisher (SecretBird in past blog posts) |
| Secret is wider than the Host but has a smaller total pixel count | California Quail | Ruby Red Hummingbird |
| Secret is taller than the Host but has a smaller total pixel count | Ruby Red Hummingbird | Kookaburra |
| Secret is wider than the Host but has an identical total pixel count | Puffin | Peacock |
| Secret is taller than the Host but has an identical total pixel count | Peacock | Puffin |
Secret is 1/2 the size of or smaller than the Host:
| Test: | Host Image: | Secret Image: |
| Secret has a longer width than the Host* | California Quail | Puffin |
| Secret has a taller height than the Host | Puffin | Stork Billed Kingfisher |
| Secret is exactly half the size of the Host** | Peacock | Short-Eared Owl |
| The Host has an odd number of pixels | Puffin (odd) | Stork Billed Kingfisher |
** the image is encoded with an even number of bits
Additionally, here are each image’s dimensions and total pixel counts:
| Image: | Width: | Height: | Total # of Pixels: |
| European Robin | 2000 | 2000 | 4,000,000 |
| Common Kingfisher (blue) | 2000 | 2000 | 4,000,000 |
| Ruby Red Hummingbird | 3920 | 2800 | 10,976,000 |
| Kookaburra | 2500 | 3500 | 8,750,000 |
| California Quail | 2900 | 4200 | 12,180,000 |
| Puffin | 3000 | 2000 | 6,000,000 |
| Puffin (odd) | 2999 | 1999 | 5,995,001 |
| Peacock | 2000 | 3000 | 6,000,000 |
| Stork Billed Kingfisher (brown) | 1200 | 2400 | 2,880,000 |
| Short-Eared Owl | 1500 | 2000 | 3,000,000 |
And lastly, a dropdown box with each image for those who are less familiar with different bird species:
Bird Images
European Robin

Common Kingfisher

Ruby Red Hummingbird

Kookaburra

California Quail

Puffin

Peacock

Stork Billed Kingfisher

Short-Eared Owl

Now, for the test results!
Here are the “Normal” tests. All of them worked, thankfully!
Host & Secret have the same width and height

Why test it?
This test is to make sure that, with all my programming changes, this test still works. It does, hooray! It did not, however, work earlier this week. Thankfully, with the assistance of Dr. Meyer & Dr. McVey, we found the error! I had placed the image display condition inside a condition which only triggered when the secret image’s total pixel count was less than the total pixel count of the host image.
Secret is wider than the Host but has a smaller total pixel count

Why test it?
This is to verify that the decoder can properly determine what to do when the secret image’s pixels carry over to the next column of the host image when the secret image’s row has not completed. That is, one row of the secret image’s pixels get split across multiple rows of the host image. Additionally, this makes sure that this condition works when an image has an offset.
Secret is taller than the Host but has a smaller total pixel count

Why test it?
For similar reasons as above, I wanted to make sure that the decoder knew what to do when a secret image might have many small rows which may get encoded in the same rows. The secret image has a different counter than the host image in the decoder, and I want to verify it works correctly for the two failure points: width, and height. I encode and decode each image in a nested for loop (I promise, that’s the proper term and not simply a bird pun!). However, I need to keep track of four variables instead of 2: the width of the host, the width of the secret, the height of the host, and the height of the secret. That’s a lot of room for errors, and it’s quite a relief that I’ve passed this test!
Secret is wider than the Host but has an identical total pixel count

Why test it?
I wanted to verify it worked. Neither of these tests have an offset, so in a sense, I’ve already done the more difficult test above. However, it’s important to test every case, and this is one.
Secret is taller than the Host but has an identical total pixel count

Why test it?
Simply put, to make sure it didn’t not work.
Now, for the disappointing results. Alas, something has gone wrong either in my encoder or decoder, and I’m unsure which. Notice how the secret image is strangely desaturated and has some off colors in places? That’s the issue.
Secret is 1/2 the size of or smaller than the Host:
Secret has a longer width than the Host

Why test it?
This group of tests is a completely separate process for decoding. This is because the encoding works completely differently: since the secret image is so drastically smaller than the host image, we can encode one pixel of the secret image in two pixels of the host. This allows for more information to be preserved, as well as more subtle encoding, depending on what the user chooses. Therefore, we need to test similar cases here as we did for the “Normal” encoding process.
Secret has a taller height than the Host

Why test it?
Because it’s important to see what might happen before a user does.
Secret is exactly half the size of the Host

Why test it?
Well, I’ve so far presumed the image will have an offset and as such, will not use every single pixel for encoding in the host image. It appears this is an incredibly important test, as the owl seems to have gotten shifted pretty off center. For reference, this is what our owl should look like:

The Host has an odd number of pixels

Why test it?
I’ve done a sneaky thing where I throw away the odd-numbered column in order to make the encoder work properly. Since I need to encode two pixels at once in order to split the secret image’s pixel information, I need to do each encoding in groups of two. Otherwise, I (and therefore, my program) would struggle to know whether we encoded the first half or second half of the pixel data. I tackled this by making my inner, traverse-through-the-row for loop increment by two each time. It needs to stop when it is still less than the check, but this could go haywire when the width is odd. (If our int i is currently 12, and the loop ends at 13, it could cause the program to try to encode on a pixel which doesn’t exist).
I chose to resolve this issue by having the encoder pretend the final column does not exist. As a result, I need the decoder to do the same thing.
Well, it appears I have one final thing to tackle for Algorithm 1, but I will say, I am quite chuffed with the results of this week! I have tested as I’ve gone, but sitting down and testing everything at once was quite the ordeal. For one, I had to go through and determine every test which needed to occur, and also debug until I got the correct results.
This week, I’ve also begun the process of going through and adding proper documentation to my code. Here’s an example of what that looks like:

This was one of the easier ones to accomplish. Current count is 5/6 of the encoder, and 0/4 of the decoder. The last one of the encoder is the one in which I actually do the bulk of the work, and as such, it’s quite a daunting one to tackle. I plan to print off that function’s code and go through with a highlighter to make it easier to do.
Thankfully, the decoder is in a much nicer state. There’s only one big function to do there, and it is not half as complicated as the encoder’s counterpart! I’m hoping to have all of this documentation done by the end of next week.
Lastly, I’ve copied the Sources from last week here, since this is the week in which the images got used:
Sources
“Puffin Talk on Saltee Island Great” by Wynand van Poortvliet on Unsplash
“California Quail” by Richard Lee on Unsplash
“Black-Capped Chickadee” by Patrice Bouchard on Unsplash
“Blue-Winged Kookaburra” by Peter Scholten on Unsplash
“A Peacock in the Helsinki Zoo” by Julius Jansson on Unsplash
“Stork-Billed Kingfisher Perching on Brown Wooden Stand” by Thomas Maximilian Lener on Unsplash
“Pink Pelican” by Maksim Samsonov on Unsplash
“Ruby Throated Hummingbird” Photo by Candi Foltz on Unsplash
“The Raven” by Daniel Shapiro on Unsplash
“UK Seagull Portrait” Photo by Peter F. Wolf on Unsplash
“Bee Hummingbird, Cuba” by Anne and Saturnino Miranda from Pixabay
“Short-Eared Owl” by Richard Lee on Unsplash
“Tufted Titmouse” by Mark Olsen on Unsplash