28.1.7 Modifying images
Setting pixel data explicitly.
Existing image objects can be modified by using the
set_channel_data command.
-
set_channel_data takes four or five arguments:
- set_channel_data(img ⟨,chn ⟩,x,y,data)
returns a modified copy of img in which the indicated channel components of pixels in
the rectangle with upper left corner (x,y)
and lower right corner (x+w−1,y+h−1), where w resp. h is the number of columns resp. rows of the
matrix data, are set to the values in data; i.e. the chn component in the
pixel (x+j,y+i) in is set to dataij for i=0,…,h−1 and j=0,…,w−1.
Inverting pixel data.
To produce a negative of an image, i.e. to apply the function p↦ 255−p to all channel data
entries, use the unary operator - or the command
inv.