Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
Loading...
Searching...
No Matches
SImage Class Reference

Provide image edition methods. More...

Inheritance diagram for SImage:
SComp

Public Types

enum  SImageType { ABSTRACT = 0 , PERSPECTIVE = 1 , SPHERICAL = 2 , ORTHO = 3 }
 The type of the SImage. More...
 
- Public Types inherited from SComp
enum  VisibilityEnum { HIDDEN_ONLY = 0 , VISIBLE_ONLY = 1 , ANY_VISIBILITY = 2 }
 Visible criteria. More...
 

Public Member Functions

Object ClearMask ()
 Clear the link between a SImage and its texture mask. More...
 
Object CreateMaskAuto ()
 Create an automatic mask from the SImage. More...
 
Object GetCameraExternalParameters ()
 Get the external camera parameters of perspective and spherical SImage. More...
 
Object GetCameraInternalParameters ()
 Get the internal camera parameters of a perspective SImage. More...
 
Object GetImageType ()
 Get the type of the SImage. More...
 
Object GetOrthoParameters ()
 Get the ortho SImage parameters. More...
 
Object GoToCameraViewpoint ()
 Go to the camera viewpoint. More...
 
boolean HasMask ()
 Return if the SImage has a mask or not. More...
 
Object Save (string filePath, SMatrix coordinateSystemMatrix=SMatrix())
 Save the image into a file. More...
 
Object SetCameraExternalParameters (SCameraExternal externalParams)
 Set the external camera parameters for perspective and spherical SImage. More...
 
Object SetCameraInternalParameters (SCameraInternal internalParams)
 Set the internal camera parameters for a perspective SImage. More...
 
Object SetMaskFromFile (string maskFilePath)
 Set the texture mask of the SImage from a file.
File extensions authorized: .bmp, .tif, .jpg, .png.
The texture mask image must have the same size as the current image. More...
 
Object SetOrthoParameters (SPoint position, number rotation, number pixelSize)
 Set the ortho SImage parameters. More...
 
 SImage (SImage other, SImageType imageType=SImage.ABSTRACT)
 Construct a SImage by copying the SImage other and setting the SImage.SImageType in input. If ABSTRACT type is set, the image type of the SImage other is used. More...
 
string toString ()
 Get the type of the variable. More...
 
- Public Member Functions inherited from SComp
 AddToDoc ()
 Add the object to the document. More...
 
 ApplyTransformation (SMatrix matrix)
 Apply a geometric transformation to the current object by making a product with the given matrix. More...
 
Object GetBoundingBox (SMatrix ucs=null)
 Calculate the bounding box of the object. More...
 
Object GetColors ()
 Get the colors of the object. More...
 
string GetFolderName ()
 Get the name of the folder containing the object. More...
 
string GetName ()
 Return the object's name. More...
 
string GetPath ()
 Return the full path of a SComp in the tree. More...
 
 Invert ()
 Invert the normal of the object. More...
 
boolean IsInDoc ()
 Return if the object is in the document or not. More...
 
boolean IsVisible ()
 Get the visibility of the object. More...
 
 MoveToGroup (string groupPath, boolean moveInsideTopParent=true)
 Move the object to the document group represent by the given path. If some groups, in the path, don't exist, they will be created. More...
 
 RemoveFromDoc ()
 Remove the object from the document. More...
 
 SetClippable (boolean clipping)
 Set clippable or not. More...
 
 SetColors (number red, number green, number blue)
 Set the colors of the object. More...
 
 SetName (string objectName)
 Set the object's name. More...
 
 SetTransparency (number alpha)
 Set the transparency of the object. More...
 
 SetVisibility (boolean visible)
 Set the object to be visible, or not visible. More...
 
string toString ()
 Get the type of the variable. More...
 
 Translate (SVector vector)
 Make a translation of the current object with an SVector. More...
 

Static Public Member Functions

static Array< SImageAll (VisibilityEnum visCrit=SComp.ANY_VISIBILITY)
 Get all the SImage in the document. More...
 
static Object EstimatePose (SImage imageToEstimate, Array< SPoint > crdModel3D, Array< SPoint > crdUVImage, Object options)
 Estimate the pose of a SImage using reference points. More...
 
static Object EstimatePose (SImage imageToEstimate, string path, Object options)
 Estimate the pose of a SImage using reference points from a file. More...
 
static Object ExportOrthoImage (string outputFilePath, SVector viewDirection, SVector horizontalNormal, SPoint upperLeftCorner, number backgroundColor, number widthInDocumentUnit, number heightInDocumentUnit, number pixelSize, number pointAndLineSize)
 Export an ortho SImage and create a georeferencing file. More...
 
static Object FromFile (string fileName, number imageType=0)
 Import an image and create a new SImage from a file.
