Example Code

Interactively Extract The Color Of A Pixel From A 2D Picture

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

Overview

This VI demonstrates how you can interactively extract the color of a pixel from a 2D picture.

 

Description

Have you ever wondered if you could find out the color of a specific pixel on an image? That's exactly what this example does. Run this VI and pick any JPEG image on your computer. An example image is already provided with the VI.

Mouse over the picture control and find out the exact color your mouse is over and the coordinates your mouse is hovering over within the picture identifier.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Download and open the attached ZIP-file
  2. Open the VI and follow the instructions on the Front Panel

 

Additional Information or References

2D Picture Color Picker - Front Panel.png
 
2D Picture Color Picker - Block Diagram.png
 
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**
Raj
National Instruments
Applications Engineer

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

Comments
Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

There is a bug with this that it doesn't take into account and scrolling of the image.  So if you load an image and then scroll down it no longer selects the right color properly.  To fix this read the Origin property, and add it to the offset inside the Mouse Move event.