You need to strip off the bits that aren't part of the component you're getting, especially if there's any sign extension going on in the shifts.
You need to strip off the bits that aren't part of the component you're getting, especially if there's any sign extension going on in the shifts. Int R = (qi >> 16) & 0xff ; //bitwise shifting int G = (qi >> 8) & 0xff ; int B = qi & 0xff.
What you made looks allright to me.. I once did this, in java, in much the same way. Getting the average of the 0-255 color values of RGB, to get grayscale, and it looks alot like yours. Public int getGray(int row, int col) throws Exception { checkInImage(row,col); int rgb = this.
GetRGB(row,col); return (int) (rgb0+rgb1+rgb2)/3; }.
There is no "correct" algorithm as per dfanning.com/ip_tips/color2gray.html They use Y = 0.3*R + 0.59*G + 0.11*B.
Those constants are the simplified versions of the ones chosen for NTSC color television: en.wikipedia. Org/wiki/YUV. I've never seen any evidence that they map well to human perception, but it's probably better than a straight average.
– Mark Ransom Oct 28 '10 at 18:36.
You can certainly modify each pixel in Java, but that's very inefficient. If you have the option, I would use a ColorMatrix. See the Android documentation for details: developer.android.com/resources/samples/... You could set the matrix' saturation to 0 to make it grayscale.
IF you really want to do it in Java, you can do it the way you did it, but you'll need to mask out each element first, i.e. Apply & 0xff to it.
Thank you very much for your answer. I am suffering from lack of setpixel function indeed , and that was the my next question. – Tony Oct 28 '10 at 18:48.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.