Example: Change the Contrast of an Image

In this example we use the Style pane to change the contrast of an image.   We will use an image showing the portrait of Ginevra de' Benci painted by Leonardo da Vinci.



Before proceeding we have clicked on the ginevra image in the Project pane to highlight it and then we have done a Ctrl-C followed by a Ctrl-V to copy and then paste the image, making a copy in the Project pane under the name ginevra 2.   



We can use the ginevra 2 image in these illustrations to compare changes made to the original image.



Above, we have opened the original ginevra image and have zoomed in to a close up view of the face.   



The Style pane presents the three color outputs in the outputs and channels list.   The R output is driven by data Channel 2, the G output is driven by data Channel 1 and the B output is driven by data Channel 0.   We can see right away the image is what is almost always casually referred to as an "RGB" image.



We would like to adjust contrast on all three channels at the same time, so we Ctrl-click on each row to select it.  With all three rows selected, we right-click into the values cells which give the range 0 to 255 for each channel.



In the menu, we choose Autocontrast and then choose whatever level of standard deviation to apply for the autocontrast effect.   We choose 1.5 standard deviations.



The new values in the list fall within 1.5 standard deviations of all values in the data channel, that is, they are the most frequently used.    The intervals list says to interpolate them into the full range of display output intensities from 0 to 255.  A number like 173, which would normally be only about two thirds intensity will now power the R output to full brightness of 255.   The net effect is to take a range of values that would have involved lesser brightness variations and to make them take effect with greater brightness variations, emphasizing the difference between what formerly were more similar darker and lighter tones.


We press Update Style to apply the changes to the image.


The first illustration below shows the application of the contrast, a harsh contrast using the 1.5 standard deviation setting.   The second illustration shows the original image before contrast changes, using the ginevra 2 copy we made.



Important: The new values autocontrast settings provide are not a change in the data.   They are simply a change in how that data should be interpreted for display.   At any time we can restore the default interpretation of data and thus the original coloring.


Restoring the original coloring is easy.   A simple way of getting a visual effect similar to the original coloring, or better, is to use Full Range:



With the three channel rows selected we right-click into one of the values range boxes and choose Full Range and then we press the Update Style button.



This is not exactly correct, because using the Full Range choices loads the values boxes with the actual values found in the data.  In our example above, Channel 0 used for Blue does not have any pixels at full 255 intensity, so Full Range loads the range zero to 238, the maximum value that occurs.    The result is a slight shift towards blue as seen above at left, compared to the slightly less blue (more yellowish) original at right.



We can restore the original, default range of 0 to 255 by manually entering 255 for the upper value of Channel 0, as seen above.   We press Update Style to apply the change.



"Stretching" the blue channel to apply from zero to 255 produces the original image.


Individual channel contrast - By selecting all three channels we applied the autocontrast choice to all three at once.  If we only wanted to apply Autocontrast (or, for that matter, Full Range) to only one or two channels, we could do that by selecting only one or two channels.


Ginevra de' Benci - Our sample ginevra image shows a close up of the Leonardo da Vinci portrait of Ginevra de' Benci.  The portrait hangs in the National Gallery of Art in Washington, DC, the only painting by Leonardo on public display in the US.  Unlike the Mona Lisa (Giaconda) on display in the Louvre in Paris, where a railing keeps viewers a few meters away, we can approach very close to the Ginevra de' Benci portrait to see fine details.   Download the full size ginevra image from the Product Downloads page.



Painted in the early 1470's when Leonardo was only 21, the portrait shows Ginevra at age 16 or 17, perhaps on the occasion of her betrothal or marriage, in what was for the time a revolutionary and lifelike pose, a three quarter view and not the more typical profile.  Ginevra already at 16 was known for her intelligence, her beauty and her virtue.   



The details of the work, such as Ginevra's left eye seen above in a Zoom to Native zoom level, reveal the characteristic Leonardo genius for rendering the truth of anatomy with artistry in every fine detail.


The painting as we know it today has been altered from the original, with the bottom of the original painting cut away.   Based on other Leonardo works, preparatory sketches Leonardo had drawn at that age, and his exposure to styles and work at the studio of his master and collaborator, Verrocchio, it is likely that the bottom portion of the painting which was cut away showed Ginevra's hands, perhaps in a pose that was a variation of the Leonardo sketch in the Windsor Castle collection, shown at right.   


The early history of the painting is unknown.  It became part of the collections of the Prince of Liechtenstein in Vienna, most likely in 1712.  During WWII it was transferred to the Prince's castle at Vaduz and stored in the wine cellar for safekeeping.  The Ginevra portrait was purchased in 1967 from the reigning Prince for the then-record sum of $5 million by Alisa Mellon Bruce as a gift for the National Gallery of Art.   


