X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

6/3/2025

Rethinking the Reliability of Type 1a Supernovae   How do astronomers measure the universe? It all starts with distance. From gauging the size of a galaxy to calculating how fast the universe is expanding, measuring cosmic distances is essential to understanding everything in the sky. For nearby stars, astronomers use... Read More >

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

5/26/2025

Whether you’re new to remote sensing or a seasoned expert, there is no doubt that large language models (LLMs) like OpenAI’s ChatGPT or Google’s Gemini can be incredibly useful in many aspects of research. From exploring the electromagnetic spectrum to creating object detection models using the latest deep learning... Read More >

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

4/28/2025

When every second counts, the ability to process geospatial data rapidly and accurately isn’t just helpful, it’s critical. Geospatial Intelligence (GEOINT) has always played a pivotal role in defense, security, and disaster response. But in high-tempo operations, traditional workflows are no longer fast enough. Analysts are... Read More >

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

4/24/2025

This blog was written by Eli Dwek, Emeritus, NASA Goddard Space Flight Center, Greenbelt, MD and Research Fellow, Center for Astrophysics, Harvard & Smithsonian, Cambridge, MA. It is the fifth blog in a series showcasing our IDL® Fellows program which supports passionate retired IDL users who may need support to continue their work... Read More >

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

2/25/2025

This blog was written in collaboration with Adam O’Connor from Wyvern.   As hyperspectral imaging (HSI) continues to grow in importance, access to high-quality satellite data is key to unlocking new insights in environmental monitoring, agriculture, forestry, mining, security, energy infrastructure management, and more.... Read More >

1345678910Last
7597 Rate this article:
5.0

First Valley Shadow Detection

Anonym

Shadows can be difficult to deal with when introduced into an analysis pipeline. There are many different ways in which to deal with shadows, but I’ve found that one of the easiest ways is to simply mask them out. I work primarily with agricultural data and row-planted crops in particular. In this type of data, the shadows are cast on bare earth between rows, because of that they can be masked out without much heartache, assuming that your target material is the vegetation itself. Depending on what type of imagery is being used, shadows are normally one of the darkest, if not the darkest, surfaces in the image. This assumption can be used to our advantage—in a histogram of the imagery, the shadows should fall at the lower end.

For example, in this image of an orange orchard, the shadows are the darkest feature and thus fall at the bottom of the histogram.

Figure 1: NIR image of orange orchard

 

Figure 2: Histogram of figure 1

By looking at the imagery, you can see that there is a distinctive valley between two major features. Using the NIR First Valley Method (Jan-Chang, Yi-Ta, Chaur-Tzuhn, & Shou-Tsung, 2016), you can isolate the local minima then use that as the upper bound of a threshold used for shadow masking. The local minima can be easily derived by using the method presented in the support document entitled: Finding multiple local max/min values for 2D plots with IDL.

Figure 3: Shadows displayed in red

 

Figure 4: First valley identified

 

function local_max_finder, datax, datay, minima = minima compile_opt idl2 ;initialize list max_points = list() data_x = datax data_y = datay 
 ;check for keyword, flip the sign of the y values if keyword_set(minima) then data_y = -datay ;iterate through elements for i=1, n_elements(data_y)-2 do begin 
 ;previous point less than i-th point and next point less than i-th point if ( (data_y[i-1] le data_y[i]) AND (data_y[i] ge data_y[i+1])) then max_ points.add, i endfor ;return an array of the indices where the extrema occur return, max_points.toarray() end 
pro ShadowFinder compile_opt IDL2 ; Select your image e = envi(/current) oRaster = e.UI.SelectInputData(/Raster, bands = bands) ; Check for single band if N_ELEMENTS(bands) gt 1 then begin MESSAGE, 'Input raster may only contain 1 band', /INFORMATIONAL return endif ; Pull the data out of the image data = oRaster.GetData(bands = bands, pixel_state = pixel_state) ; Convert data to float data = float(bytscl(data)) ; Mask all values in the image bkgrd_pos = where(pixel_state ne 0) data[bkgrd_pos] = !VALUES.F_NAN ; find all local minima based off the histogram of the image h = histogram(data, LOCATIONS=xbin) ; Remove zero values non_zeros = where(h ne 0) h = h[non_zeros] xbin = xbin[non_zeros] ; Get the number of points n_pts = n_elements(h) ; Smooth data (7 pixel moving average) boxcar = 7 p1 = (boxcar - 1) / 2 p2 = boxcar - p1 for i = 0 , n_pts-1 do begin pos = [i-p1:i+p1] pos = pos[where((pos ge 0) and (pos le n_pts-1))] h[i] = mean(h[pos]) endfor MINIMA = local_max_finder(xbin, h, /MINIMA) x_extrema = xbin[MINIMA] y_extrema = h[MINIMA] ; Plot all local minima p = plot(xbin, h) p3 = scatterplot(x_extrema, y_extrema, /current, /overplot, $ symbol = 'o', sym_color = 'b', sym_thick = 2) ; Create a shadow mask mask = bytarr(oRaster.ns, oRaster.nl) mask[where(data le x_extrema[0])] = 1 ; create a new metadata object metadata = ENVIRasterMetadata() metadata.AddItem, 'classes', 2 metadata.AddItem, 'class names', ['Background', 'Shadow'] metadata.AddItem, 'class lookup', [[0,0,0],[255,0,0]] metadata.AddItem, 'data ignore value', 0 metadata.AddItem, 'band names', 'Shadows' ; Create a classification image oClass = e.CreateRaster(e.GetTemporaryFileName(), mask, SPATIALREF = oRaster.SPATIALREF, $ data_type = 1, metadata = metadata) oClass.save ; Add the new class image to envi e.data.add, oClass end 
 

References

Jan-Chang, C., Yi-Ta, H., Chaur-Tzuhn, C., & Shou-Tsung, W. (2016). Evaluation of Automatic Shadow Detection Approaches Using ADS-40 High Radiometric Resolution Aerial Images at High Mountainous Region. Journal of Remote Sensing & GIS.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Please login or register to post comments.