TI Image Menu

This submenu is located under More Modules.

Note: When creating a new program that uses this module, it is recommended to use the Image Processing program type. This will ensure that all the relevant modules are imported.

Item

Description

from ti_image import *

Imports all methods from the ti_image module.

new_image(width,height,(r,g,b))

Creates a new image with the specified width and height for use in the Python program.

The color of the new image is defined by the (r,g,b) values.

load_image("name")

Loads the image specified by the "name" for use in the Python program.

The image must be part of the TNS document either in a Notes or Graphs application.

The "name" prompt will display the image names (if they have been named earlier) or a number indicating their insertion order.

copy_image(image)

Creates a copy of the image specified by the "image" variable.

Methods of the image object

Additional functions related to the image objects are available in the Editor and Shell by typing the variable name followed by a . (dot).

get_pixel(x,y): Gets the (r,g,b) value of the pixel at location defined by the (x,y) coordinate pair.

px_val = get_pixel(100,100)

print(px_val)

set_pixel(x,y,color_tuple): Sets the pixel at location (x,y) to the color specified in the color_tuple.

set_pixel(100,100,(0,0,255))

Sets the pixel at (100,100) to the (0,0,255) color.

show_image(x,y): Displays the image with the top left corner at location (x,y).
w, h, name: Gets the width, height, and name parameters of the image.

Example

from ti_image import *

 

# An image has been previously inserted into the TNS document in a Notes application and named "bridge"

im1=load_image("bridge")

px_val = im1.get_pixel(100,100)

print(px_val)

 

# Set the pixel at 100,100 to blue (0,0,255)

im1.set_pixel(100,100,(0,0,255))

new_px = im1.get_pixel(100,100)

print(new_px)

 

# Print the width, height and name of the image

print(im1.w, im1.h, im1.name)