public override Image ToDouble() { ImageDoubleRGB doubleImage = new ImageDoubleRGB(Width, Height); double divider = ushort.MaxValue + 1; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { doubleImage.R[x, y] = R[x, y] / divider; doubleImage.G[x, y] = G[x, y] / divider; doubleImage.B[x, y] = B[x, y] / divider; } } return(doubleImage); }
public override Image ToRGB() { ImageRGB <double> rgbImage = new ImageDoubleRGB(Width, Height); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { double c = C[x, y]; double m = M[x, y]; double ye = Y[x, y]; double k = K[x, y]; rgbImage.R[x, y] = (1 - c) * (1 - k); rgbImage.G[x, y] = (1 - m) * (1 - k); rgbImage.B[x, y] = (1 - ye) * (1 - k); } } return(rgbImage); }
public override Image ToRGB() { ImageRGB <double> rgbImage = new ImageDoubleRGB(Width, Height); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { double h = H[x, y]; double s = S[x, y]; double v = V[x, y]; if (s == 0) { rgbImage.R[x, y] = v; rgbImage.G[x, y] = v; rgbImage.B[x, y] = v; continue; } if (h == 1) { h = 0; } else { h *= 6; } int region = (int)h; double remainder = h - region; double p = v * (1 - s); double q = v * (1 - (s * remainder)); double t = v * (1 - (s * (1 - remainder))); switch (region) { case 0: rgbImage.R[x, y] = v; rgbImage.G[x, y] = t; rgbImage.B[x, y] = p; break; case 1: rgbImage.R[x, y] = q; rgbImage.G[x, y] = v; rgbImage.B[x, y] = p; break; case 2: rgbImage.R[x, y] = p; rgbImage.G[x, y] = v; rgbImage.B[x, y] = t; break; case 3: rgbImage.R[x, y] = p; rgbImage.G[x, y] = q; rgbImage.B[x, y] = v; break; case 4: rgbImage.R[x, y] = t; rgbImage.G[x, y] = p; rgbImage.B[x, y] = v; break; default: rgbImage.R[x, y] = v; rgbImage.G[x, y] = p; rgbImage.B[x, y] = q; break; } } } return(rgbImage); }