var a1,a1,a3,b1,b2,b3;
function chooseImage1(){
var canvas1 = document.getElementById("image1");
var fileinput = document.getElementById("img1");
image = new SimpleImage(fileinput);
image.drawTo(canvas1);
}
function chooseImage2(){
var canvas2 = document.getElementById("image2");
var fileinput = document.getElementById("img2");
hideimage = new SimpleImage(fileinput);
hideimage.drawTo(canvas2);
}
function encode()
{
var opimage =new SimpleImage();
var output = document.getElementById("output");
for(var pix of image.values()){
var red = a1 + b1;
var green = a1 + b1;
var blue = a1 + b1;
pix.setRed(red);
pix.setGreen(green);
pix.setBlue(blue);
}
image.drawTo(output);
}
function MainImages()
{
for(var pixel of image.values()){
var r = Math.floor(pixel.getRed()/16)*16;
var g = Math.floor(pixel.getGreen()/16)*16;
var b = Math.floor(pixel.getBlue()/16)*16;
a1 = pixel.setRed(r);
a2 = pixel.setGreen(g);
a3 = pixel.setBlue(b);
}
}
function HideImages()
{
for(var pixel of hideimage.values()){
var r = Math.floor(pixel.getRed()/16);
var g = Math.floor(pixel.getGreen()/16);
var b = Math.floor(pixel.getBlue()/16);
b1 = pixel.setRed(r);
b2 = pixel.setGreen(g);
b3 = pixel.setBlue(b);
}
}
.canvas1{
height:400px;
width:800px;
border: 2px solid white;
border-radius:20px;
}
body{background:#0059b3;}
h1{color:#000066;}
button
{
height:50px;
width: 150px;
background:#9900ff;
border-radius:20px;
font-size:20px;
font-family:times-new-roman;
}
<body>
<script src='https://www.dukelearntoprogram.com/course1/common/js/image/SimpleImage.js'>
</script>
<canvas id="image1"></canvas>
<canvas id="image2"></canvas>
<canvas id="output"></canvas>
<br>
<input type="file" id="img1" accept="image/*" onchange="chooseImage1();">
<input type="file" id="img2" accept="image/*" onchange="chooseImage2();">
<button id="encode" onclick="encode();">Encode</button>
</body>
您好,每个我都想使该图像成为Stegnoghraphy Web应用程序的人,每次运行此程序时,它只会将输出显示为黑色图像,我不知道它是怎么了。但是每个输出都是黑色图像。
链接到我的代码笔:https://codepen.io/dbhatt97/pen/VwvOLOL
代码的目的是将一个图像隐藏到另一个像素级别的图像中,并且它使用的是立体视觉技术。
变量image
是原始图像。变量hideimage
是要隐藏的图像。我认为我的JavaScript出了点问题,因为它始终显示黑色图像作为输出。