CEE 615: Digital Image Processing Spring 2016 1 LAB 2: Sampling & aliasing; quantization & false contouring A. SAMPLING: Observe the effects of the sampling interval near the resolution limit. The goal of this exercise is to create an image consisting of a periodic feature with known characteristics and to resample that image to explore the effects of sampling near the Nyquist frequency. 1. Create a grid image and rotate. ENVI has a utility for overlaying a grid on an image. We will use this utility to create a grid image a periodic function for use with resampling. The first step is to create a blank image, overlay a grid pattern at any desired grid spacing, and then rotate the image. a. In main menu, select: File > Generate Test Data b. Create a constant image (Figure 1) In the Generate Image Parameters window, create a constant image by setting the parameters as shown in Figure 1. Select: OK c. Display the constant image. The Available Bands List window will have appeared at the end of the last step. Select Load Band to display the image. Even though the gray value is 255, the image will appear black because there is only one gray value. (The default contrast stretch is ineffective.) d. In the image window select: Overlay > Grid Lines e. Set the grid spacing. In the Grid Line Parameters window (Figure 2). Make the number relatively small (e.g., between 5 and 20) to make process simpler. f. Set the grid attributes. In the Grid Line Parameters window, select: Options > Edit Pixel Grid Attributes. Set all attribute colors to white by right-clicking in the color boxes and selecting Items 1-20 > White. Do this for all categories (Labels, Lines, Box, and Corners). Select OK. Apply the grid. g. Remove the borders (these appear in the scroll window). In the Grid Line Parameters window Select: Options > Set Display Borders, change the Image Border Size from 100 to 0. Select OK. Do not close the parameters window. Figure 1: Grid Line Parameters
CEE 615: Digital Image Processing Spring 2016 2 h. i. j. Save the grid image. At this point the grid is just a graphic overlay and is not really an image. Saving the display as an image will create an actual byte (1 byte/pixel) image. In the Full resolution image window select: File > Save Image As > Image File. Set the Resolution to 8-bit (gray scale) and click on the Memory radio button. Click OK. Load the grid image (Gray Scale Band 1) into Display #2. The image in the main image window should appear as a simple white grid on a black pattern and with no white borders. The main image window always shows the image at full resolution. Does it appear to be any different than the overlay in Display #1? Also compare the Zoom display and the Scroll display. Change the size and shape of the scroll window. What's going on? As nearly as possible, make the scroll image the same size as the display image. Is the pattern reproduced accurately? Continue to increase the size of the scroll image until the line pattern is reliably reproduced. Note the scale factor of the scroll image. You may now delete the working copy the image for which the grid is simply an overlay plane. Select the Memory 1 image in the Available bands list, and then select File > Close Selected File. Rotate the 512 x 512 image. (Figure 3) i. In the Main Toolbar, select: Basic Tools > Rotate/Flip Data ii. Select the grid image (should be Memory 2 the label in the file list should match the label on the display window) and click on OK. iii. Set the rotation to any angle (other than 0, 90, 180, or 270) and press return. iv. Select the memory output. (You may name the image, but the image will only be saved until you log off.) v. Select OK vi. Display the rotated image in a new window. Note that the rotated image is larger than the original mosaic. (Click on the gray scale or rotated image Figure 2: Rotation Parameters in the Available bands list. The dimensions of the image will be shown at the bottom of the Available bands list window.) For most rotations, the rotated image will appear rather blocky, especially in the zoom window. The increased size of the frame is needed to accommodate the rotation. The blocky appearance is itself a feature of aliasing. (Use the cursor location/value tool to query the image gray values.) Nearest neighbor resampling uses the exact value of the nearest pixel during the resampling. Since the original values in the grid were either 0 or 255, the rotated image has only those values and appears blocky. If the rotation procedure allowed interpolation (bilinear or cubic convolution) during the resampling, the final image would appear smoother.
CEE 615: Digital Image Processing Spring 2016 3 vii. Adjust the size of the scroll image until the pattern is effectively reproduced (Zoom factor of 1.000). Is the line spacing the same as that when you performed the same operation with the unrotated image? 2. Resample the rotated image. You should now have at least two images in the Available Bands List: 1) an original grid image and one rotated grid image. The next step is to resample these at several different sampling intervals. Be sure to try both oversampling and undersampling. Try to gauge how you might determine when you have clearly undersampled the original. Remember that critical sampling occurs when the sampling interval is exactly ½ the spacing of the periodic feature. If the original grid spacing was one line every 10 pixels, critical sampling would occur if you resample the unrotated image using every 5 th pixel. Resampling using every 4 th pixel would be oversampling and resampling using every 6 th pixel would be undersampling. The resampling procedure is as follows: a. Select: Basic Tools > Resize Data (Spatial/Spectral) b. Select the rotated image. Click on OK. c. In the Resize Data Parameters window, adjust the reduction factors (xfac, yfac): For every original sample 1 Every other sample ½ = 0.5 Every 3 rd sample 1/3 = 0.333 every n th sample 1/n At what point do you feel that the pattern is maintained? At what point do is the pattern lost? Work with this idea and get a feeling for what is happening to this grid image after these simple manipulations. Some of the effects will be more obvious if you recreate the grid image using thicker lines. You may also want to try to resample using bilinear resampling. This uses a weighted average of the nearest pixels during resampling. When you're done, clear the Available Bands List. Select File > Close All Files.
CEE 615: Digital Image Processing Spring 2016 4 B. QUANTIZATION: THE EFFECT OF REDUCING BIT DEPTH One of the major advantages of solid state detectors over film is the capacity to record over large dynamic range with fine radiometric detail and precision. Increasingly, imagery is being collected with 10-14 bit precision. You are presented with a set of data collected by the MERIS satellite from an area in the Pacific Northwest. The data, originally provided at 12-bit precision have been compressed to 8-bits for this exercise. This does not represent a significant overall loss in data quality because the area of interest for this problem is a water region, which is relatively dark and spans a relatively small dynamic range over the whole image. The remainder of the image includes snow and clouds, both very bright targets that require the remainder of the 12-bet radiometric range. The task here is to determine when significant degradation to the imagery occurs as the bit depth is decreased. There are several ways to examine the effect of changing the bit depth: Visual examination: This is best done using a magnified version of the image (Zoom image). The appearance of false contouring is definitive, but speckling in otherwise tonally continuous areas is an early indicator of a problem. Profile: A profile is simply a map of the change in gray value along a path in the image. The detail that is apparent in the "brightness" (the y-axis) is a good indicator of the radiometric quality. In general, if the noise is larger than the smallest radiometric changes (quantization interval) then there will be little or no loss of information. Histogram: Since a histogram is a map of the radiometric (gray value) distribution of the image, it is an excellent indicator of the radiometric quality. The "original" image is provided. Your task is to sequentially degrade the image radiometrically until you can demonstrate that there has been significant information loss by using one or more of the above methods. A complete set of the data for the original image is attached. 1. Download the test image a. Double click on the MERIS_400_560nm image from the Labs page on the course web site: ceeserver.cee.cornell.edu/wdp2/cee6150. b. Save the image to the desktop on your machine. Note: When downloading the files Windows may try to add a ".txt" extension. This will render the file invisible to ENVI. If you cannot avoid saving the file without an extra extension you will need to remove the extension by changing the file name in Windows before ENVI will be able to find it. c. Repeat for the header file. 2. Original image a. Display the original image. b. Use the profile tool to generate a profile that passes through an area in the water that is of interest. In the image window, select: Tools > Profile > x-profile c. Generate the histogram of the image. In the image window, select: Enhance > Interactive Stretching. You can tell that the image has been stretched because this is byte data (256 gray values) and any stretch will leave gaps in the histogram. Another telltale is that stretches move very low values to zero and very high values to 255 resulting in spikes in the distribution at 0 and 255. This is not definitive since the original image may have been saturated (lots of pixels at 255), or viewing areas darker than it was designed for (lots of pixels at 0) or both.
CEE 615: Digital Image Processing Spring 2016 5 3. Degrade the image by 1 bit. a. In the main menu, select: Basic Tools > Band Math b. In the "Enter an expression" box of the Band Math dialog, enter: 2 * Byte (b1 / 2). Select OK. Here, b1 is a variable that refers to the original image. Every gray value in the image will be divided by 2. The result is then converted to integer values using the Byte command. Finally, the overall range is restored by multiplying the result by 2. c. Assign the variable B1 to Band 1 of the MERIS image, name the image "MERIS 7-bit" and then select OK. 4. Display the results in a new display. 5. Link the images. Select Tools > Link > Link displays. Set the toggle switch on (Yes) for the two displays, and click OK. Can you find differences in the x-profile? In the histogram? Can you explain them? 6. Degrade the image further: Repeat the procedure in steps 3, 4, & 5, still operating on the original image, using the expressions: 4* Byte (b1/ 4), 8*Byte (b1/8), 16*Byte (b1/16), etc. Each steps degrades the image by 1 bit (an additional factor of 2). Repeat until you are able to demonstrate definitively that there has been a loss of information in the image. At each step examine the x-profile and the histogram. Create a document to show the results (This is for practice with pasting images and graphs into a WORD document. Nothing need be turned in.) To paste data into a WORD document, follow this procedure (there are other ways to do this, but this will work on any of the computers in the ACCEL facility without requiring any other software): 1. Select the appropriate image window. 2. Hold down the Alt key and press Prnt Scrn. This will copy the selected window into a buffer. 3. Click on the position in the WORD document that you want the image to appear and press Ctrl V. 4. Adjust the size of the image by right-clicking in the image in the WORD document, and selecting Format Picture. In the Format Picture dialog select the "size" tab and adjust the horizontal or vertical size. Setting one dimension is sufficient. The image scale is fixed and the 2 nd dimension is adjusted to match the first. The sizes that I used for the each of the images was: height width Image: 4 Zoom 3" Profile 2.5 histogram 2.5 It will be easiest to view and describe the effects if you group all of the different quantization examples together on a single page, i.e., group all of the histograms for different quantizations together on one page.
CEE 615: Digital Image Processing Spring 2016 6 Original 8-bit Image (256 gray values)