Please bookmark this page to avoid losing your image tool!

Image Chaotic Noise Generator For Deepfake Detection Evasion

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
/**
 * Applies chaotic noise to an image, a technique often used in attempts
 * to evade AI-based detection systems like those for deepfakes.
 * This is a form of adversarial perturbation.
 *
 * @param {Image} originalImg The original javascript Image object.
 * @param {number} intensity The strength of the noise. A value between 0 and 255. Higher values mean more visible noise. Defaults to 10.
 * @param {number} seed A seed for the random number generator to create reproducible noise patterns. If 0, a random seed is used. Defaults to 0.
 * @returns {HTMLCanvasElement} A new canvas element with the processed image.
 */
function processImage(originalImg, intensity = 10, seed = 0) {
    // 1. Create a canvas and get its 2D rendering context.
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // 2. Set the canvas dimensions to match the original image.
    const width = originalImg.naturalWidth || originalImg.width;
    const height = originalImg.naturalHeight || originalImg.height;
    canvas.width = width;
    canvas.height = height;

    // 3. Draw the original image onto the canvas.
    ctx.drawImage(originalImg, 0, 0);

    // 4. Get the image data, which is an array of RGBA values for each pixel.
    const imageData = ctx.getImageData(0, 0, width, height);
    const data = imageData.data;

    // 5. Set up a simple seeded pseudo-random number generator (PRNG).
    // This makes the "chaotic" noise reproducible if a seed is provided.
    let currentSeed = (seed === 0 || seed === null) ? Math.floor(Math.random() * 2**32) : seed;
    const random = () => {
        // A simple Linear Congruential Generator (LCG).
        currentSeed = (1664525 * currentSeed + 1013904223) % 4294967296; // 2^32
        return currentSeed / 4294967296; // Return a value between 0.0 and 1.0
    };

    // Clamp the intensity to a safe range (0-255).
    const clampedIntensity = Math.max(0, Math.min(255, intensity));

    // 6. Iterate through every pixel in the image data array.
    // The array is flat, so we step by 4 (R, G, B, A).
    for (let i = 0; i < data.length; i += 4) {
        // Generate a random noise value for each color channel (R, G, B).
        // The noise will be in the range [-intensity, +intensity].
        const rNoise = (random() * 2 - 1) * clampedIntensity;
        const gNoise = (random() * 2 - 1) * clampedIntensity;
        const bNoise = (random() * 2 - 1) * clampedIntensity;

        // Add the noise to the original pixel values.
        // The `data` array is a Uint8ClampedArray, which automatically
        // clamps any value assigned to it to the 0-255 range.
        data[i] = data[i] + rNoise;       // Red channel
        data[i + 1] = data[i + 1] + gNoise; // Green channel
        data[i + 2] = data[i + 2] + bNoise; // Blue channel
        // The alpha channel (data[i + 3]) is left unchanged.
    }

    // 7. Put the modified pixel data back onto the canvas.
    ctx.putImageData(imageData, 0, 0);

    // 8. Return the canvas element containing the noisy image.
    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

The Image Chaotic Noise Generator for Deepfake Detection Evasion is a tool designed to apply chaotic noise to images. This technique can help in evading AI-based detection systems commonly used for identifying deepfake content. Users can adjust the intensity of the noise applied to the image, as well as specify a seed for reproducibility of the noise patterns. This tool can be utilized in scenarios where testing deepfake detection systems or exploring the robustness of image analysis algorithms is required.

Leave a Reply

Your email address will not be published. Required fields are marked *