You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = originalImg.width;
canvas.height = originalImg.height;
// Draw the original image onto the canvas
ctx.drawImage(originalImg, 0, 0);
// Get the image data from the canvas
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data; // This is a Uint8ClampedArray: [R, G, B, A, R, G, B, A, ...]
// Constants defining the Gold-N-Blue polarizer effect.
// These values are chosen empirically to approximate the visual characteristics
// of such a filter.
// For Blue Enhancement:
// Factor to boost the blue channel in predominantly blue areas (e.g., sky, water).
const blueIntensity = 1.3;
// Factor to reduce the red channel in blue areas, increasing blue purity.
const bluePurityR = 0.8;
// Factor to reduce the green channel in blue areas, increasing blue purity.
const bluePurityG = 0.9;
// Minimum blue value threshold for a pixel to be considered for strong blue enhancement.
// This helps target significant blues and avoids over-processing very dark or faint blues.
const blueDetectionThreshold = 50;
// For Gold/Warming Effect (applied to non-blue dominant areas):
// Factor to boost the red channel, creating a golden/warm hue.
const goldIntensityR = 1.3;
// Factor to boost the green channel. Kept slightly lower than red's boost
// to achieve a warmer gold rather than a pure yellow or greenish-yellow.
const goldIntensityG = 1.1;
// Factor to reduce the blue channel, enhancing the warmth of the color.
const goldPurityB = 0.7;
// Iterate over each pixel (each pixel consists of 4 values: R, G, B, A)
for (let i = 0; i < data.length; i += 4) {
let r = data[i]; // Red channel
let g = data[i+1]; // Green channel
let b = data[i+2]; // Blue channel
// Alpha channel (data[i+3]) is preserved.
let outR, outG, outB;
// Determine if the pixel is predominantly blue.
// A pixel is considered "blue dominant" if its blue channel value is greater
// than both red and green, AND its blue value is above a certain threshold.
if (b > r && b > g && b > blueDetectionThreshold) {
// Apply Blue Enhancement
outB = b * blueIntensity;
outR = r * bluePurityR;
outG = g * bluePurityG;
} else {
// Apply Gold/Warming Effect to non-blue dominant areas
// This affects greens, yellows, reds, browns, grays, etc.
outR = r * goldIntensityR;
outG = g * goldIntensityG;
outB = b * goldPurityB;
}
// Clamp the resulting R, G, B values to the valid 0-255 range and round them.
data[i] = Math.max(0, Math.min(255, Math.round(outR)));
data[i+1] = Math.max(0, Math.min(255, Math.round(outG)));
data[i+2] = Math.max(0, Math.min(255, Math.round(outB)));
}
// Put the modified image data back onto the canvas
ctx.putImageData(imageData, 0, 0);
// Return the canvas element
return canvas;
}
Free Image Tool Creator
Can't find the image tool you're looking for? Create one based on your own needs now!
The Image Singh-Ray Gold-N-Blue Polarizer Effect Tool allows users to enhance their images by applying a polarizing filter effect that emphasizes blue tones in predominantly blue areas while warming up other colors to golden hues. This tool is ideal for photographers and hobbyists looking to improve landscape photos, particularly those featuring water or sky, by enhancing the blues and adding warmth to other elements in the scene. The tool processes images in real-time and can help achieve a more vibrant and artistically pleasing appearance.