#whats a good library for shifting image hue and saturation kind of like photoshop can
18 messages · Page 1 of 1 (latest)
Hey, @median nimbus!
Please remember to /close this post once your question has been answered!
theoretically, you could do it with Swing's BufferedImage
you could get the HSV of every pixel
and increase it as you like
yea ive got these two methods
public static BufferedImage tint(BufferedImage image, Color color) {
for (int x = 0; x < image.getWidth(); x++) {
for (int y = 0; y < image.getHeight(); y++) {
Color pixelColor = new Color(image.getRGB(x, y), true);
int r = (pixelColor.getRed() + color.getRed()) / 2;
int g = (pixelColor.getGreen() + color.getGreen()) / 2;
int b = (pixelColor.getBlue() + color.getBlue()) / 2;
int a = pixelColor.getAlpha();
int rgba = (a << 24) | (r << 16) | (g << 8) | b;
image.setRGB(x, y, rgba);
}
}
return image;
}
public static BufferedImage hueShift(BufferedImage image, int iHUE) {
float hue = iHUE / 360.0f;
int WIDTH = image.getWidth();
int HEIGHT = image.getHeight();
BufferedImage processed = new BufferedImage(WIDTH, HEIGHT, image.getType());
for (int Y = 0; Y < HEIGHT; Y++) {
for (int X = 0; X < WIDTH; X++) {
int RGB = image.getRGB(X, Y);
int R = (RGB >> 16) & 0xff;
int G = (RGB >> 8) & 0xff;
int B = (RGB) & 0xff;
float HSV[] = new float[3];
Color.RGBtoHSB(R, G, B, HSV);
processed.setRGB(X, Y, Color.getHSBColor(hue, HSV[1], HSV[2]).getRGB());
}
}
return processed;
}
hueShift is the better one
so?
idk just wondering if there are any libs that would do it better than mine
or offer other methods to do unique things
maybe you can do something with ffmpeg (there might be a Java port) but I think that's more for video stuff
yea im dealing with pngs only
im sure ffmpeg could just be repurposed in some ways
I found this really old thing: https://imagej.nih.gov/ij/
https://sksamuel.github.io/scrimage/ also this
Java, Scala, Kotlin image manipulation library.