Logic problems in program code

Can you help me to change the logic in my code which originally “extracts each pixel into R, G, and B values. Adds these values to the ByteBuffer.” into a code that is able to detect writing or lines in my AI model. Please help me to complete this code so that I can complete my assignment with the lecturer. Thank You.

This code is from
IJ Apps

Hi @febrii, Could you please elaborate more on this? Thank You.