Matlab Program For Contrast Stretching
Histogram Equalization
The process of adjusting intensity values can be done automatically using histogram equalization. Histogram equalization involves transforming the intensity values so that the histogram of the output image approximately matches a specified histogram. By default, the histogram equalization function, histeq
, tries to match a flat histogram with 64 bins, but you can specify a different histogram instead.
Notice how this curve reflects the histograms in the previous figure, with the input values mostly between 0.3 and 0.6, while the output values are distributed evenly between 0 and 1.
Jan 08, 2013 Contrast Stretching increases the dynamic range of the grey level in the image being processed. Points (r1, s1) and (r2, s2) control the shape of the transformation. The selection of control points depends upon the types of image and varies from one image to another image. Digital Image Processing using matlab.
Adjust Intensity Values Using Histogram Equalization
This example shows how to use histogram equalization to adjust the contrast of a grayscale image. The original image has low contrast, with most pixel values in the middle of the intensity range. histeq
produces an output image with pixel values evenly distributed throughout the range.
Read an image into the workspace.
Display the image and its histogram.
Adjust the contrast using histogram equalization. In this example, the histogram equalization function, histeq
, tries to match a flat histogram with 64 bins, which is the default behavior. You can specify a different histogram instead.
Display the contrast-adjusted image and its new histogram.
ZEMAX ® Optical Design Program User's Manual July 8, 2011 Radiant ZEMAX LLC support@zemax.com www.zemax.com. You can use to learn ZEMAX. In particular, the User's Manual is a detailed reference on all aspects of ZEMAX. It is supplied in PDF format and is found in ZEMAX by clicking on HelpKManual. This guide refers to the various chapters and sections of the manual as it goes along, as well as to some of the many sample files distributed along with ZEMAX. Zemax manual 2012. Zemax ® 12 Optical Design Program User's Manual July 10, 2012 Radiant Zemax LLC support@zemax.com www.zemax.com. Zemax provides you with a link to activate and log in to your OpticStudio Online account. The activation page includes a link to the services agreement, which you must read before you continue. Activating your online account acknowledges that you have read and agreed to these terms and conditions.
Plot Transformation Curve for Histogram Equalization
This example shows how to plot the transformation curve for histogram equalization. histeq
can return a 1-by-256 vector that shows, for each possible input value, the resulting output value. (The values in this vector are in the range [0,1], regardless of the class of the input image.) You can plot this data to get the transformation curve.
Read image into the workspace.
Hard reset anne pro 2. Adjust the contrast using histogram equalization, using the histeq
function. Specify the gray scale transformation return value, T
, which is a vector that maps graylevels in the intensity image I
to gray levels in J
.
Plot the transformation curve. Notice how this curve reflects the histograms in the previous figure, with the input values mostly between 0.3 and 0.6, while the output values are distributed evenly between 0 and 1.
Tips
The Adjust Contrast tool presents a scaled histogram of pixel values (overly represented pixel values are truncated for clarity). Dragging on the left red bar in the histogram display changes the minimum value. The minimum value, and any pixel value less than the minimum, display as black. Dragging on the right red bar in the histogram changes the maximum value. The maximum value, and any value greater than the maximum, display as white. Values in between the red bars display as intermediate shades of gray.
Together the minimum and maximum values create a 'window'. Stretching the window reduces contrast. Shrinking the window increases contrast. Changing the center of the window changes the brightness of the image. It is possible to manually enter the minimum, maximum, width, and center values for the window. Changing one value automatically updates the other values and the image.
Click and drag the mouse within the target image to interactively change the window values. Dragging the mouse horizontally from left to right changes the window width (i.e., contrast). Dragging the mouse vertically up and down changes the window center (i.e., brightness). Holding down the Ctrl key before clicking and dragging the mouse accelerates the rate of change; holding down the Shift key before clicking and dragging the mouse slows the rate of change. Keys must be pressed before clicking and dragging.
When you use the tool,
imcontrast
adjusts the contrast of the displayed image by modifying the axesCLim
property. To modify the actual pixel values in the target image, click the button. This button is unavailable until you make a change to the contrast of the image.The Adjust Contrast tool can handle grayscale images of class
double
andsingle
with data ranges beyond the default display range, which is [0
1
]. For these images,imcontrast
sets the histogram limits to fit the image data range, with padding at the upper and lower bounds.