Example Code

IMAQ: Color Image to Grayscale

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This VI demonstrates how to convert an image from color (RGB) to a grayscale image.

Description

This simple program converts a color image to grayscale by two methods:  1) Converting the RGB image to a HSL image and extracting the luminance plane  2) Extracting the red color plane from the RGB image. The attached image can be saved and used to demonstrate the functionality of this VI.  The file path of the saved image should be in the File Path control on the front panel.

Steps to Implement or Execute Code

  1. Specify the File Path on the front panel to your desired image
  2. Run the VI

Requirements

Software

LabVIEW 8.0 "or compatible"

IMAQ (part of Vision Acquisition Software 8.0 "or compatible") - Compatibility Link

Vision Development Module "or compatible" - Compatibility Link

VI Snippet

Grayscale.png

Additional Information or References

Additional Images

grayy.jpg


**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit this discussion thread**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Member
Member
on

Hi,

I would like do the oposite.. grayscale to color image. How can i do this?

thanks

alex

Contributors