-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Study the effect of image size vs alpha #9
Comments
I've included the images I used so that you can run it yourself and compare results. |
To achieve this, you can modify the algorithm in the Here is an example implementation of the modified algorithm in Java: import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
public class ColorTable {
public static void main(String[] args) {
// Read the file path of the input image
String filePath = args[0];
// Load the image into a BufferedImage object
BufferedImage image = null;
try {
image = ImageIO.read(new File(filePath));
} catch (IOException e) {
e.printStackTrace();
}
// Create a list to store the colors in order of layering
List<Color> colorList = new ArrayList<>();
// Loop through each pixel in the image
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
// Get the color of the current pixel
Color color = new Color(image.getRGB(x, y));
// If the color is not already in the list, add it to the beginning
if (!colorList.contains(color)) {
colorList.add(0, color);
}
}
}
// Loop through the color list and print each color with its count
for (Color color : colorList) {
int count = 0;
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
if (color.equals(new Color(image.getRGB(x, y)))) {
count++;
}
}
}
System.out.println(color + ": " + count);
}
}
} |
Hello Professor, I hope this email finds you well. As part of a project I'm working on, I'm facing a technical challenge and I would appreciate your help. I need my program to read all the pixels of an image and give me the points of the numbers from 1 to 8,000 passes, according to the colors found, which can come out in quantities of 20, 30, 49, and 10 of each color. I have already started working on the code, but I'm having some difficulties implementing this functionality. As an experienced professor, I'm sure you can help me better understand how I can solve this problem. I would like to know if you would be available for a technical consultation, where I could present my current code and discuss possible solutions to incorporate this functionality. Please let me know your availability and the best way to contact you so we can schedule a meeting. Thank you in advance for your attention and expertise. Best regards, |
1 similar comment
Hello Professor, I hope this email finds you well. As part of a project I'm working on, I'm facing a technical challenge and I would appreciate your help. I need my program to read all the pixels of an image and give me the points of the numbers from 1 to 8,000 passes, according to the colors found, which can come out in quantities of 20, 30, 49, and 10 of each color. I have already started working on the code, but I'm having some difficulties implementing this functionality. As an experienced professor, I'm sure you can help me better understand how I can solve this problem. I would like to know if you would be available for a technical consultation, where I could present my current code and discuss possible solutions to incorporate this functionality. Please let me know your availability and the best way to contact you so we can schedule a meeting. Thank you in advance for your attention and expertise. Best regards, |
desenhar linhas com as cores presentes na imagem e salvar as cores em pastas separadas com seus respectivos números sequenciais em formato de rgb (ex: 255_0_0 para vermelho). Além disso, você deseja que as cores sejam nomeadas com o nome da cor correspondente (ex: cor laranja) e que a imagem e as cores tenham o número de cada prego, de 1 até 10 mil. PImage img; // Imagem de entrada
HashMap<Integer, Integer> colors; // Mapa de cores presentes na imagem
int colorIndex = 1; // Índice da cor atual
void setup() {
size(500, 500);
img = loadImage("imagem.jpg"); // Carrega a imagem de entrada
colors = getColors(img); // Obtém as cores presentes na imagem
drawLines(); // Desenha as linhas com as cores presentes na imagem
saveColors(colors); // Salva as cores em pastas separadas com números sequenciais em formato de rgb
}
HashMap<Integer, Integer> getColors(PImage img) {
HashMap<Integer, Integer> colors = new HashMap<Integer, Integer>();
img.loadPixels();
for (int i = 0; i < img.pixels.length; i++) {
int c = img.pixels[i];
if (!colors.containsKey(c)) {
colors.put(c, 1);
} else {
int count = colors.get(c);
colors.put(c, count + 1);
}
}
return colors;
}
void drawLines() {
int lineHeight = height / colors.size();
int i = 0;
for (Map.Entry<Integer, Integer> entry : colors.entrySet()) {
int c = entry.getKey();
int count = entry.getValue();
stroke(c);
line(0, i * lineHeight, width, i * lineHeight);
i++;
}
}
void saveColors(HashMap<Integer, Integer> colors) {
File folder = new File(sketchPath("cores"));
folder.mkdir();
int i = 1;
for (Map.Entry<Integer, Integer> entry : colors.entrySet()) {
int c = entry.getKey();
int count = entry.getValue();
String colorName = getColorName(c);
String |
![received_513714242634479.jpeg](https://user-i![received_516766082360488.jpeg](https://user-i![received_529830481276900.jpeg](https://user-images.githubusercontent.com/127507849/229398795-936ea605-b5ab-4b72-b78f-2f1f4fe3ed70.jpeg) -cb44e7c0-a0df-4e05-bff0-2c7e416a0e09.jpeg) -a364dfc8-7cee-4296-9b2a-b13f9f7e4f10.jpeg) |
I need my program to read all the pixels of an image and give me the points of the numbers from 1 to 8,000 passes, according to the colors found, which can come out in quantities of 20, 30, 49, and 10 of each color. I have already started working on the code, but I'm having some difficulties implementing this functionality.What?Sent from my iPhoneOn Apr 2, 2023, at 7:15 PM, Atanaelslompo ***@***.***> wrote:
Hello Professor,
I hope this email finds you well. As part of a project I'm working on, I'm facing a technical challenge and I would appreciate your help.
I need my program to read all the pixels of an image and give me the points of the numbers from 1 to 8,000 passes, according to the colors found, which can come out in quantities of 20, 30, 49, and 10 of each color. I have already started working on the code, but I'm having some difficulties implementing this functionality.
As an experienced professor, I'm sure you can help me better understand how I can solve this problem. I would like to know if you would be available for a technical consultation, where I could present my current code and discuss possible solutions to incorporate this functionality.
Please let me know your availability and the best way to contact you so we can schedule a meeting.
Thank you in advance for your attention and expertise.
Best regards,
[Slompo ]
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
The reason I use low quality images is that when I wrote the original sketch I used the screen pixels as part of my comparison tests. I made a version that locks the image on screen to 500x500 but lets you put in any size source image. larger source means more samples and larger output for higher quality sampling.
david 1300x1300 with alpha=64
david 1300x1300 with alpha=128
Try your own variations and share your results. Maybe we can find a sweet spot?
The text was updated successfully, but these errors were encountered: