Anyone who reads that is probably wondering what is ';dr'; or ';using dr'; and so am i!
For grayscale conversion, i.e black=0, white=255 and all values in between represent a shade of grey, you can do an average:
gray_val = ( pixelObj.getRed() + pixelObj.getGreen() + pixelObj.getBlue() ) / 3;
Another way is to use a weighted average:
gray_val = 0.3*pixelObj.getRed() + 0.6*pixelObj.getGreen() + 0.1*pixelObj.getBlue();
Once you get that value assign it to your pixel:
pixelObj.setGreen(gray_val);
pixelObj.setRed(gray_val);
pixelObj.setBlue(gray_val);
PS. I am assuming that pixelObj is an individual pixel element, if not, you'll have to find out how to access it and apply the above method.How to change pictures to grayscale, sepia, and negate in dr. java programming?
After spending hours researching this, I finally figured it out. I wrote a function that produces amazing sepia images. I posted the code on Sun's website:
http://forums.sun.com/thread.jspa?threadID=5394659
Report Abuse
No comments:
Post a Comment