The function automatically detects image type (spherical, ortho, perspective, abstract) and loads calibration or georeferencing information.
The image type can also be forced by using the SImage.SImageType in input. If SImage.ABSTRACT type is set, the automatically detected image type won't be changed.
File extensions authorized: .bmp, .tif, .jpg, .png. More...
 
static Array< SImageFromName (string name)
 Search all the SImage with the given name. More...
 
static Object FromPix4DProject (string fileName)
 Import SImage from a Pix4D project. More...
 
static Array< SImageFromSel ()
 Get all the selected SImage. More...
 
static SImage New (SImage other, SImageType imageType=SImage.ABSTRACT)
 Construct a SImage by copying the SImage other and setting the SImage.SImageType in input. If ABSTRACT type is set, the image type of the SImage other is used. More...
 
static Object SphericalFromPerspectiveImages (Array< SImage > images, number clusteringDistance, SCloud cloud=null)
 Convert perspective SImage to spherical SImage. More...
 
- Static Public Member Functions inherited from SComp
static Array< SCompAll (VisibilityEnum visCrit=SComp.ANY_VISIBILITY)
 Get all the SComp in the document. More...
 
static Object FromClick ()
 Launch an interaction to select a SComp in the scene. More...
 
static Array< SCompFromName (string name)
 Search all the SComp with the given name. More...
 
static Array< SCompFromSel ()
 Get all the selected SComp. More...
 

Detailed Description

Provide image edition methods.

Requires the Survey license.

Member Enumeration Documentation

◆ SImageType

The type of the SImage.

Enumerator
ABSTRACT 

Abstract image.

PERSPECTIVE 

Perspective image.

SPHERICAL 

Spherical image.

ORTHO 

Ortho image.

Constructor & Destructor Documentation

◆ SImage()

SImage::SImage ( SImage  other,
SImageType  imageType = SImage.ABSTRACT 
)

Construct a SImage by copying the SImage other and setting the SImage.SImageType in input. If ABSTRACT type is set, the image type of the SImage other is used.

Parameters
other(SImage) The other SImage to copy
imageType(SImageType) The image type

Member Function Documentation

◆ All()

static Array< SImage > SImage::All ( VisibilityEnum  visCrit = SComp.ANY_VISIBILITY)
static

Get all the SImage in the document.

Parameters
visCrit(VisibilityEnum) Visible selection criteria
Returns
(Array<SImage>) Array of all the SImage contained in the document, that fulfill the visibility criteria

◆ ClearMask()

Object SImage::ClearMask ( )

Clear the link between a SImage and its texture mask.

License
This function requires the license Survey.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
  • 2: The image doesn't contain any mask

◆ CreateMaskAuto()

Object SImage::CreateMaskAuto ( )

Create an automatic mask from the SImage.

License
This function requires the license Survey.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ EstimatePose() [1/2]

static Object SImage::EstimatePose ( SImage  imageToEstimate,
Array< SPoint crdModel3D,
Array< SPoint crdUVImage,
Object  options 
)
static

Estimate the pose of a SImage using reference points.

License
This function requires the license Survey.
Note
Example to fill the options array:
var image = SImage.FromSel()[0];
var xyzPoints = [SPoint.New(10, 20, 30), SPoint.New(20, 30, 40), SPoint.New(30, 40, 50), SPoint.New(40, 50, 60)];
var uvPoints = [SPoint.New(0.0, 0.0, 0), SPoint.New(1.0, 0.0, 0), SPoint.New(1.0, 1.0, 0), SPoint.New(0.0, 1.0, 0)];
var options = {keepPosition: false, keepOrientation: false, keepInternal: true, projection: 0};
var result = SImage.EstimatePose(image, xyzPoints, uvPoints, options);
Provide image edition methods.
Definition: Reshaper.h:5290
static Object EstimatePose(SImage imageToEstimate, Array< SPoint > crdModel3D, Array< SPoint > crdUVImage, Object options)
Estimate the pose of a SImage using reference points.
static Array< SImage > FromSel()
Get all the selected SImage.
Provide point edition and creation methods.
Definition: Reshaper.h:6761
static SPoint New()
Default constructor to create an empty new SPoint. X = Y = Z = 0.
Parameters
imageToEstimate(SImage) The SImage to estimate the pose of.
crdModel3D(Array<SPoint>) The 3D coordinates.
crdUVImage(Array<SPoint>) The texture UV coordinates.
options(Object) Data structure containing computation options. This data structure have to contain the following fields:
  • keepPosition (boolean): To keep or not the position of the camera (default: false). It cannot be true for images of type Unknown.
  • keepOrientation (boolean): To keep or not the orientation of the camera (default: false). It cannot be true for images of type Unknown.
  • keepInternal (boolean): To keep or not the internal parameters of the camera (default: false). It cannot be true for images of type Spherical and Unknown.
  • projection (number): The desired projection type. Images of type Perspective and Spherical must have a matching projection type. Images of type Unknown can be both.
