Application Center - Maplesoft

App Preview:

Image Tools

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

Image Tools 

? Maplesoft, a division of Waterloo Maple Inc., 2008 

In this application we test the effectiveness of the image processing algorithms, manipulate the pixel intensities, and construct an edge detector using a convolution mask using the image shown. 

 

 

Input Image 

Histogram Manipulation 

Edge Detection 

Image 

Input Image 

To test the effectiveness of the image processing algorithms, we use the following image. To view the image, click the View Image button. To use a different image, click the Load Image button. 

`:=`(img, ToGrayscale(Read(cat(kernelopts(datadir),  

VIEW IMAGELOAD IMAGE 

Image 

Histogram Manipulation 

With the enhancements to the ImageTools package, we can easily manipulate the pixel intensities of the images. Starting with the already loaded image, we can plot the histogram of the pixels. 

 

PlotHistogram(img) 

Plot_2d
 

 

By applying the function to all the pixels in the image, we adjust the histogram of the image. Note that by applying this operator, the pixel intensities no longer fit between 0 and 1. We must therefore also use the FitIntensity command to rescale the pixel intensities to fit between 0 and 1. 

 

`:=`(img1, FitIntensity(map[evalhf](sqrt, img))); -1 

 

VIEW IMAGES 

Click the button above to see the effect of the transformation. The original, as well as the transformed image is shown. 

 

We can plot the histogram of the original image and the modified image. 

 

plots[display](PlotHistogram(img, 80, color = red, legend =
plots[display](PlotHistogram(img, 80, color = red, legend =
plots[display](PlotHistogram(img, 80, color = red, legend =
 

Plot_2d
 

 

Similarly, we can apply the exponential operator. To intensify the effect of the exponential operators, we multiply the pixel intensity by 5 before applying the operator. 

 

`:=`(img2, FitIntensity(map[evalhf](proc (x) options operator, arrow; exp(`+`(`*`(2, `*`(x)))) end proc, img))); -1 

 

VIEW IMAGES 

Click the button above to see the effect of both transformations. The original as well as the two transformed images are shown. 

 

plots[display](PlotHistogram(img, 80, color = red, legend =
plots[display](PlotHistogram(img, 80, color = red, legend =
plots[display](PlotHistogram(img, 80, color = red, legend =
plots[display](PlotHistogram(img, 80, color = red, legend =
 

Plot_2d
 

 

 

We would like to take the image modified by the exponential operator and adjust the histogram so that the occurrence of all intensity levels are equally likely. First, we create a cumulative histogram of the image. 

`:=`(v, c, Histogram(img, 100, normalized, centers, cumulative, autorange)); -1; `:=`(v1, convert(v, list)); -1; `:=`(c1, convert(c, list)); -1; `:=`(lst, zip(proc (x, y) options operator, arrow; [x, ...
`:=`(v, c, Histogram(img, 100, normalized, centers, cumulative, autorange)); -1; `:=`(v1, convert(v, list)); -1; `:=`(c1, convert(c, list)); -1; `:=`(lst, zip(proc (x, y) options operator, arrow; [x, ...
`:=`(v, c, Histogram(img, 100, normalized, centers, cumulative, autorange)); -1; `:=`(v1, convert(v, list)); -1; `:=`(c1, convert(c, list)); -1; `:=`(lst, zip(proc (x, y) options operator, arrow; [x, ...
`:=`(v, c, Histogram(img, 100, normalized, centers, cumulative, autorange)); -1; `:=`(v1, convert(v, list)); -1; `:=`(c1, convert(c, list)); -1; `:=`(lst, zip(proc (x, y) options operator, arrow; [x, ...
`:=`(v, c, Histogram(img, 100, normalized, centers, cumulative, autorange)); -1; `:=`(v1, convert(v, list)); -1; `:=`(c1, convert(c, list)); -1; `:=`(lst, zip(proc (x, y) options operator, arrow; [x, ...
`:=`(v, c, Histogram(img, 100, normalized, centers, cumulative, autorange)); -1; `:=`(v1, convert(v, list)); -1; `:=`(c1, convert(c, list)); -1; `:=`(lst, zip(proc (x, y) options operator, arrow; [x, ...
 

Plot_2d
 

 

 

 

Now we want to use this cumulative histogram as a function that maps the intensity levels. We use the Spline version of the CurveFitting command to build a function from the histogram points. 

 

`:=`(spl, unapply(CurveFitting[Spline](lst, x), x)); -1 

 

Then we apply the function to the image and plot the histogram for both the distorted image and the equalized image. 

 

`:=`(img3, map[evalhf](spl, img)); -1 

plots[display](PlotHistogram(img, color = green, legend =
plots[display](PlotHistogram(img, color = green, legend =
plots[display](PlotHistogram(img, color = green, legend =
 

Plot_2d
 

 

Execute the command below to view the altered image. 

View(img, img3); 1 

VIEW IMAGES 

Click the button above to see the effect of the histogram equalization. 

Edge Detection 

Using a convolution mask, we construct an edge detector. First, we construct a Gaussian mask that will be used to smooth the image and reduce the effect of noise on the edges. Then, using one of several edge masks, we extract the horizontal and vertical edges. These edges are combined and a threshold operation is applied to extract the edges from the image. 

 

The convolution mask parameters can be set with the following controls. 

Surface Plot of the Convolution Mask 

Embedded component 

 

Mask size 

Embedded component 

              INPUT IMAGE               

         SMOOTHED IMAGE           

INPUT AND SMOOTHED IMAGE 

Variance (`*`(`^`(sigma, 2))) 

Embedded component 

 

Select the operator 

Embedded component 

   INPUT IMAGE 

  Robert's Cross 

  EDGE OPERATORS 

  3 x 3 Prewitt 

  HORIZONTAL & VERTICAL EDGES 

  Sobel 

Embedded component 

  THRESHOLD EDGES 

  4 x 4 Prewitt 

   HIGHLIGHT EDGES 

Enable smoothing