Skip to content

Commit

Permalink
added stegasaurusography.
Browse files Browse the repository at this point in the history
  • Loading branch information
kscottz committed Feb 16, 2013
1 parent d9e652f commit 82eead5
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
88 changes: 88 additions & 0 deletions SimpleCV/ImageClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12302,6 +12302,94 @@ def drawSIFTKeyPointMatch(self, template, distance=200, num=-1, width=1):
resultImg.drawLine(pt_a, pt_b, color=Color.getRandom(Color()),thickness=width)
return resultImg

def stegaEncode(self,message):
"""
**SUMMARY**
A simple steganography tool for hidding messages in images.
**PARAMETERS**
* *message* -A message string that you would like to encode.
**RETURNS**
Your message encoded in the returning image.
**EXAMPLE**
>>>> img = Image('lenna')
>>>> img2 = img.stegaEncode("HELLO WORLD!")
>>>> img2.save("TopSecretImg.png")
>>>> img3 = Image("TopSecretImg.png")
>>>> img3.stegaDecode()
**NOTES**
More here:
http://en.wikipedia.org/wiki/Steganography
You will need to install stepic:
http://domnit.org/stepic/doc/pydoc/stepic.html
You may need to monkey with jpeg compression
as it seems to degrade the encoded message.
PNG sees to work quite well.
"""

try:
import stepic
except ImportError:
logger.warning("stepic library required")
return None
warnings.simplefilter("ignore")
pilImg = pil.frombuffer("RGB",self.size(),self.toString())
stepic.encode_inplace(pilImg,message)
retVal = Image(pilImg)
return retVal.flipVertical()

def stegaDecode(self):
"""
**SUMMARY**
A simple steganography tool for hidding and finding
messages in images.
**RETURNS**
Your message decoded in the image.
**EXAMPLE**
>>>> img = Image('lenna')
>>>> img2 = img.stegaEncode("HELLO WORLD!")
>>>> img2.save("TopSecretImg.png")
>>>> img3 = Image("TopSecretImg.png")
>>>> img3.stegaDecode()
**NOTES**
More here:
http://en.wikipedia.org/wiki/Steganography
You will need to install stepic:
http://domnit.org/stepic/doc/pydoc/stepic.html
You may need to monkey with jpeg compression
as it seems to degrade the encoded message.
PNG sees to work quite well.
"""
try:
import stepic
except ImportError:
logger.warning("stepic library required")
return None
warnings.simplefilter("ignore")
pilImg = pil.frombuffer("RGB",self.size(),self.toString())
result = stepic.decode(pilImg)
return result

def findFeatures(self, method="szeliski", threshold=1000):
"""
**SUMMARY**
Expand Down
Binary file modified SimpleCV/sampleimages/orson_welles.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SimpleCV/sampleimages/simplecv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions SimpleCV/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2155,8 +2155,7 @@ def test_findHaarFeatures():

results = [img]
name_stem = "test_findHaarFeatures"
perform_diff(results,name_stem)

perform_diff(results,name_stem)


def test_biblical_flood_fill():
Expand Down Expand Up @@ -3135,3 +3134,14 @@ def test_ColorMap():
result = [img]
name_stem = "test_color_map"
perform_diff(result,name_stem,1.0)


def test_Steganograpy():
img = Image(logo)
msg = 'How do I SimpleCV?'
img.stegaEncode(msg)
img.save(logo)
img2 = Image(logo)
msg2 = img2.stegaDecode()
pass

0 comments on commit 82eead5

Please sign in to comment.