MaplePortal/ImageTools - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MaplePortal/ImageTools

ImageTools in Maple

Go to Maple Portal     Maple Portal for Engineers

 

The ImageTools package in Maple contains a large number of image processing functions. Before using the commands found within the ImageTools package, load the package into the workspace using the with command. This enables use of the short form of the command  names.

 

withImageTools:

 

This document below uses a sample image to illustrate how the commands in the ImageTools package work.

 

Extract Input Image

Histogram Manipulation

Smoothing & Edge Detection

See Also

Extract Input Image

 

The image in Figure 1, which is located in Maple's data directory, is imported into the worksheet by using the Read command.

 

Figure 1: Tree image

 

 

 

FileLocationcatkerneloptsdatadir,/images/tree.jpg:

 

TreeImageReadFileLocation

 

Note: Since backslashes are special characters, backslashes used in filenames must be escaped by "doubling up," that is, using two backslashes as was done in defining FileLocation. Alternatively, use the form <Maple>/data/images/tree.jpg, where <Maple> represents the pathway to Maple directory. See backslash and file for more information about backslashes and file names.

 

Use the View command to view the image stored in TreeImage. The image is displayed in a Maplet dialog.

ViewTreeImage

 

The image can be converted into a grayscale image with the ToGreyscale command.

 

TreeImageGrayscaleToGrayscaleTreeImage&colon;

ViewTreeImageGrayscale

Figure 2: Grayscale tree image

 

Histogram Manipulation

 

View histograms of the colored and grayscale images using the PlotHistogram command.

PlotHistogramTreeImage

PlotHistogramTreeImageGrayscale

The following steps show how to manipulate the pixel intensities; the grayscale image is used in this example. Adjust the histogram of the grayscale image by applying the  function to all the pixels in the image. Since this operation will cause the pixel intensities to no longer fit between 0 and 1, the pixel intensities are then rescaled using the FitIntensity command.

sqrtImagemapevalhfsqrt&comma; TreeImageGrayscale&colon; 

SqrtTreeImageGrayscaleFitIntensitysqrtImage

 

In a similar manner, you can intensify the grayscale image by applying an exponential operator.

expImagemapevalhfx&rarr;&ExponentialE;2x&comma;TreeImageGrayscale&colon;

ExpTreeImageGrayscaleFitIntensityexpImage

 

View the images to see the effects of adjusting the histogram.

ViewTreeImageGrayscale&comma;SqrtTreeImageGrayscale&comma;ExpTreeImageGrayscale  

 

Histogram Manipulations

Original Image

Decreased Intensity Image

Increase Intensity Image

 

You can plot the histograms of the original and modified images. The histogram can be normalized using the normalized option to the PlotHistogram command.. See PlotHistogram for information on normalized and other options.

 

plotsdisplayPlotHistogramTreeImageGrayscale&comma; 80&comma; normalized&comma;color&equals;Red&comma;legend&equals;Original Image&comma; PlotHistogramSqrtTreeImageGrayscale&comma; 80&comma; normalized&comma;color&equals;Blue&comma;legend&equals;Sqrt Image&comma;PlotHistogramExpTreeImageGrayscale&comma; 80&comma; normalized&comma; color&equals;Green&comma;legend&equals;Exp Image&comma;thickness&equals;2

Use plots[display] to display multiple plots on the same axes.

Smoothing & Edge Detection

 

An edge detector can be constructed by applying a convolution mask to the image.

 

The Robert's Cross is a typical edge mask that can be used to extract the horizontal and vertical edges of an image. The Robert's Cross mask is defined below.

 

  GxMatrix0&comma;1&comma;1&comma;0&colon;GyMatrix1&comma;0&comma;0&comma;1&colon;

 

Use the Convolution command to obtain the horizontal and vertical edge operators for the image defined in TreeImageGrayscale.

 

RCHorizontalEdgeOperatorConvolutionTreeImageGrayscale&comma; Gx&colon;RCVerticalEdgeOperatorConvolutionTreeImageGrayscale&comma; Gy&colon;

 

Detect the horizontal and vertical edges of the image.

 

HorizontalEdgeDetectionmapevalhfabs&comma; RCHorizontalEdgeOperator&colon; 

VerticalEdgeDetectionmapevalhfabs&comma; RCVerticalEdgeOperator&colon;

TotalEdgeDetectionmapevalhfsqrt&comma; RCHorizontalEdgeOperator2 &plus;RCVerticalEdgeOperator2&colon;

 

View the results of the edge detection.

 

ViewTreeImageGrayscale&comma;FitIntensityTotalEdgeDetection&comma;FitIntensityHorizontalEdgeDetection&comma;FitIntensityVerticalEdgeDetection

 

Horizontal and Vertical Edge Detection

Original Image

Horizontal & Vertical Edge Detection

Horizontal Edge Detection

Vertical Edge Detection

 

Using the Threshold command you can extract the edges that were detected.

 

HorizontalEdgeExtractionThresholdHorizontalEdgeDetection&colon;

 

VerticalEdgeExtractionThresholdVerticalEdgeDetection&colon;

TotalEdgeExtraction  ThresholdTotalEdgeDetection&colon; 

 

The results of the extraction are shown in the plots below.

 

ViewTreeImageGrayscale&comma;TotalEdgeExtraction&comma;HorizontalEdgeExtraction&comma;VerticalEdgeExtraction

Horizontal and Vertical Edge Extraction

Original Image

Horizontal & Vertical Edge Extraction

Horizontal Edge Extraction

Vertical Edge Extraction

 

Another useful feature found in the ImageTools package is the ability to take the color complement of an image using the Complement command. For instance, the complement of the image defined in TotalEdgeExtraction can be seen in the plots below.

 

TotalEdgeExtractionComplimentComplementTotalEdgeExtraction&colon;

ViewTotalEdgeExtraction&comma;TotalEdgeExtractionCompliment 

 

Complement

Edge Extracted Image

Complement of Edge Extracted Image

 

See Also

backslash, cat, file, ImageTools, kernelopts(datadir), map[evalhf]

 

Go to Maple Portal     Maple Portal for Engineers