- This topic is empty.
-
AuthorPosts
-
January 24, 2026 at 7:47 am #5961
ߓ Context (Initial Code)
When recovering a hidden black-and-white image using LSB steganography, we often create a new blank image and then fill it pixel-by-pixel:
from PIL import Image def reveal_bw_image(filename): img = Image.open(filename) width, height = img.size pixels = img.load() secret_img = Image.new("L", (width, height)) secret_pixels = secret_img.load() # later we fill it inside loops... return secret_imgThis leads to a common beginner doubt ߑ
✅ Q&A: What Are the Pixel Values in a Brand New
Image.new()Image?❓ Q: When we create a new image like this…
secret_img = Image.new("L", (width, height)) secret_pixels = secret_img.load()…what are the pixel values at this point?
✅ Answer:
At this stage, the image is completely blank, and every pixel is set to0by default.
❓ Q: What does pixel value
0mean in"L"mode?✅ Answer:
"L"means grayscale (black & white intensity image), where each pixel value is:0→ black255→ white
So when the image is created, it starts as a full black image.
❓ Q: Why does Pillow set all pixels to 0?
✅ Answer:
BecauseImage.new()is creating an empty canvas.
Before we fill the pixels with meaningful values, Pillow initializes the canvas to a safe default:✅
0(black) everywhere.
❓ Q: How do pixels get meaningful values later?
✅ Answer:
Later in the program, the loop overwrites each pixel with recovered secret data, for example:secret_pixels[x, y] = hidden_bit * 255So the image changes from:
- completely black initially
to - a visible recovered hidden
-
AuthorPosts
- You must be logged in to reply to this topic.

