Example Code

Three Ways to Create a Photo Negative in LabVIEW

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

  • Vision Development Module
  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates how to create a negative grayscale image with 3 different methods.

 

Description

The example demonstrates three different methods of creating a photo negative in LabVIEW:

  1. Using the IMAQ Inverse function: This method is the cleanest on the block diagram, but it does not allow for customization.
  2. Using IMAQ Subtract: This method is less simple, but a bit more hands-on than the IMAQ Inverse Method. The original image is loaded from a file and an equally sized image of full luminance (all pixel values of 255 for 8 bit image) is created with the IMAQ FillImage function. To create the negative, the original image is simply subtracted from the full luminance image using the IMAQ Subtract function.
  3. Using IMAQ ImageToArray. This method is the most complex, but will also allow for the highest level of customization and direct adjustments. The original image is loaded from file, then converted to an array using the IMAQ ImageToArray function. The array is indexed in a For Loop and each of the pixel values is compared to a neutral-grey value, inverted, and placed into a new array pixel by pixel. The array of inverted pixel values is then converted into an image using the IMAQ ArrayToImage function.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • Vision Development Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

 Steps to Implement or Execute Code

  1. Open the attached file
  2. (Optional) Change the path to the preset image in the block diagram
  3. Select the mode on how to negate the image
  4. Run the VI

 

Additional Information or References

Create Negative Image - Front Panel.png 

Create Negative Image - 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.**

Matt
NI Community Team
National Instruments

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

Comments
Greg_S-Video
NI Employee (retired)
on

Thank you very much!  This is exactly what I needed!

Sincerely,

Greg S.
VGans
Member
Member
on

Thanks for the tip
I have to make an image processing program and i needed that!

And It even works without Imaq

Hassan_Atassi
Active Participant
Active Participant
on

Awesome Example!

Regards,

Hassan Atassi
Senior Group Manager, Digital Support
Strob
Member
Member
on

Ok!!! прикольно

Greg_S-Video
NI Employee (retired)
on

"I won 2nd place in my elementary school bike rodeo in the 3rd grade." - Spicy Brown

Sincerely,

Greg S.
_Y_
Active Participant
Active Participant
on

Seems, CreateNegativeArray.vi contains an error. Operation "Greater Then 0?" is applied to U8 value. Thus the output is False only if the input value is zero.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
Greg_S-Video
NI Employee (retired)
on

OH, NO!  I've been using that VI for the past 4 years in my PhD thesis!  4 years of data down the drain. 

Sincerely,

Greg S.
_Y_
Active Participant
Active Participant
on

Untitled.gif

Would such an operation do the work?

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
RyanCheng
Member
Member
on

you did great by helping me, thank you for your great job!