Steganography

Steganography is a process of hiding an image into another image.
Here’s the code for hiding an image……


function crop(image, width, height){
    var n = new SimpleImage(width,height);
    for(var p of image.values()){
   	   var x = p.getX();
   	   var y = p.getY();
   	   if (x < width && y  255)   print("error: answer too big");     return answer;
}

function combine(a,b){
     var n = new SimpleImage(a.getWidth(), a.getHeight());
     for(var pa of a.values()){
    	var x = pa.getX();
        var y = pa.getY();
        var pb = b.getPixel(x,y);
        var np = n.getPixel(x,y);
        np.setRed(newpv(pa.getRed(),pb.getRed()));
        np.setGreen(newpv(pa.getGreen(),pb.getGreen()));
        np.setBlue(newpv(pa.getBlue(),pb.getBlue()));
     }
     return n;
}

var start = new SimpleImage("astrachan.jpg");
var hide = new SimpleImage("duvall.jpg")

var cropWidth = start.getWidth();
if (hide.getWidth() < cropWidth) {
	cropWidth = hide.getWidth();
}
var cropHeight = start.getHeight();
if (hide.getHeight() < cropHeight) {
	cropHeight = hide.getHeight();
}
start = crop(start,cropWidth, cropHeight);
hide = crop(hide,cropWidth, cropHeight);

start = chop2hide(start);
hide = shift(hide);

var result = combine(start,hide);


print(start);
print(hide);
print(result);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s