TIOVX User Guide
vx_tutorial_image_extract_channel.c File Reference
#include <stdio.h>
#include <VX/vx.h>
#include <VX/vxu.h>
#include <utility.h>

Go to the source code of this file.

Macros

#define IN_FILE_NAME   "${VX_TEST_DATA_PATH}/colors.bmp"
 Input file name.
 
#define OUT_FILE_NAME   "${VX_TEST_DATA_PATH}/vx_tutorial_image_extract_channel_out.bmp"
 Output file name.
 

Functions

void vx_tutorial_image_extract_channel ()
 Tutorial Entry Point. More...
 

Detailed Description

Extract channels from RGB image using immediate mode then combine them in opposite order.

In this tutorial we learn the below concepts,

  • How to create OpenVX context and OpenVX image data object
  • How to read a BMP file and load the pixel values into the image data object
  • How to query the image data object for attributes like width, height
  • How to use the immediate mode for image processing
  • How to read pixel values from an image data object and save it as a BMP file
  • How to cleanup all created resources and exit the OpenVX application

To include OpenVX interfaces include below file

#include <VX/vx.h>

To include OpenVX interfaces for immediate mode include below file

#include <VX/vxu.h>

Follow the comments in the function vx_tutorial_image_extract_channel() to understand this tutorial

Definition in file vx_tutorial_image_extract_channel.c.

Function Documentation

◆ vx_tutorial_image_extract_channel()

void vx_tutorial_image_extract_channel ( )

Tutorial Entry Point.

















- Define objects that we wish to create in the OpenVX application.

A vx_context object is defined which is used as input parameter for all subesquent OpenVX object create APIs

/
vx_context context;
vx_image in_image = NULL;
vx_image r_channel = NULL;
vx_image g_channel = NULL;
vx_image b_channel = NULL;
vx_image out_image = NULL;































- Create OpenVX context.

This MUST be done first before any OpenVX API call. The context that is returned is used as input for subsequent OpenVX APIs

/
context = vxCreateContext();





























- Create image object.

Follow the comments in tivx_utils_create_vximage_from_bmpfile() to see how a vx_image object is created and filled with RGB data from BMP file IN_FILE_NAME



























- Show image attributes.

Follow the comments in show_image_attributes() to see how image attributes are queried and displayed.

























- Create OpenVX image object.

Creates an OpenVX image object of 'width' x 'height' and having data format 'df'.

/
r_channel = vxCreateImage(context, width, height, (vx_df_image)VX_DF_IMAGE_U8);























- Show image attributes.

Follow the comments in show_image_attributes() to see how image attributes are queried and displayed.

/





















- Create OpenVX image object.

Creates an OpenVX image object of 'width' x 'height' and having data format 'df'.

/
g_channel = vxCreateImage(context, width, height, (vx_df_image)VX_DF_IMAGE_U8);



















- Create OpenVX image object.

Creates an OpenVX image object of 'width' x 'height' and having data format 'df'.

/
b_channel = vxCreateImage(context, width, height, (vx_df_image)VX_DF_IMAGE_U8);

















- Show image attributes.

Follow the comments in show_image_attributes() to see how image attributes are queried and displayed.

/















- Create OpenVX image object.

Creates an OpenVX image object of 'width' x 'height' and having data format 'df'.

/
out_image = vxCreateImage(context, width, height, (vx_df_image)VX_DF_IMAGE_RGB);













- Show image attributes.

Follow the comments in show_image_attributes() to see how image attributes are queried and displayed.

/











- Performs immediate mode channel extract.

The second argument gives the input image, the third argument gives the channel to extract and the final argument gives the output image.

/
vxuChannelExtract(context, in_image, (vx_enum)VX_CHANNEL_R, r_channel);
vxuChannelExtract(context, in_image, (vx_enum)VX_CHANNEL_G, g_channel);
vxuChannelExtract(context, in_image, (vx_enum)VX_CHANNEL_B, b_channel);









- Performs immediate mode channel combine.

The second, third and fourth arguments give channels to combine with the last argument being the output image.

/
vxuChannelCombine(context, b_channel, g_channel, r_channel, NULL, out_image);







- Save image object to bitmap file OUT_FILE_NAME.

Follow the comments in tivx_utils_save_vximage_to_bmpfile() to see how data in vx_image object is accessed to store pixel values from the image object to BMP file OUT_FILE_NAME





- Release image object.

Since we are done with using this image object, release it

/
vxReleaseImage(&in_image);
vxReleaseImage(&r_channel);
vxReleaseImage(&g_channel);
vxReleaseImage(&b_channel);
vxReleaseImage(&out_image);



- Release context object.

Since we are done using OpenVX context, release it. No further OpenVX API calls should be done, until a context is again created using vxCreateContext()

/
vxReleaseContext(&context);

Definition at line 108 of file vx_tutorial_image_extract_channel.c.