public override Image ToUInt8() { ImageUInt8RGB uint8Image = new ImageUInt8RGB(Width, Height); int divider = (ushort.MaxValue + 1) / (byte.MaxValue + 1); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { uint8Image.R[x, y] = (byte)(R[x, y] / divider); uint8Image.G[x, y] = (byte)(G[x, y] / divider); uint8Image.B[x, y] = (byte)(B[x, y] / divider); } } return(uint8Image); }
public override Image ToRGB() { ImageRGB <byte> rgbImage = new ImageUInt8RGB(Width, Height); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { byte c = C[x, y]; byte m = M[x, y]; byte ye = Y[x, y]; byte k = K[x, y]; rgbImage.R[x, y] = (byte)(byte.MaxValue * (1 - ((double)c / byte.MaxValue)) * (1 - (double)k / byte.MaxValue)); rgbImage.G[x, y] = (byte)(byte.MaxValue * (1 - ((double)m / byte.MaxValue)) * (1 - (double)k / byte.MaxValue)); rgbImage.B[x, y] = (byte)(byte.MaxValue * (1 - ((double)ye / byte.MaxValue)) * (1 - (double)k / byte.MaxValue)); } } return(rgbImage); }
public override Image ToRGB() { ImageRGB <byte> rgbImage = new ImageUInt8RGB(Width, Height); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { byte h = H[x, y]; byte s = S[x, y]; byte v = V[x, y]; if (s == 0) { rgbImage.R[x, y] = v; rgbImage.G[x, y] = v; rgbImage.B[x, y] = v; continue; } byte region = (byte)(h / 43); byte remainder = (byte)((h - (region * 43)) * 6); byte p = (byte)((v * (byte.MaxValue - s)) >> 8); byte q = (byte)((v * (byte.MaxValue - ((s * remainder) >> 8))) >> 8); byte t = (byte)((v * (byte.MaxValue - ((s * (byte.MaxValue - remainder)) >> 8))) >> 8); 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); }