hi
I understand that you are trying to do a simple image processing functionality-grayscaling of RGB images.
Here is a similar code:
In your code,
you should have included the Mediatracker while loading the image.Remember image loading takes some time.So you must ensure that the execution of the program waits until the image is fully loaded. m.waitForID9..) ensures this. Otherwise you get NullPointerException for the image.
Secondly in your method printFrame(int[] pixels) you took the width and height of the image to be created from:
Dimension d=getSize();
but assuming that you are writing the code inside a class extending FRame/Applet/Panel etc, getSize() will give the size of that component and this size has nothing to do with the image.What you need is the size of the original image from which you obtained the pixels. So in the imageToIntArray(...) method put the width and height of the image into member variables, so that you can get these values in the convert(..) method.
hope this helps.
For more image manipulation algorithms,codes and concepts like image processing theory,image filters, brightness/contrast, histograms, noise reduction etc you can visit my website:
http://tanveer.freeservers.com and go to the projects page.Or directly you can access:
http://tanveer.freeservers.com/projects/image_processing_cover.htm hope this helps
regards
Tanveer