You can search for readPixels in this forum and you will find several examples
Especially the following post shows how to read, change and write data.
I think it wil be help you further.
However if you and to read, change and write, then you should think about implementing an operator. This can be done either in Python or Java. How to write a processor in Python