Please bookmark this page to avoid losing your image tool!

Image Japanese Anime Cel Shading Renderer For Military Vehicles

(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.
async function processImage(originalImg, quantizationLevels = 4, edgeThreshold = 80, edgeColor = 'black') {

    const width = originalImg.width;
    const height = originalImg.height;

    const canvas = document.createElement('canvas');
    canvas.width = width;
    canvas.height = height;
    const ctx = canvas.getContext('2d', { willReadFrequently: true });
    ctx.drawImage(originalImg, 0, 0, width, height);

    /**
     * Helper function to parse a CSS color string into an RGB object.
     * @param {string} colorStr - The color string (e.g., 'black', '#FF0000', 'rgb(255,0,0)').
     * @returns {{r: number, g: number, b: number}}
     */
    const parseColor = (colorStr) => {
        const tempCanvas = document.createElement('canvas');
        tempCanvas.width = tempCanvas.height = 1;
        const tempCtx = tempCanvas.getContext('2d');
        tempCtx.fillStyle = colorStr;
        tempCtx.fillRect(0, 0, 1, 1);
        const [r, g, b] = tempCtx.getImageData(0, 0, 1, 1).data;
        return { r, g, b };
    };

    const edgeRgb = parseColor(edgeColor);

    // Ensure quantization levels are valid to avoid division by zero.
    if (quantizationLevels < 2) {
        quantizationLevels = 2;
    }
    const step = 255 / (quantizationLevels - 1);

    const originalImageData = ctx.getImageData(0, 0, width, height);
    const originalData = originalImageData.data;
    const finalImageData = ctx.createImageData(width, height);
    const finalData = finalImageData.data;

    // 1. Create a grayscale representation of the image for edge detection.
    const grayData = new Uint8ClampedArray(width * height);
    for (let i = 0; i < originalData.length; i += 4) {
        const r = originalData[i];
        const g = originalData[i + 1];
        const b = originalData[i + 2];
        // Using luminance formula for better-perceived brightness.
        const gray = 0.299 * r + 0.587 * g + 0.114 * b;
        grayData[i / 4] = gray;
    }

    // Sobel kernels for edge detection
    const kernelX = [
        [-1, 0, 1],
        [-2, 0, 2],
        [-1, 0, 1]
    ];
    const kernelY = [
        [-1, -2, -1],
        [0, 0, 0],
        [1, 2, 1]
    ];

    // 2. Iterate through each pixel, apply Sobel filter for edges,
    //    and quantize colors for non-edge pixels.
    for (let y = 0; y < height; y++) {
        for (let x = 0; x < width; x++) {
            const i = (y * width + x);
            const dataIndex = i * 4;
            let isEdge = false;

            // Skip border pixels for Sobel operator
            if (y > 0 && y < height - 1 && x > 0 && x < width - 1) {
                let gx = 0;
                let gy = 0;

                for (let ky = -1; ky <= 1; ky++) {
                    for (let kx = -1; kx <= 1; kx++) {
                        const neighborY = y + ky;
                        const neighborX = x + kx;
                        const neighborIndex = neighborY * width + neighborX;
                        const grayValue = grayData[neighborIndex];
                        
                        gx += grayValue * kernelX[ky + 1][kx + 1];
                        gy += grayValue * kernelY[ky + 1][kx + 1];
                    }
                }

                const magnitude = Math.sqrt(gx * gx + gy * gy);
                if (magnitude > edgeThreshold) {
                    isEdge = true;
                }
            }

            if (isEdge) {
                finalData[dataIndex] = edgeRgb.r;
                finalData[dataIndex + 1] = edgeRgb.g;
                finalData[dataIndex + 2] = edgeRgb.b;
            } else {
                // Not an edge, so apply color quantization (posterization)
                const r = originalData[dataIndex];
                const g = originalData[dataIndex + 1];
                const b = originalData[dataIndex + 2];

                finalData[dataIndex] = Math.round(r / step) * step;
                finalData[dataIndex + 1] = Math.round(g / step) * step;
                finalData[dataIndex + 2] = Math.round(b / step) * step;
            }
            finalData[dataIndex + 3] = 255; // Set alpha to fully opaque
        }
    }

    // 3. Put the processed image data back onto the canvas
    ctx.putImageData(finalImageData, 0, 0);

    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 Japanese Anime Cel Shading Renderer for Military Vehicles is a specialized online tool designed to transform images of military vehicles into a stylized cel-shaded effect reminiscent of Japanese anime. This tool enhances the visual aesthetics by applying edge detection and color quantization techniques, resulting in a bold and graphic appearance. Ideal for artists, designers, and hobbyists, the tool can be used for producing concept art, illustrations, game assets, or simply for creative explorations, enabling users to experiment with the unique blend of military and anime styles in their visual projects.

Leave a Reply

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

Other Image Tools:

Image Anime Cel Shade Effect Generator

Image Liquid Metallic Chrome Material Top View

Image Generator for Rainbow Six Siege Logo with Rainbow Fill

Image Transparency Adjuster for Clothing

Photo VHS Found Footage Analog Effect Tool

Image Old Fashioned Wanted Poster Creator

Image Toxic Waste Identifier

Image Realism Enhancer

Image Bulk Date and Location Stamp Adder Without Background Color

Image Time Stamp Removal Tool

Image Bulk Date and Text Stamp Adder

Image Bulk Date and Location Stamp Adder

Image Date and Location Stamp Adder

Image Date and Zone Stamping Tool

Image Bulk Date and Location Stamper

Image Bulk Date and Coordinate Stamper

Photo Artificial Metadata Generator

Photo Artificial Pattern Generator for Deepfake Bypass

Image Ultra Realistic Skin Texture Pore Emulation Tool

Image Chaotic Noise and Blur Generator for Deepfake Detection Evasion

Image Deep Effects Modification Tool

Image Portrait to Classic Hollywood Cinematic Still Enhancer

Image Chaotic Deep Modifications Editor

Image Chaotic Interleaving Modifier

Image Random Effects Generator with Low Intensity

Image Random Effects Generator

Image Chaotic Noise and Mosaic Effect Maker

Image Chaotic Noise Generator for Deepfake Detection Evasion

Image 4K Enhancement Tool for Realistic Skin Texture

Image Batch Chroma Key Processor

Image To Cel-Shaded Vector Converter

Image Hair Color Change Tool

Image Grillz and Smile Overlay Tool

Photo Reflection Insight Tool

Image Subject Isolation and Custom Transformation Tool

Image Background Eraser

See All →