To convert an RGB image to HSV, transform every pixel from its red, green, and blue channels into hue, saturation, and value, then export the components on the scale required by the destination; a single-color converter can validate one pixel at a time, not process an entire image file.

That distinction prevents a common mistake: treating a three-field color tool as an image uploader. The RGB to HSV Converter accepts one ordinary 8-bit RGB triplet, calculates its HSV coordinates, and runs entirely in your browser without saving a color history. For a complete image, use an image-processing library for the pixel-by-pixel work and use the converter to check representative samples.

convert rgb to hsv image
Convert RGB to HSV Image: Pixels, Scales, and Workflow

How RGB and HSV represent the same color

RGB records the amount of red, green, and blue in each pixel. HSV reorganizes those same channel amounts around a hue position, saturation, and value. Hue identifies a location on the color wheel, saturation describes the color's distance from gray relative to its value, and value follows the strongest normalized RGB channel.

For the conversion, each 8-bit channel is divided by 255. If Cmax is the largest normalized channel, Cmin is the smallest, and Δ is their difference, value equals Cmax. Saturation equals Δ divided by Cmax, except that black has zero saturation. Hue is calculated from the maximal channel and the relative positions of the other two channels; negative results are wrapped into the nonnegative degree range.

For one worked example, consider RGB (30, 144, 255). The normalized channels are r = 0.117647, g = 0.564706, and b = 1, giving Cmax = 1, Cmin = 0.117647, and Δ = 0.882353. Because blue is maximal, H = 60 × [4 + (r − g) ÷ Δ] = 209.60°. Saturation is (Δ ÷ Cmax) × 100 = 88.24%, and value is Cmax × 100 = 100.00%. The converter therefore displays hue 209.60 degrees, saturation 88.24%, and value 100.00%.

Calculations retain full floating-point precision, while the interface formats hue, saturation, and value to two decimal places. The implementation is independently checked against R's rgb2hsv documentation for typical 0–255 sRGB input. This is a coordinate transformation, not an ICC-profile or wide-gamut conversion.

Convert an RGB image pixel by pixel in Python

An HSV image is a three-channel data representation, so every source pixel must be transformed. To view that data on an RGB display, the HSV channels are commonly converted back to RGB. The following Pillow and Python workflow stores the actual HSV values in JSON and creates a round-trip RGB preview for visual checking.

  1. Set up the Python environment. Install Pillow, then import Image from PIL, rgb_to_hsv and hsv_to_rgb from colorsys, and json. Python's standard colorsys module uses normalized channels, so each RGB value must be divided by 255 before conversion.
  2. Load the source image as RGB. Use image = Image.open("input.png").convert("RGB"). Pillow then exposes ordinary 8-bit red, green, and blue channel values. If the source contains transparency, composite it against a deliberately chosen background first because HSV does not represent alpha.
  3. Convert each pixel. Iterate over image.getdata() and call rgb_to_hsv(r / 255, g / 255, b / 255). The returned hue, saturation, and value are all fractions from zero to one. Keep those normalized values for calculations, or convert them to the display convention when exporting.
  4. Store the HSV data and a preview. For each converted tuple, append (h * 360, s * 100, v * 100) to rows for degrees and percentages. Append hsv_to_rgb(h, s, v) to preview_rows for the round-trip preview.
  5. Export the files. Write the degree-and-percentage rows with json.dump(rows, f). Create the preview with Image.new("RGB", image.size), apply preview.putdata([tuple(round(c * 255) for c in pixel) for pixel in preview_rows]), and save it as hsv-preview.png. The JSON preserves raster pixel order, although a large image can produce a large data file.

This workflow uses the article's degrees-and-percentages convention consistently. Pipelines built on OpenCV use a different compact HSV scale, so consult the OpenCV HSV scale guide before transferring values into that application.

Convert a sampled RGB color in the browser

Use the single-color workflow when checking a sampled pixel, documenting a palette entry, or confirming a value produced by another script.

  1. Obtain the source channels. Record the pixel's red, green, and blue values as whole numbers from 0 through 255. Do not substitute values from a higher-bit-depth pipeline without first deciding on the intended 8-bit representation.
  2. Enter and convert. Place the three whole-number channels in their corresponding fields, then select Convert to HSV. The converter shows hue in degrees and saturation and value as percentages.
  3. Review the complete result. Read the normalized HSV notation, source HEX code, and visual swatch. The original RGB inputs remain visible, so you can change one channel and compare how the HSV components respond.
  4. Confirm the destination convention. Decide whether the receiving application expects degrees and percentages, fractions, or a compact integer scale before transferring the result.

Match the destination's HSV scale

A correct mathematical conversion can still produce a wrong result when the destination expects a different numeric range. The converter deliberately presents hue in degrees and saturation and value as percentages, so those values should not be transferred unchanged unless the destination documents the same convention.

Destination convention Expected representation Transfer action
Degrees and percentages Hue in degrees; saturation and value in percent Use the displayed values directly when the application documents this format.
Zero-to-one fractions Some or all components represented as fractions Divide hue degrees by 360 and percentage values by 100 only for fields the destination defines as fractions.
Compact integer range Application-specific scaled integers Apply the destination's documented mapping; some software stores hue on a 0–179 or 0–255 integer scale, so do not cast percentages blindly.
HSL rather than HSV Hue, saturation, and lightness Use an HSL-specific converter because HSV value and HSL lightness are different quantities.

The converter's ranges follow the Android Color.colorToHSV reference: hue is at least zero and below 360, while saturation and value are zero-to-one internally before being displayed as percentages. Another application may round, scale, or interpret the values differently, so its documentation remains the deciding source.

Handle achromatic colors and strict input limits

Several special cases need explicit treatment rather than silent correction:

  • Equal red, green, and blue channels: The color is achromatic, its difference and saturation are zero, and hue has no visual meaning. The converter reports the conventional placeholder hue of 0 degrees.
  • Black: When the maximum normalized channel is zero, saturation is zero and value is zero. Hue again has no meaningful visual direction and is represented by the same placeholder.
  • Nonstandard inputs: Only finite whole-number channels from 0 through 255 are accepted. Decimal values, empty fields, negative numbers, and values above 255 produce an explicit error instead of being silently rounded or clamped.
  • Different brightness models: HSV value is the maximum normalized RGB channel. It is not HSL lightness, which uses the average of the maximum and minimum channels, and it is not measured perceptual luminance.
  • Transparency and embedded profiles: Alpha is outside the scope of RGB-to-HSV conversion, and the converter does not read embedded image profiles or convert between wide-gamut color spaces.

After exporting an image, compare several representative pixels with the source, including a dominant-color pixel, a neutral pixel, and a dark pixel. If the values do not agree, check channel order, normalization, hue scaling, rounding, and alpha handling before changing the conversion formula.

For a deeper look, see How Do I Make Sure I Convert CMYK to RGB Correctly?.