Copy randomly-selected non-masked pixels.
Randomly selects pixels from an input image and copies them to an output image. The output image will have approximately the same non-spatial statistics as the input but will have different spatial properties. The user may specify mask values which will not be copied to the output image.
- IN
- Input image. The input image may be windowed and subbanded and may contain any data type.
- OUT
- Output image. The name of the output image. This image will have the same number of bands as IN. The numbers of lines and samples will be determined by SAMPERC and the amount of masked data in the input image.
- SAMPERC
- Sampling percentage. The percentage of non-masked pixels to randomly select. If SAMPERC < 100.0, the input (non-masked) pixels will be randomly selected and the image size will be reduced. If SAMPERC=100.0, then all (non-masked) input pixels will be copied to the output.
< 100.0: Reduce image size, select this percentage of pixels = 100.0: Copy all non-masked pixels
- MASKBAND(1 )
- Mask band. The band of IN used to identify masked pixels. If a masked pixel is located in MASKBAND, then all image bands will be masked at that pixel location. If MASKVAL=NULL, MASKBAND will be ignored.
- MASKVAL(-- )
- Mask values. The pixel values or value ranges designating masked areas of IN that should not be copied to OUT. If MASKVAL=NULL, no checks are performed for masked data. See User Note 2 for more detailed information.
- SEEDVAL(-- )
- Seed value. The user may specify a seed value for random number generation. This allows generating an identical output image for a given input image and set of parameters. If SEEDVAL=NULL, a seed value will be based on the system clock to produce different output images for each execution.
- FILLVAL(0 )
- Fill value. The pixel value to be used for completing the last image line. Image data will normally constitute a portion of the last image line; FILLVAL is used to complete this line.
- ODTYPE(SAME)
- Output data type. The data type of the output image.
= SAME: Same as input = BYTE: Byte = I*2: Integer*2 = I*4: Integer*4 = R*4: Real*4
RANDSEL will check band 1 for the mask value of 0. All non-masked pixels will be copied from the input image WHEEL to the output image EXAMPLE1. The number of output pixels will equal the total number of input pixels minus the number of masked input pixels.
30% of the pixels of the input image WHEEL will be randomly selected to create the output image EXAMPLE2. No checks will be applied for masked data.
Input and output images for the examples appear in the online Mosaic help and the hardcopy user guide.
RANDSEL randomly selects pixels from an input image and copies them to an output image. It maintains pixel values for each band but optionally subsamples the image and shifts pixels from one line to the next. The output image will have the same number of bands and (nearly) the same non-spatial statistics as the input, but will not generally be recognizable.
The user may specify mask values (MASKVAL) which will not be copied to the output image. If MASKVAL is specified, every pixel in MASKBAND is checked to determine if that pixel is masked data and should therefore be excluded from the output image. If SAMPERC is less than 100, the input image will be reduced in size and a random selection criteria will be applied to the non-masked pixels; the decision to select or not select each non-masked pixel will be based on a random number. (See User Note 3 for information on random numbers.) If SAMPERC=100, no subsampling will occur; all non-masked input pixels will be copied to the output image. If SAMPERC=100 and MASKVAL=NULL, the input image will be copied without change.
An intermediate single-band byte image is created with the same numbers of lines and samples as the input image. This intermediate image indicates whether or not each input pixel will later be copied to the output image; it contains the results of both application of MASKVAL and random pixel selection. The intermediate image is deleted before RANDSEL completes.
As the intermediate image is created, the number of pixels that will be copied to the output image (number_selected_pixels) is tracked. This information is used to determine the output image size that will maintain the width to height ratio of the input image. The output image size is given by the following two formulas:
out_NL = in_NL * sqrt (number_selected_pixels / number_input_pixels) out_NS = number_selected_pixels / out_NLIn most cases, these calculations will result in a real number of samples that is rounded up to the next integer. As a result of rounding, the last output image line will contain both image data and fill. In a few rare cases, image size will not have to be rounded up and the last output image line will consequently contain no fill.
If MASKVAL=NULL and SAMPERC=100, then IN will be copied to OUT without change. It would be more efficient to simply run COPY in these cases.
MASKBAND is greater than the number of input bands; the user has specified an image band which does not exist.
An invalid value was entered. See User Note 2 for the format of valid values for MASKVAL.
A fatal error was encountered. The message displayed preceding this message was the error encountered. Processing terminates.
Data ranges (as in 4:99) can be given for MASKVAL. The minimum value must precede the maximum value for a data range. It would be an error, for example, to set MASKVAL=99:4.
An error occurred attempting to dynamically allocate memory. Rerun, and if the error persists, contact the system administrator.
Under certain conditions RANDSEL will not select any input pixels and no output image will therefore be created. These conditions are: the input image is all masked data; the input image and SAMPERC are both small.
The program had an internal error while calculating the size of the output image. Contact system support.
The program had an error while determining the system time. Rerun, and if the error persists, contact system support.
The image components specified for IN must all have the same numbers of lines and samples.
Random processes produce random results. Therefore, the percentage of pixels selected usually varies from the desired percentage (SAMPERC). For small images (100 pixels square), the variation from desired percentage can be 0.2%. As the image size increases, the variation approaches zero. For an image 10,000 pixels square, variation is on the order of 0.003%.