GeoExpress can encode a defined (cropped) region from any image whether it is a single image, an image mosaic, or an individual image inside a mosaic. With the proper switches set you can target an area to crop on encode by specifying geographic coordinate pairs; by specifying a center geographic coordinate and width and height; or by specifying the same options using image pixel values. You can combine image cropping with any encoding function such as updating images, creating mosaics, optimizing using higher compression, resampling, etc. Cropping via command line also means that you can batch process crop functions for a highly automated image production system.
This feature allows you to encode a subsection of an image without first having to export the subsection to a separate file. It also is useful for removing transparency areas of an image before encoding. By cropping away the edges containing transparency, the MrSID image, in some instances, can be made without encoding any background color into the output image.
NOTE: The default for DOQ images is to automatically crop to Primary Corner Crosses to achieve a seamless mosaic.
When an image is cropped, the following attributes of the image are changed:
To crop multiple images, you may want to use a text file to list files and cropping values. The text file must have a .mos extension.
For example, if you want to crop three images to remove 10 pixels from the top, 20 pixels from the left, 30 pixels from the bottom, and 40 pixels from the right, you might write the following text file:
foo1.tif 10 20 30 40 foo2.tif 10 20 30 40 foo3.tif 10 20 30 40
To run the cropping job, use the following syntax:
mrsidgeoencoder -i mycrop.mos -tiff -cmos -o mycropped.sid
Like other text file lists supported by GeoExpress, similar rules apply to cropping:
To crop an image with a vector overlay file, use the -cropvectoroverlay/-cropvo
and -cropvectorlayer/-cropvol
switches.
The -cropvectoroverlay
switch specifies the name of the vector overlay file. The -cropvectorlayer
switch specifies which layer to use. Layers are zero-based (0 is the first layer, 1 is the second, etc.). If a layer isn't specified, layer 0 is used by default.
For example:
mrsidgeoencoder -i foo.tif -o foo.sid -cropvo overlay.xml -cropvol 0
When the image is encoded, the output file will have the dimensions of the smallest rectangle that contains the shape, and the areas outside of the shape will be filled in with black.
NOTE: Vector overlays with multiple polygons are not supported. If you have a vector overlay that has multiple polygons you can use your favorite GIS package to extract a single polygon to a new vector overlay and then import the new vector overlay into GeoExpress.
The cropping switches are listed in the following table.
Switch | Value | Notes |
---|---|---|
-cmos | Alternately, -croppedmosaic . The number of pixels to crop from the top, right, bottom, and left sides of the image. |
|
-coordspace | string | Alternately -coord . Sets the coordinate system for cropping to image or geo. Default is image (pixels). |
-cropbottom | float | Specifies crop region offset from bottom. |
-cropcxy | float0 float1 | Specifies center XY position of a cropping rectangle. |
-cropleft | float | Specifies crop region offset from left. |
-croplrxy | float0 float1 | Specifies lower right XY position of a cropping rectangle. |
-croppedmosaic | int0 int1 int2 int3 | Alternately, -cmos . The number of pixels to crop from the top, right, bottom, and left sides of the image. |
-cropright | float | Specifies crop region offset from right. |
-croptop | float | Specifies crop region offset from top. |
-cropulxy | float0 float1 | Specifies upper left XY position of a cropping rectangle. |
-cropvectorlayer | sint | Alternately -cropvol . Specifies which layer in the file is to be used for cropping. |
|
string | Alternately -cropvo . Specifies the overlay file to be used for cropping. |
-cropwh | float0 float1 | Specifies width and height of a cropping rectangle. |