X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



5221 Rate this article:
No rating

The IDL "LABEL_REGION" function considers edge pixel data to be zero

DISCUSSION:

The IDL Help reference page for the LABEL_REGION function mentions:

    "Pixels at the edges of Data are considered to be zero."

Consequently, if non-zero edge pixel data must be considered in the results from LABEL_REGION, then you'll need to pad the original data edges with a column and row of zeroes, so that LABEL_REGION will be able to "see" the original edge pixels when calculationg the results.

This Help Article provides an example IDL program that illustrates how to get LABEL_REGION to consider edge pixel data.

EXAMPLE:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+
; :Description:
;   Exelis Visual Information Solutions Technical Support example
;   illustrating a method for including edge pixel data in
;   the results when using the LABEL_REGION() function -- by
;   expanding/padding the borders of the original data with zeros.
;   (By default, the algorithm used by LABEL_REGION() considers
;   all edge pixel data to be zero, even when it is non-zero.)
;-
PRO ex_label_region_edge

  ; Input data
  data = [ [1, 1, 1, 0, 0],  $
    [1, 1, 0, 0, 1], $
    [1, 1, 0, 0, 0], $
    [0, 0, 0, 1, 1], $
    [0, 1, 1, 1, 1], $
    [0, 1, 1, 1, 1] ]
    
  ; Get array size/type information
  struct = SIZE(data, /STRUCTURE)
 
  ; Create temp array with original array dimensions + 2
  tmpdims = struct.dimensions[0:1]+2
  tmp = MAKE_ARRAY(tmpdims, TYPE=struct.TYPE)
 
  ; Assign original data to center of new array
  tmp[1:-2,1:-2] = data
 
  tmp = LABEL_REGION(tmp)
 
  ; Extract the labeled regions to an array of the original size
  labels = tmp[1:-2,1:-2]
 
  PRINT, 'Input data:'
  PRINT, data
  PRINT
  PRINT, 'LABEL_REGION() output without edge pixel data (default):'
  PRINT, LABEL_REGION(data)
  PRINT
  PRINT, 'LABEL_REGION() output including edge pixels:'
  PRINT, labels
  PRINT
END
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

The output from the example program,should look like this:

IDL> ex_label_region_edge
% Compiled module: EX_LABEL_REGION_EDGE.
Input data:
       1       1       1       0       0
       1       1       0       0       1
       1       1       0       0       0
       0       0       0       1       1
       0       1       1       1       1
       0       1       1       1       1

LABEL_REGION() output without edge pixel data (default):
       0       0       0       0       0
       0       1       0       0       0
       0       1       0       0       0
       0       0       0       2       0
       0       2       2       2       0
       0       0       0       0       0

LABEL_REGION() output including edge pixels:
       1       1       1       0       0
       1       1       0       0       2
       1       1       0       0       0
       0       0       0       3       3
       0       3       3       3       3
       0       3       3       3       3

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »