```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>画像透過と重ね合わせアプリ</title>
<style>
canvas {
border: 1px solid #000;
}
</style>
</head>
<body>
<input type="file" id="image1" accept="image/*" style="display: block; margin: 10px;">
<input type="file" id="image2" accept="image/*" style="display: block; margin: 10px;">
<div style="position: relative; width: 400px; height: 400px;">
<canvas id="canvas" width="400" height="400"></canvas>
</div>
<script>
function loadImage(file, callback) {
const reader = new FileReader();
reader.onload = function(event) {
const img = new Image();
img.src = event.target.result;
img.onload = () => callback(img);
}
reader.readAsDataURL(file);
}
function processImage(img, color) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 400;
canvas.height = 400;
ctx.drawImage(img, 0, 0, 400, 400);
const imageData = ctx.getImageData(0, 0, 400, 400);
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
if (data[i] > 200 && data[i + 1] > 200 && data[i + 2] > 200) {
data[i + 3] = 0; // Alpha channel
} else {
data[i] = color[0];
data[i + 1] = color[1];
data[i + 2] = color[2];
}
}
ctx.putImageData(imageData, 0, 0);
return canvas;
}
document.getElementById('image1').onchange = function(event) {
const file = event.target.files[0];
loadImage(file, function(img) {
const canvas1 = processImage(img, [0, 0, 255]);
const ctx = document.getElementById('canvas').getContext('2d');
ctx.clearRect(0, 0, 400, 400);
ctx.drawImage(canvas1, 0, 0);
});
}
document.getElementById('image2').onchange = function(event) {
const file = event.target.files[0];
loadImage(file, function(img) {
const canvas2 = processImage(img, [255, 0, 0]);
const ctx = document.getElementById('canvas').getContext('2d');
ctx.globalCompositeOperation = 'source-over';
ctx.drawImage(canvas2, 0, 0);
});
}
</script>
</body>
</html>
```