Return values
ret.Value(number) The sum of the residual re-projection errors.
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Not enough control points (needs at least 4 pairs)
  • 2: Missing texture size
  • 3: Invalid projection type
  • 4: Invalid residual error (more than 1% deviation, results still usable)
  • 5: An error occurred
ret.Image(SImage) The SImage with its new estimated pose.

◆ EstimatePose() [2/2]

static Object SImage::EstimatePose ( SImage  imageToEstimate,
string  path,
Object  options 
)
static

Estimate the pose of a SImage using reference points from a file.

License
This function requires the license Survey.
Note
Example to fill the options array:
var image = SImage.FromSel()[0];
var refPointsFile = "C:\\EstimatePose.txt";
var options = {keepPosition: false, keepOrientation: false, keepInternal: true, projection: 0};
var result = SImage.EstimatePose(image, refPointsFile, options);
Parameters
imageToEstimate(SImage) The SImage to estimate the pose of.
path(string) The path of the file where reference points are stored.
options(Object) Data structure containing computation options. This data structure have to contain the following fields:
  • keepPosition (boolean): To keep or not the position of the camera (default: false). It cannot be true for images of type Unknown.
  • keepOrientation (boolean): To keep or not the orientation of the camera (default: false). It cannot be true for images of type Unknown.
  • keepInternal (boolean): To keep or not the internal parameters of the camera (default: false). It cannot be true for images of type Spherical and Unknown.
  • projection (number): The desired projection type. Images of type Perspective and Spherical must have a matching projection type. Images of type Unknown can be both.
Return values
ret.Value(number) The sum of the residual re-projection errors.
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Not enough control points (needs at least 4 pairs)
  • 2: Missing texture size
  • 3: Invalid projection type
  • 4: Invalid residual error (more than 1% deviation, results still usable)
  • 5: An error occurred
ret.Image(SImage) The SImage with its new estimated pose.

◆ ExportOrthoImage()

static Object SImage::ExportOrthoImage ( string  outputFilePath,
SVector  viewDirection,
SVector  horizontalNormal,
SPoint  upperLeftCorner,
number  backgroundColor,
number  widthInDocumentUnit,
number  heightInDocumentUnit,
number  pixelSize,
number  pointAndLineSize 
)
static

Export an ortho SImage and create a georeferencing file.

License
This function requires the license Survey.
Note
Coordinates must be provided with respect to the global coordinates system.
Parameters
outputFilePath(string) The file (with path) to save.
viewDirection(SVector) The view direction (perpendicular to the created picture).
horizontalNormal(SVector) The horizontal direction.
upperLeftCorner(SPoint) The upper left corner of the image.
backgroundColor(number) The background color -> backgroundColor = ColBlue * 2^16 + ColGreen * 2^8 + ColRed.
widthInDocumentUnit(number) The width of the image, in document unit.
heightInDocumentUnit(number) The height of the image, in document unit.
pixelSize(number) The size of a single pixel, in document unit.
pointAndLineSize(number) The line width, point size and font size are scaled by this factor. This factor applies to the resulting image pixels, and thus depends on pixelSize.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
  • -9: Invalid given point (null pointer)

◆ FromFile()

static Object SImage::FromFile ( string  fileName,
number  imageType = 0 
)
static

Import an image and create a new SImage from a file.
The function automatically detects image type (spherical, ortho, perspective, abstract) and loads calibration or georeferencing information.
The image type can also be forced by using the SImage.SImageType in input. If SImage.ABSTRACT type is set, the automatically detected image type won't be changed.
File extensions authorized: .bmp, .tif, .jpg, .png.

Note
If a world file having the same name as the image is present in the same folder, georeferencing information will be associated to the image.
If the image is a geotif, the georeferencing will be read.
If a .xml or a.incam file having the same name as the image is present in the same folder, calibration information will be associated to the image.
If only one .xml or a.incam file is present in the same folder, calibration information will be associated to the image.
If a .excam file having the same name as the image is present in the same folder, external parameters will be associated to the image.
Parameters
fileName(string) The path and name of the image file to import
imageType(number) The image type
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred
ret.Image(SImage) The SImage

◆ FromName()

static Array< SImage > SImage::FromName ( string  name)
static

Search all the SImage with the given name.

Parameters
name(string) The name to find
Returns
(Array<SImage>) All the SImage with the given name

◆ FromPix4DProject()

static Object SImage::FromPix4DProject ( string  fileName)
static

Import SImage from a Pix4D project.

Parameters
fileName(string) The path and name of the .p4d file to read
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Some errors are found while reading the information
  • 2: The file can't be opened
ret.ImageTbl(Array<SImage>) The table of imported SImage.

◆ FromSel()

