I have an Image of 128×128 pixels in which, there are 1024 blocks of 4×4 pixels each.
If the coordinates of the first block areblock1= im[0:4, 0:4]
, then I want to replace the colour of pixels into a specific pixel intensity(or colour),example-128.
So what I want to do is I want to change the colour of the image something like this-
block1=im[0:4,0:4] block1.replace_colour=128
Note that the image is in the grayscale.Thanks in advance.
Advertisement
Answer
You can do that like this:
colorValue = 150 im[0:4,0:4] = colorValue