We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys,
I'm trying to build a new image, capturing only part that interests me from another, I used this base to begin with: https://processing.org/tutorials/pixels/
I am in doubt as to the image below, the part where it seems "rainbow", would I use the function (hue), or (r, g, b) individually to capture?
And what about the circled part (very badly done, sorry) more in the middle, would have to use the function (brightness), since it is kind of "brightness" in the image?
Thanks any hint, below is the sample code, and the image as template.
Thank you,
PImage source;
PImage destination;
float threshold = 0;
void setup() {
size(400, 300);
source = loadImage("Img01.jpg");
source.resize(400, 300);
destination = createImage(source.width, source.height, RGB);
}
void draw() {
//threshold = 127;
threshold = 70;
source.loadPixels();
destination.loadPixels();
for (int x = 0; x < source.width; x++) {
for (int y = 0; y < source.height; y++ ) {
int loc = x + y*source.width;
if (brightness(source.pixels[loc]) > threshold) {
//if (hue(source.pixels[loc]) > threshold) {
//destination.pixels[loc] = source.pixels[loc]; // White
destination.pixels[loc] = source.pixels[loc];
}
}
}
destination.updatePixels();
image(destination,0,0);
//image(source,0,0);
}
void keyPressed(){
if (key == 'A' || key == 'a')
threshold = threshold + 10;
if (key == 'D' || key == 'd')
threshold = threshold - 10;
println(threshold);
}
Answers
Here is a suggestion: If you want to select certain color, you can use distance:
In your case, I think you will need a mix of brightness and hue (?) If you use HSB, notice you could do something like this:
However, your case is very specific and you should give it a try and see how the algorithm performs. It is different to use HSB to RGB or maybe you could use both.
Kf
Hello kfrajer, thanks for the feedback ...
I'm going to do tests, thanks for the attention,
Thanks!
If this something you want to do once or you are looking to automate it?
Kf
Hello, thanks again ...
This is just an example, but if I can do this, it would be a big step, so I can think of how to automate for other images, I'm actually realizing that it's something very complex ...
As I mentioned, I need to "filter" only certain colors and brightness in the image, and I was thinking how to mount this range of values, and then compare with the pixels of the image, to see if it is in the range, and thus compose a new image.
I still have not figured out how to do this, I thought of putting together a two-dimensional array with the desired ranges of values, and if pixel value is in this range, I use, if not discard ...
The problem I could not "see" yet, how would I compare the range of values ...
This image passes a close idea of what I need to do, if I can compare and separate only part of the "rainbow", it would be a big step.
Thanks for the interest ...
Sorry for English, I'm writing with Google Translate.
Thank you very much
Sorry, I made a mistake, I sent it twice ...
Some ideas:
Based on your sketch:
Hello jeremydouglass,
Thank you very much for the tips, this will certainly help to adapt to my needs.
I'll work on it better, and as soon as I get something new, I'm here ...
Thanks guys, I really appreciate the help I always have here!
Thanks!