last day (14 days later) » 

5:44 AM
1
A: BufferedImage is not changing the colour of all white parts of the image

LasagnaIt seems to me that all of your "white" isn;t exactly white, and that all of your black isn't black (from what you said). What you should be doing is printing out every color in the kanji, to see what's going on. Something such as. public static void illuminateImage(BufferedImage elementIm...

 
I'm a bit confused because the values that you gave are not RGB values, right? I'm confused as to how to find the RGB range of white.
 
I did give you RGB values 255 Red, 255 Green, and 255 Blue is white. 0,0,0 is black. Now, in this case we could really just get each value of red green and blue, and check to see if they are all above 200. so I will edit this above.
 
Sorry, what I mean is that when you print out the RGB values, they come up as one integer, not three. How do I convert that RGB code to the one in which only one value is presented?
For instance, when I get the RGB of black, it comes out as 1. It doesn't print out three integers.
Do you mean on the link to that site you sent me? I can't find on there where it converts from three integers to one.
 
sorry, I got confused as I was looking at my example, and not the link. What you can do is create a new color, and then do color.getRed() blue, green, and then figure it out that way. You can then convert it back to an integer later.
 
OK, now I'm really confused, because I found a converter online. White (255, 255, 255) converts to 1672215, and yet if I print out every pixel of an image before I change its color, non of the numbers come out as that value, which is impossible, because some of the images DO change colour when I say change colour if white.
 
5:44 AM
yup, that is white I believe.
 
I don't understand how that's possible. Shouldn't the majority of pixels be coming out as that value when I run print statements (because the majority of pixels are changing color when I say change color if white)? This doesn't make sense.
 
What are you getting as values?
 
A whole lot of different ones
but absolutely none of the values are 16777215
e.g., 65794, 9737878
 
Can you give some values so I can run a check myself?
ok on3 second
unless you have tested these values yourself?
the first one is really low.
see, the way this works is that you need to look at the bits
Blue is 0-7
so you will do blue value 2^0
 
I don't think I need to do that though
I just need to convert the pixels that are of color white or similar, right?
But if the program is saying that absolutely none of the pixels are white (which is impossible - the majority of them are white or they wouldn't be changing) then I won't be able to change the colors through having a range of white
 
5:49 AM
Well, when you give Color the integer value, you get the RGB value back'
to get the integer value again you will need to add up everything
 
would you know what a range of white would be in integer form?
 
you could convert it'
so the first value is basically black
65794 is 1 1 2 RGB
the next one is 9737878
err wtf
148 148 159
 
how did you convert like that?
 
But if you're not getting a value of 16777215 then there's an issuel
I just did Color c = new Color (integer);
 
how did you convert 65794 to 1 1 2
 
5:53 AM
then did c.getRed(), etc.
 
is there a way of doing it by hand?
 
that will print you RGB values
well, the way to get an integer value is by multi playing the bits
so 2^0 * 2
plus 2^8(256) * 1
 
so 2?
I don't understand where you are getting the zero value and 8 value from
 
Sorry
so essentially each integer is 32-bits right
 
right
 
5:55 AM
each color takes 4 bits
0-7 is 8 bits
err
sorry each takes bits
1 byte.
8 bits
so 0-7 is the last value, or blue
thehn green is bits 8-15
and red is the rest.
 
I'm not sure if I will be able to figure this out. This is too confusing for me
 
so when finding the integer value you are going to do 2^0 2^8 and 2^16 multiplied by the value of r g or b, then you add each of them up
Hmm, sorry.
I might not be explaining it well since I'm, a bit hungry and headache lo.
I'll go grab some food and try to explain it better.
 
OK.
 
it;s just some basic math really
(2^16*Red) + (2^8 *Green) + (Blue)
is the integer value of your RGB
but I feel like this is getting far from your question, even though it's one ofg hte answsers.
First we need to figure out if you're actually getting any white values.
 
I'm not sure if that calculation is right
 
6:01 AM
and if maybe there's something else happening. i.e., Alpha channel, which means White in't that 16771215 nymnber anymore.
 
I just tried doing the values for white (255,255,255) and the answer was waaaay too big
alpha channel?
 
transparency is alpha
also 256 * 256 * 255 = 16711680
if you add that to 65535 * 255 which is green + 255 which is blue
you should get that number
but first we need to see when it goes white.
you should do the system print when you do the if statement.
ifg (color = white) print color;
that way we can see if it's actually white or what's going on.
 
oh right i didn't think of printing out when == color.white
one sec
it says the white integer is -1
i don't get it
i can chat again later, as I have to go now. I will leave this chat thing open and post a message when I next come online. Thanks for your help.
 
ok
just fihnished food
I believe a negative number indicates alpha
let me do a quick check
it could also be an error, but I'm pretty sure I've encountered negatives before.. .hmmm
yup
-1 is white with an alpha channel
so to find that you would do Color c = new Color (integer, true);
that will give you the alpha value
whe checking c.getAlpha();
It seems that when a alpha value is involved, everything is backwards.
Alpha of 255
is -16777216 instead of 16777215
so as you multiply down the loop you get to -1.
Sorry this is so confusing, it took me awhile to understand this all when I did it.
You are going to want t ocompare the RGB values separetly instead of together as an integer, seeing as getting a range with an int will be a hard task.
sorry I spoke about that in depth, but it is stil part of this
getting some food worked out for me haha..
So yeah I would check between 200-255 or some other value that your kanji add up to.
So if you wanted to check all of the colors and see which one is the last value that is kind of white, then you can use that as well.
Not sure if all the kanji are the same though.
It would be so much easier for sure if you converted all of the colors corerectly
Good luck
 
6:37 AM
Do you mean check between 200-255 for red, green and blue?
 
yes
h/o sec
 
I will have to get the RGB and then convert to Color, and then do color1.getRed() right?
This will probably take me a while to figure out how to do this.
 
it's not to hard my good man
what would be best is converting the colors propwrly'
do you have photoshop?
you would do Color c = new Color (integer,true);
then you will say if c.getRed() > 200 &&
c.getGreen() > 200... etc
but 200 might not be the value you want.
you did have a value of 148 150 150 before.
which is odd because you have transparency...
let me check something.
hmmmm.....
According to this, the first value 65794
is 0 | 1 | 1 | 2
so almost invisible...?
| 1 | 1 | 2 | 0
so basically invisible...
weird.
the second value is | 148 | 150 | 150 | 0
but it;s weird you also have alpha values.
these are images from the net?
 
Yes
 
yeah, weird stuff ahha
 
6:50 AM
I will get the link for the image. One second
 
neverfear.
that's okay. its not really needed for our case.
was just curious.
 
OK
Yaaay, it worked
Thank you so much
Here, I will show you my code
public static void illuminateImage(BufferedImage elementImage, Color elementColor){
for (int j = 0; j < elementImage.getWidth(); j++){
for (int k = 0; k < elementImage.getHeight(); k++){
Color color = new Color(elementImage.getRGB(j, k), true);
if(color.getRed() > 200 && color.getBlue() > 200 && color.getGreen() > 200){
elementImage.setRGB(j,k, elementColor.getRGB());

}

}
}
}
Thanks heaps man.
 
oh yeah? great!
so everything is selected now?
 
Yes. I don't know why I was bothering to work out the integer value of everything. It wasn't necessary
All of the "white" pixels are turning the different color
 
yeah, I was just giving it as an alternative, but I was pretty hungry so I was confusing myself haha
gotta get food for brain worl[.
 
6:57 AM
yeah
 
The integers would not work in this case at all sadly.
You also can convert all of the colors to white if you wish as well, to make it easier for the future, but if this works, it owrks.
 
Yes but the problem with converting all the pixels to white is that it would convert the black ones too
And I would have the same problem with not being able to identify the integer value of the "black" pixels
 
well, I mena convert the ones above the threshhold
you will have to look at a color chart and see where thew white ones arel
you did have a 148 150 150 value
which is more than halfway up the chat towards white.
but mayb that is white.
i don'T think so tho
will have to checl :P
Also, just to let yo u know getRGB and SetRGB is the slow way to d othis :)
the fast way is manipulating the integer array itself.
but if this works, then I wouldn't bother.
in my case I have to check hundreds if not more of photos and have to change all of the pixels of one color to another.
 
OK, I didn't know there was another way of doing it
 
it;s the secret way :)
must unlock level 12 and find the hidden dungeon.
But it all depends if you're having speed issues or not.
usually they say there's no point in redoing the code if it works well.
in my case I'm not sure how much of a difference it will make, but still....
was fun to learn :)
 
7:25 AM
I don't think I am having any runtime delays using this method anyway
yes
 
7:46 AM
thanks again. i have to go now
 
8:00 AM
/great
good luck
i m8ighjt leave this chat open if you need ,e
 

last day (14 days later) »