Hi guys i have a PGM i have created, and would like to read in to python line by line
is there a quick and easy way to do this, as i want to alter the LSB for each say purple pixel there is
Thanks
Edit
Ok guys the input image is a PNG file, of our university,
This is the code i have so far:
it takes the text to be hidden and also the image, the image gets converted to PPM and this is where i get stuck at
i want to be able to read in the PPM image, and change the LSB of the purple, ideally the last purple circle in the image
CODE:
import Image
import os
import re
import numpy #sudo apt-get install python-numpy #Also need matplotlib
#Text to be hidden within the image
text_to_be_hidden = "test"
#Converts text to binary (NO spaces)
text_to_be_hidden_binary = ''.join(format(ord(x), 'b') for x in text_to_be_hidden)
#User info
print "text to be hidden:", text_to_be_hidden
print "text to be hidden in binary:", text_to_be_hidden_binary
#Converts a png image to pgm
print "Taking image to be inputted, and converting it to ppm"
im = Image.open('Portsmouth.png')
im = im.convert('RGB')
im.save('Portsmouth.ppm')
file_size_of_pgm = os.stat('Portsmouth.ppm').st_size #Gets the file size of the image in byte
#Make sure we have enough space to add the data, if under 5mb ? then close
if file_size_of_pgm < 5000000:
print "PGM file size is too small exiting now"
sys.exit("System exiting")
EDIT 2
i have now read in the data :
# Open the PPM file and process the 3 first lines (HEADER)
f = open("Portsmouth.ppm")
color = f.readline().splitlines()
size_x, size_y = f.readline().split()
max = f.readline().splitlines()
print color
print size_x
print size_y
print max
data = f.read().split()
print data
i suppose the new question is how can i target only the last circle in the image to alter ?