static Array< SImage > SImage::FromSel ( )
static

Get all the selected SImage.

Returns
(Array<SImage>) All the selected SImage

◆ GetCameraExternalParameters()

Object SImage::GetCameraExternalParameters ( )

Get the external camera parameters of perspective and spherical SImage.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type
ret.CameraExternal(SCameraExternal) The camera external parameters

◆ GetCameraInternalParameters()

Object SImage::GetCameraInternalParameters ( )

Get the internal camera parameters of a perspective SImage.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type
ret.CameraInternal(SCameraInternal) The camera internal parameters

◆ GetImageType()

Object SImage::GetImageType ( )

Get the type of the SImage.

Return values
ret.ImageType(SImageType) The image type

◆ GetOrthoParameters()

Object SImage::GetOrthoParameters ( )

Get the ortho SImage parameters.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type
ret.Point(SPoint) The top left corner of the ortho image
ret.RotZ(number) The rotation of the ortho image in degrees
ret.Length(number) The pixel size in document unit

◆ GoToCameraViewpoint()

Object SImage::GoToCameraViewpoint ( )

Go to the camera viewpoint.

Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type

◆ HasMask()

boolean SImage::HasMask ( )

Return if the SImage has a mask or not.

Returns
(boolean) True if the SImage has a mask

◆ New()

static SImage SImage::New ( SImage  other,
SImageType  imageType = SImage.ABSTRACT 
)
static

Construct a SImage by copying the SImage other and setting the SImage.SImageType in input. If ABSTRACT type is set, the image type of the SImage other is used.

Parameters
other(SImage) The other SImage to copy
imageType(SImageType) The image type
Returns
(SImage) The new SImage.

◆ Save()

Object SImage::Save ( string  filePath,
SMatrix  coordinateSystemMatrix = SMatrix() 
)

Save the image into a file.

License
This function requires the license Survey.
Note
Supported extensions:
.jpg
.jpeg
.bmp
.png
.tif
.tiff
Warning
When you write a '\' in string you need to double it '\\' or use '/' instead. Pay especially attention to this when writing file paths in your scripts.
var path = 'C:/Point.asc'; // valid syntax
var path = 'C:\\Point.asc'; // valid syntax
var path = 'C:\Point.asc'; // invalid syntax
Parameters
filePath(string) The complete file path to save into
coordinateSystemMatrix(SMatrix) The matrix to define a UCS used for the export (or identity to use the WCS)
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type

◆ SetCameraExternalParameters()

Object SImage::SetCameraExternalParameters ( SCameraExternal  externalParams)

Set the external camera parameters for perspective and spherical SImage.

License
This function requires the license Survey.
Parameters
externalParams(SCameraExternal) The camera external parameters
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type

◆ SetCameraInternalParameters()

Object SImage::SetCameraInternalParameters ( SCameraInternal  internalParams)

Set the internal camera parameters for a perspective SImage.

License
This function requires the license Survey.
Parameters
internalParams(SCameraInternal) The camera internal parameters
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type

◆ SetMaskFromFile()

Object SImage::SetMaskFromFile ( string  maskFilePath)

Set the texture mask of the SImage from a file.
File extensions authorized: .bmp, .tif, .jpg, .png.
The texture mask image must have the same size as the current image.

License
This function requires the license Survey.
Note
The texture mask is expected to be only black and white.
Therefore, all non-white pixels will be considered as masking area.
Parameters
maskFilePath(string) The path of the file that contains the mask to apply.
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: An error occurred

◆ SetOrthoParameters()

Object SImage::SetOrthoParameters ( SPoint  position,
number  rotation,
number  pixelSize 
)

Set the ortho SImage parameters.

License
This function requires the license Survey.
Parameters
position(SPoint) The insertion point (top left corner)
rotation(number) The rotation value in degrees
pixelSize(number) The pixel size of the ortho image in document unit
Return values
ret.ErrorCode(number) The error code
  • 0: No error
  • 1: Wrong image type

◆ SphericalFromPerspectiveImages()

static Object SImage::SphericalFromPerspectiveImages ( Array< SImage images,
number  clusteringDistance,
SCloud  cloud = null 
)
static

Convert perspective SImage to spherical SImage.

License
This function requires the license Survey.
Parameters
images(Array<SImage>) The table of SImage to convert.
clusteringDistance(number) The distance used to group images according to their positions.
cloud(SCloud) An optional cloud to improve image quality by computing a depth information.
Return values
ret.ImageTbl(Array<SImage>) The spherical images.
ret.IndicesTbl(Array<Array<number>>) The indices of the inputs images used to create each spherical image.
ret.ErrorCode(number) The error code:
  • 0: No error
  • 1: Partial conversion
  • 2: An error occurred

◆ toString()

string SImage::toString ( )

Get the type of the variable.

Returns
(string) The type name