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-
JavaScript
x
3
1
block1=im[0:4,0:4]
2
block1.replace_colour=128
3
Note that the image is in the grayscale.Thanks in advance.
Advertisement
Answer
You can do that like this:
JavaScript
1
3
1
colorValue = 150
2
im[0:4,0:4] = colorValue
3