Gradient Fill of an Area Under the Waveform Chart in LabVIEW

Updated Dec 4, 2023

Environment

Software

  • LabVIEW

Operating System

  • Windows

In LabVIEW there is a built-in option of Filling the plot (Chart Properties>Plots>Fill). You can select among -Infinity,+Infinity, Zero, and None. Basically, this will fill the area under or above the plot with the selected color.
However, let's imagine a situation that you want to fill the area under the plot with different colors. 
For example, this might be necessary for Histogram graph design which could be met in various programs UI elements. The coloring of the space under the graph varies from black to white.
In this article, we will describe a VI which performs this operation.

Let's suppose you have created a VI which calculates the histogram of the image in your Region Of Interest (ROI). It is calculating the number of pixels in the ROI (this could be a line or rectangle) and provides 255 pairs of data. On the X-axis of the graph, the values of the pixels are represented  (where 0 is black and 255 is white). The Y-axis shows the number of the given intensity values. 
In order to achieve the goal, first, it is necessary to split the single curve of Histogram.vi into 255 curves. For instance, the first curve should contain only the number of pixels with value 0, the 60-th curve should contain the number of pixels with value 60. The rest 254 pints of each curve should be 0.

After doing this, by means of property nodes for each curve, we select Plot Line Width = 0Plot Bar style = 3Plot fill/Point color and Plot Line-color should have the pixel value. 
In order to achieve desired shades of Grey, it is necessary to apply the same values for R, G, B channels of the color control simultaneously.

The screenshot shows the result of the processing described. 
The green rectangle shows the Region Of Interest (ROI) on the image. The Waveform chart named Histogram shows the histogram of ROI. It is colored yellow by means of LabVIEW's built-in properties. 
The waveform chart named Gradient Fill shows the result of the processing of Histogram Chart. It shows the same data but with a gradient fill.

2.jpg
 

The screenshot of the block diagram is shown below. The VI was built on the basis of Histogram.vi which is shipped with LabVIEW.

2.1.jpg