At one time the portrait was attributed to Cranach, but for many years experts knew it had to be a Leonardo.  That Leonardo painted Ginevra was conclusively proved in 1991, when during a cleaning his thumbprints were discovered where he had pressed the surface of the paint to soften transitions.


A map of Imola, Italy, drawn by Leonardo da Vinci


Leonardo da Vinci. 1452 - 1519 - The portrait sketch at right by Francesco Melzi, Count of Lombardy, Leonardo's favorite student, is probably the best rendition of Leonardo late in life.   Melzi travelled with Leonardo to his final residence in France as a guest of François I. Leonardo bequeathed to Melzi his manuscripts, his tools and his artistic works, including the Mona Lisa, and named Melzi to be the executor for the rest of his estate. 


Widely acknowledged throughout Europe as the most intelligent man alive, after early years in Florence at the court of Lorenzo de' Medici, "the Magnificent," Leonardo spent much of his life in Milan, first at the court of the Duke of Milan, Ludovico Sforza.  After the overthrow of the Duke in 1499 he spent time in Florence and also Milan.  Late in life, after three years working for Pope Leo X in Rome, in 1516 Leonardo moved to Amboise in France under the patronage of François I.


Leonardo lived at the small chateau of Clos Lucé provided to him by François, near the great royal fortress and chateau of Amboise, which was connected by underground tunnel to Clos Lucé.  Leonardo died on 2 May 1519 at Clos Lucé.


François was certainly aware of the great prestige attached to being Leonardo's patron and protector in his old age, but the stylish king by all accounts formed a genuine and sincere friendship with Leonardo, not surprising since few people of the era met Leonardo without immediately liking him.   Leonardo is said to have designed for François the impressive dual helix spiral staircase at the heart of the king's enormous chateau at Chambord, illustrated in the Labels topic.


Known today for his art and scientifically omnivorous notebooks, Leonardo spent much of his professional life at court designing great stages and decorations for parties and festivals, costumes, jewelry and other courtly frivolities.   He was as famous in his day for leaving artworks uncompleted as he was famous for the genius of his completed works.   A brilliant, kind man, he died a beloved savant to everyone who knew him.



Leonardo is buried in France at the royal fortress of Amboise on the banks of the Loire.   He is interred within the small, jewel-like chapel of St. Hubert, seen above, that juts out from the ramparts of the fortress high above the medieval town below.


Leonardo's grave is in the floor of the Southern niche of the chapel (behind the person seen at left in the photo above) which is by tradition and by sun angle the warm side of the chapel.   That niche and the small nave of the chapel both extend outside the cliff-like retaining walls of the fortress, perched on the buttress that supports the chapel high above the town below.  Leonardo literally is interred not in the earth but in the air, most appropriate for the first man to draw parachutes and flying machines.


See Also





Images and Channels


Palette Images




Style: Images


Style: Channels and Outputs Tutorial


Style: Autocontrast


Style: Palettes


Example: How Images use Tiles from Tables - An example showing how an image is made up from data stored in a table in tiles.


Example: Create Two Images From One Table - More than one image can show data from the same table, including from the same tile field.


Example: An Image using Computed Fields in a Table - How an image can be created from tiles where the data for the tiles is taken from a field that is computed on the fly.


Example: Using the Assign Channels Button - The Assign Channels button in the Style pane for images allows us to assign channels to the standard three Red, Green, and Blue display outputs using frequently-desired arrangements.   The button provides a short cut way to assign all channels at once instead of doing each channel individually.


Example: Assign Channels - How to use the Style pane for images to assign channels to display outputs such as R, G, B or A.  This topic shows examples of channel combinations and the visual results.


Example: Display an NAIP Four Band Image as Color Infrared (CIR) - How to use the Style pane for images to re-assign channels in a four band NAIP image to produce a Color Infrared (CIR) image display.


Example: Set Image Transparency using Alpha - The A row in the Style pane allows us to specify what transparency we want to apply to the image, either by applying the same value for A for all pixels or by using one of the other channels to also control the A value.


Example: Autocontrast and Hill Shading Images using Style - This example shows how the Style pane can hill shade an image using the values of pixels as heights and generating shadows as if the Sun were located at the specified azimuth and altitude.   This capability is used most frequently with raster images to give an impression of three dimensionality in cases where the values of pixels represent terrain elevations.


Example: Style Applied to an Image Server Image - Because the Style pane simply changes the way an image is displayed and not the data, it can operate on read-only data served by various web servers such as WMS REST servers.    In this example we look at every detail of creating a data source using an image server and then manipulating the appearance of the display with Style.  We will connect to a WMS server that provides LiDAR data in various forms, including as terrain elevation.