Isolate Color Channel
Extract and isolate a specific color channel (Red, Green, or Blue) from an image.
/api/image/isolate-channel
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Yes | The image file to process. Supported formats: JPEG, PNG, WebP, BMP, TIFF. |
channel | String | Yes | The color channel to isolate. Options: R (Red), G (Green), B (Blue). |
Response
Returns the image with only the specified color channel preserved, in the same format as the input file.
Example Request
curl -X POST "https://oyyi.xyz/api/image/isolate-channel" -H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@image.jpg" \
-F "channel=R" \
--output red_channel.jpg
Example with Python
import requests
url = "https://oyyi.xyz/api/image/isolate-channel"
files = {
'file': open('image.jpg', 'rb')
}
data = {
'channel': 'R'
}
response = requests.post(url, files=files, data=data)
# Save the processed image
with open('red_channel.jpg', 'wb') as f:
f.write(response.content)
Example with JavaScript
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('channel', 'R');
fetch('https://oyyi.xyz/api/image/isolate-channel', {
method: 'POST',
body: formData
})
.then(response => response.blob())
.then(blob => {
// Create a URL for the blob
const url = URL.createObjectURL(blob);
// Create a link to download the image
const a = document.createElement('a');
a.href = url;
a.download = 'red_channel.jpg';
a.click();
// Clean up by revoking the URL
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
Color Channels
Red Channel (R)
Isolates the red component of each pixel. Useful for analyzing red-dominant features or creating artistic effects.
Green Channel (G)
Isolates the green component of each pixel. Often contains the most detail in natural images due to the sensitivity of the human eye to green.
Blue Channel (B)
Isolates the blue component of each pixel. Useful for analyzing blue-dominant features like skies or water.
How It Works
The channel isolation process works by preserving the values of the specified channel while setting the other channels to zero:
- Red Channel (R): Keeps the red values, sets green and blue to zero.
- Green Channel (G): Keeps the green values, sets red and blue to zero.
- Blue Channel (B): Keeps the blue values, sets red and green to zero.
If the grayscale
parameter is set to true
, the isolated channel values are copied to all three channels, creating a grayscale image based on just that channel's information.
Error Responses
Status Code | Description |
---|---|
400 | Bad request. Missing required parameters, invalid channel value, or invalid file format. |
413 | Payload too large. The file size exceeds the maximum allowed limit. |
500 | Internal server error. Something went wrong on the server. |
Notes
- When a color channel is isolated, the other channels are set to zero.
- If
grayscale
is set totrue
, the isolated channel will be converted to grayscale, which can be useful for analysis. - The maximum file size allowed is 10MB.
- This operation preserves the alpha channel (transparency) if present in the original image.
- Different channels often reveal different aspects of an image. For example, the blue channel often shows more noise in digital photographs.
Use Cases
- Analyzing the contribution of each color channel to an image
- Creating artistic effects by manipulating individual channels
- Enhancing specific features that are more prominent in certain channels
- Preparing images for scientific or medical analysis
- Creating channel-specific masks for advanced image editing
- Identifying color casts or imbalances in photographs