OriginPro
 
Loading...
Searching...
No Matches
originpro.image.IPage Class Reference
Inheritance diagram for originpro.image.IPage:
originpro.base.BasePage originpro.base.BaseObject

Public Member Functions

def __repr__ (self)
 
def from_np (self, arr, dstack=False)
 
def to_np (self)
 
def to_np2d (self, frame)
 
def from_np2d (self, arr, frame)
 
def from_file (self, fname)
 
def rgb2gray (self)
 
def split (self)
 
def merge (self)
 
def layer (self)
 
def setup (self, channels, multiframe, channelType=-1)
 
def size (self)
 
def channels (self)
 
def frames (self)
 
def type (self)
 
- Public Member Functions inherited from originpro.base.BasePage
def __len__ (self)
 
def is_open (self)
 
def is_active (self)
 
def lt_range (self)
 
def activate (self)
 
def destroy (self)
 
def duplicate (self)
 
- Public Member Functions inherited from originpro.base.BaseObject
def __init__ (self, obj)
 
def __del__ (self)
 
def __str__ (self)
 
def __bool__ (self)
 
def index (self)
 
def get_str (self, prop)
 
def get_int (self, prop)
 
def get_float (self, prop)
 
def set_str (self, prop, value)
 
def set_int (self, prop, value)
 
def set_float (self, prop, value)
 
def method_int (self, name, arg='')
 
def method_float (self, name, arg='')
 
def method_str (self, name, arg='')
 
def lt_exec (self, labtalk)
 
def name (self)
 
def name (self, value)
 
def lname (self)
 
def lname (self, value)
 
def comments (self)
 
def comments (self, value)
 
def show (self)
 
def show (self, value)
 
def usertree (self)
 
def usertree (self, tr)
 
def userprops (self)
 

Additional Inherited Members

- Public Attributes inherited from originpro.base.BaseObject
 obj
 

Detailed Description

This class represents an Origin Image Window, it holds an instance of a PyOrigin ImagePage

Member Function Documentation

◆ channels()

def originpro.image.IPage.channels (   self)
    Parameters:
        none
    Returns:
        image number of channels
    Examples:
        img=op.new_image()
        fn=op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg'
        img.from_file(fn)
        print(img.channels)

◆ frames()

def originpro.image.IPage.frames (   self)
    Parameters:
        none
    Returns:
        number of frames for an image stack, or return 1 if not multi-frames
    Examples:
        img=op.new_image()
        fn=op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg'
        img.from_file(fn)
        print(img.frames)

◆ from_file()

def originpro.image.IPage.from_file (   self,
  fname 
)
load image(s) into the image window

Parameters:
    fname(str): file path to an image file or with wildcard to a group of image files to be loaded into an image stack

Returns:
    success of failure

Examples:
    im = op.find_image('Image1')
    folder = op.path('e') + r'Samples\Image Processing and Analysis'
    fn = folder + r'\Flower.jpg'
    im.from_file(fn)
    #load image stack simply by wildcard
    im2 = op.find_image('Image2')
    fn = folder + r'\*.tif'
    im2.from_file(fn)

    import originpro as op
    url = r'https://download.osgeo.org/geotiff/samples/gdal_eg/cea.tif'
    iw=op.new_image()
    iw.from_file(url)

◆ from_np()

def originpro.image.IPage.from_np (   self,
  arr,
  dstack = False 
)
Set an Image page data from a multi-dimensional numpy array.

Parameters:
    arr (numpy array):
    dstack (bool):  True if arr as row,col,frames, False if frames,row,col

Returns:
    None

Notes:
    It must first call setup() method to initialize the image window

Examples:
    img = op.new_image()
    data = np.array([[[1.0, 2.0],[3.0, 4.0]],[[5.0, 6.0],[7.0, 8.0]],[[9.0, 10.0],[11.0, 12.0]]])
    #print(data.shape)
    img.setup(1, True, 0)
    img.from_np(data, False)

◆ from_np2d()

def originpro.image.IPage.from_np2d (   self,
  arr,
  frame 
)
Transfers data from a 2D numpy array into one frame of an ImagePage.
The image must be multiframe, otherwise nothing is returned.
The size (width, height) of the supplied data must match the size of the image.

Parameters:
    frame (int) the index of the image frame

Returns:
    (bool) success or failure

Examples:
    im2=iw.to_np2d(1)
    im2*=10
    iw.from_np2d(im2,2)

◆ layer()

def originpro.image.IPage.layer (   self)
Parameters:
    none
Returns:
    Graph layer as image holder
Examples:
    img=op.new_image()
    print(img.layer)

◆ merge()

def originpro.image.IPage.merge (   self)
merge a image with 3 or 4 frames in Image Window to a single image
Parameters:
    none
Returns:
    none
Examples:
    img=op.find_image()#you should use imgstack.xfc to prepare a image with 3 or 4 frames first
    img.merge()

◆ rgb2gray()

def originpro.image.IPage.rgb2gray (   self)
convert image window to grayscale
Parameters:
    none
Returns:
    none
Examples:
    img=op.new_image()
    fn=op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg'
    img.from_file(fn)
    img.rgb2gray()

◆ setup()

def originpro.image.IPage.setup (   self,
  channels,
  multiframe,
  channelType = -1 
)
It allows simple initialization by specifying the number of channels
and whether it should be multiframe or not. The existing image
held in the object (if present) is wiped out.

Parameters:
    channels(int): the number of channels (1, 3 or 4).
    multiframe(bool): whethwer it should be multiframe (Image Stack) or not.
    channelType (int, optional): the variable type of the channel.
                                Possible values are:
                                    0 : float64
                                    1 : float32
                                    8 : uint16
                                For all the other values the channel size will be set
                                to uint8.

Returns (bool): success or not

Examples:
    img = op.new_image()
    data = np.array([[[1.0, 2.0],[3.0, 4.0]],[[5.0, 6.0],[7.0, 8.0]],[[9.0, 10.0],[11.0, 12.0]]])
    #print(data.shape)
    img.setup(1, True, 0)
    img.from_np(data, False)

◆ size()

def originpro.image.IPage.size (   self)
    width and height of the image
    Parameters:
        none
    Returns:
        (tuple) width, height value
    Examples:
        img=op.new_image()
        fn=op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg'
        img.from_file(fn)
        print(img.size)

◆ split()

def originpro.image.IPage.split (   self)
split a color image into RGB channels
Parameters:
    none
Returns:
    none
Examples:
    img=op.new_image()
    fn=op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg'
    img.from_file(fn)
    img.split()

◆ to_np()

def originpro.image.IPage.to_np (   self)
Transfers data from an ImagePage to a numpy array.

Parameters:

Returns:
    (numpy array)

Examples:
    npimg = im.to_np()

◆ to_np2d()

def originpro.image.IPage.to_np2d (   self,
  frame 
)
Transfers data from one frame of an ImagePage to a 2D numpy array.
The image must be multiframe, otherwise nothing is returned.

Parameters:
    frame (int) the index of the image frame

Returns:
    (numpy array)

Examples:
    im2=iw.to_np2d(1)

◆ type()

def originpro.image.IPage.type (   self)
    Parameters:
        none
    Returns:
        image media type, 1=single image, 2=multi-frame, 3=video
    Examples:
        img=op.new_image()
        fn=op.path('e') + r'Samples\Image Processing and Analysis\Flower.jpg'
        img.from_file(fn)
        print(img.type)

The documentation for this class was generated from the following file: