What is the for loop at the end of the posted code supposed to do?
The values of red and blue do not change in the loop.
What will the image look like if all the pixels are set to the same values of red and blue?
You need to stop making random changes to the code and work on the design for the steps the program needs to take.
Write some pseudo code describing what you want the code to do.
When the design is worked out, then write the code to do what the design says to do.
An example of pseudo code:
initialize variables
begin loop through all the pixels in image
get next pixel
change value of colors for pixel
set the updated pixel
end loop
show new image with changed pixels