Previous topic

IPLT command line

Next topic

Applying a Fourier Transform to an image

Extracting and Pasting ImagesΒΆ

An image can be extracted and pasted into another image using the Extract() and Paste() member functions:

# import the necessary classes
from ost.img import *
from ost.io import LoadImage
# load the image
im=LoadImage("imagename.tif")
# gererate a subimage from the region going from (10,10) to (30,30)
im2=im.Extract(Extent(Point(10,10),Point(30,30)))
# generate an empty image with the same size as the original image
im3=CreateImage(im.GetExtent())
# paste the subimage into the empty image
im3.Paste(im2)

Note that the extent is fully honored for the paste operation, i.e. only the region where the pasted-to and the pasted-in image overlap will be affected.