/// <summary> /// Метод, предназначенный для квантования изображения /// </summary> /// <param name="bitmap"></param> /// <param name="n"></param> /// <returns></returns> public static Bitmap Quantization(Bitmap bitmap, int n) { BufferedImage img = new BufferedImage(bitmap); Color color; for (int i = 0; i < img.getWidth(); i++) { for (int j = 0; j < img.getHeight(); j++) { color = new Color(img.getRGB(i, j)); if (color.getRed() % n != 0 && color.getRed() != 0) { img.setRGB(i, j, new Color(newColor(color.getRed(), n), color.getGreen(), color.getBlue()).getRGB()); } if (color.getBlue() % n != 0 && color.getBlue() != 0) { img.setRGB(i, j, new Color(color.getRed(), color.getGreen(), newColor(color.getBlue(), n)).getRGB()); } if (color.getGreen() % n != 0 && color.getGreen() != 0) { img.setRGB(i, j, new Color(color.getRed(), newColor(color.getGreen(), n), color.getBlue()).getRGB()); } } } return(img.getBitmap()); }
static private Color FromNativeColor( awt.Color awtColor, string name, KnownColor knownColor) { return(Color.FromArgbSystem(awtColor.getAlpha(), awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue(), name, knownColor)); }
/** * Creates a hexadecimal string representation of a {@link Color} in the form 0xaabbggrr. * * @param color Color to encode. * * @return String encoding of the specified color. * * @throws ArgumentException If the specified color is null. * @see #decodeColorABGR(String) * @see #encodeColorRGBA(java.awt.Color) */ public static String encodeColorABGR(java.awt.Color color) { if (color == null) { String message = Logging.getMessage("nullValue.ColorIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } // Encode the red, green, blue, and alpha components int rgba = (color.getRed() & 0xFF) | (color.getGreen() & 0xFF) << 8 | (color.getBlue() & 0xFF) << 16 | (color.getAlpha() & 0xFF) << 24; return(String.Format("%#08X", rgba)); }
/// <summary> /// Линейное контратирование изображения /// </summary> /// <param name="bitmap"></param> /// <returns></returns> public static Bitmap SetsContrans(Bitmap bitmap) { BufferedImage img = new BufferedImage(bitmap); Color color; for (int i = 0; i < img.getWidth(); i++) { for (int j = 0; j < img.getHeight(); j++) { color = new Color(img.getRGB(i, j)); int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); if (r > 94) { r = 94; } else if (r < 28) { r = 28; } if (g > 94) { g = 94; } else if (g < 28) { g = 28; } if (b > 94) { b = 94; } else if (b < 28) { b = 28; } img.setRGB(i, j, new Color(r, g, b).getRGB()); } } return(img.getBitmap()); }
/// <summary> /// Метод, для пороговой обработки изображения /// </summary> /// <param name="bitmap">позволяет считывать и сохранять файлы различных графических форматов</param> /// <param name="rRed"></param> /// <param name="rGreen"></param> /// <param name="rBlue"></param> /// <returns></returns> public static Bitmap ThresholdProcessing(Bitmap bitmap, int rRed, int rGreen, int rBlue) { BufferedImage img = new BufferedImage(bitmap); for (int i = 0; i < img.getWidth(); i++) { for (int j = 0; j < img.getHeight(); j++) { Color color = new Color(img.getRGB(i, j)); int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); red = red <= rRed ? red : 0; green = green <= rGreen ? green : 0; blue = blue <= rBlue ? blue : 0; img.setRGB(i, j, new Color(red, green, blue).getRGB()); } } return(img.getBitmap()); }
public WPIColor(Color color) { WPIColor wpiColor = this; double num1 = (double) color.getRed(); double num2 = (double) color.getGreen(); double num3 = (double) color.getBlue(); throw new NoClassDefFoundError("com.googlecode.javacv.cpp.opencv_core"); }