Digital Image Processing
1 Linear Scaling Transformations
The scaling and display of images is an extremely important concept. Typically, display buffers require that images be provided in a specific format. For example, it is pretty common that an image be formatted for the display buffer as an unsigned 8bit number for grayscale images or a 24bit image for color images (8bits per three color channels). The act of mapping a given image from its current units and data format into the display space is called a scaling transformation. Often times we are interested in linear scaling transformations. Shown below are two linear scaling transformations where at left the output is an 8bit unsigned integer and at right the output is a floatingpoint number in the range of [0, 1].
In each case, notice that a range [αl, αh] is specified to indicate the region where linear scaling should be applied with values outside of this range being saturated, i.e.,
Notice that in the transformation above, the output image will be in the range of [0, 1].
The imshow() function in MATLAB will display images in a number of formats (see the function documentation for details). When an image’s data format is single or double precision, imshow() expects the range of the image to be [0, 1]. When an image’s data format is an unsigned integer of bit depth n, imshow() expects the range of the image to be [0, 2n − 1]. There are a number of linear scaling transformations that are useful. Here, we are going to focus on three methods: MaxMin Scaling, Statistical Scaling, and Absolute Scaling.
MaxMin Scaling : In this type of scaling, we want to scale the image so that the entire range of the input image maps into the range of [0,1]. Thus, we set and αl = min i[m, n]m,nαh = max i[m, n].m,n
Statistical Scaling: In this type of scaling, we want to scale the image so that the input image’s range of [µ − Aσ, µ + Aσ] maps into the range [0, 1]. Thus, we simply compute the mean and standard deviation (µ, σ) across all pixels in the image. The parameter A controls how many standard deviations about the mean that we want to include in our scaling range, where A is a real number. Hence, we simply set αl = µ − Aσ and αh = µ + Aσ.
Absolute Scaling: In absolute scaling, the scaling range is directly specified by the user such that αl = L and
αh = H, where L and H are in units of the input image’s intensity levels.
2 Assignment
For this assignment, you are going to implement these three linear scaling methods in a MATLAB function (I have included a template for you to use with this assignment). We will adopt the convention that all output images will be in double precision format, and thus all scaled output images should be in the range of [0, 1]. As such, regardless of the input image format, the first step will be to convert the image to double() format. Then, depending upon the number of input parameters to the function, the function will perform a corresponding linear transformation (no parameters for maxmin, one for statistical, and two for absolute). See the function template for additional details.
Testing : Once you have implemented your code, read in each of the three images provided with this assignment. Use the imread() function for reading JPG images. Use the load() command to read in .mat file images. Apply each type of scaling to each image according to the parameters specified below. Then, display each output image (three figures with three subplots per figure) using the imshow() function.
Image 
Scaling Type 
Parameter 1 
Parameter 2 
image1.png 
MaxMin 
– 
– 
Statistical 
A = 10.0 
– 

Absolute 
L = 130 
H = 132 

image2.jpg 
MaxMin 
– 
– 
Statistical 
A = 1.5 
– 

Absolute 
L = 50 
H = 140 

image3.mat 
MaxMin 
– 
– 
Statistical 
A = 1.5 
– 

Absolute 
L = 280.0 
H = 310.0 
image1.png is a graylevel 8bit image with only 4 intensity levels. image2.jpg is a graylevel 8bit image of a landscape photograph taken at the Giant’s Causeway in Northern Ireland. image3.mat is a graylevel doubleprecision infrared image of a daytime scene at LAX airport, calibrated to units of Kelvin.
Submission : Publish the results of your work into a .pdf file (which should include the code and figures) and submit through Isidore.
3 Additional Exploration
If you would like to additionally include functionality for 3channel RGB images, these scalings are typically ap plied across all three color channels (not to each color channel independently). So, MaxMin Scaling would find the minimum and maximum value across all three colors channels, Statistical Scaling would find the mean and standard deviation using all three color channels, and Absolute Scaling would apply the same L and H to all three color channels. If each color channel is treated independently it could result in color casts or shifts in the output image.
If you would like to convert your image to an unsigned nbit integer format, you can simply take the output of your function in double precision format, multiply it by 2n − 1, apply a floor() operation, and then cast it to the appropriate data type. For example, to convert the results to an 8bit unsigned integer format, use the command out8bit = uint8(floor(255 ∗ out));.
Code
function out = imgscale(in,param1,param2)
% out = imgscale(in,[param1],[param2])
%% This function takes an input gray scale image (in) and scales it
% according to one of three possible scaling transformations: maxmin
% scaling, absolute scaling, or statistical scaling.
% MaxMin Scaling: If no parameters are specified, maxmin scaling is
% assumed and min(in)>0 and max(in)>1. All values between min(in) and
% max(in) are linearly scaled between (0,1).
% Statistical Scaling: If one parameter is specified, statistical scaling
% is assumed, where param1 is the specified standard deviation of in.
% Values of in<= mean(in)param1*sdev(in)>0 and
% in>=mean(in)+param1*sdev(in)>1. Values of in in the range of
% (mean(in)param1*sdev(in), mean(in)+param1*sdev(in)) are linearly scaled
% between (0,1).
% Absolute Scaling: If two parameters are specified, absolute scaling is
% assumed and values of in<=param1>0 and in>=param2>1. Values of in
% in the range of (param1,param2) are linearly scaled between (0,1).
% INPUT PARAMETERS:
% in Input image of size MxN
% param1 Either the lower absolute scaling range for absolute scaling or
% the standard deviation for statistical scaling
% param2 The upper absolute scaling range for absolute scaling
% OUTPUT PARAMETERS:
% out Output image of size MxN in double precision format scaled to
% the range of [0,1]
% Note: The output image can easily be transformed to another format if
% desired. For example, if an unsigned 8bit format is desired, simply
% transform out as follows: out2 = uint8(floor(255*out));
[M,N,Z] = size(in);
in = double(in);
%MaxMin Scaling: Set alpha_l = min(in(:)). Set alpha_h = max(in(:));
if(nargin==1)
% Statistical Scaling: Set alpha_l = mean(in(:))param1*std(in(:)).
% Set alpha_h = mean(in(:))+param1*std(in(:)).
elseif(nargin==2)
% Absolute Scaling: Set alpha_l = param1. Set alpha_h = param2.
elseif(nargin==3)
end
%Saturate all values of in < alpha_l = alpha_l
%aturate all values of in > alpha_h = alpha_h
%Linearly scale data in the range of [alpha_l, alpha_h] > [0,1]
DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction  the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction  the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of