In: Electrical Engineering
In the MATLAB environment, display an image of a breast
mammogram from the MAMMO database. Apply gray-level scaling,
histogram equalization, and an LOG enhancement mask for image
enhancement as given below. Compare the enhanced images to original
image qualitatively.
LOG enhancement mask to be convolved with the image:
- 1 -1 -1
- 1 9 - 1
-1 -1 -1
MAMMO database:
http://peipa.essex.ac.uk/pix/mias/
Syntax:
[X, map] = gray2ind(I,n)
[X, map] = gray2ind(BW,n)
Description:
[X, map] = gray2ind(I,n) converts the grayscale image I to an indexed image X. n specifies the size of the colormap, gray(n). n must be an integer between 1 and 65536. If nis omitted, it defaults to 64.
[X, map] = gray2ind(BW,n) converts the binary image BW to an indexed image X. n specifies the size of the colormap, gray(n). If n is omitted, it defaults to 2.
gray2ind scales and then rounds the intensity image to produce an equivalent indexed image.
Class Support:
The input image I can be logical, uint8, uint16, int16, single, or double and must be a real and nonsparse. The image I can have any dimension. The class of the output image X is uint8 if the colormap length is less than or equal to 256; otherwise it is uint16.
Examples:
Convert Grayscale Image to Indexed Image
Try This Example
Read grayscale image into the workspace.
I = imread('cameraman.tif');
Convert the image to an indexed image using gray2ind. This example creates an indexed image with 16 indices.
[X, map] = gray2ind(I, 16);
Display the indexed image.
imshow(X, map);
escription
Histograms are a type of bar plot for numeric data that group the data into bins. After you create a Histogram object, you can modify aspects of the histogram by changing its property values. This is particularly useful for quickly modifying the properties of the bins or changing the display.
Creation
Syntax
histogram(X)
histogram(X,nbins)
histogram(X,edges)
histogram('BinEdges',edges,'BinCounts',counts)
histogram(C)
histogram(C,Categories)
histogram('Categories',Categories,'BinCounts',counts)
histogram(___,Name,Value)
histogram(ax,___)
h = histogram(___)
Description
example
histogram(X) creates a histogram plot of X. The histogram function uses an automatic binning algorithm that returns bins with a uniform width, chosen to cover the range of elements in X and reveal the underlying shape of the distribution. histogram displays the bins as rectangles such that the height of each rectangle indicates the number of elements in the bin.
example
histogram(X,nbins) uses a number of bins specified by the scalar, nbins.
example
histogram(X,edges) sorts X into bins with the bin edges specified by the vector, edges. Each bin includes the left edge, but does not include the right edge, except for the last bin which includes both edges.
histogram('BinEdges',edges,'BinCounts',counts) manually specifies bin edges and associated bin counts. histogram plots the specified bin counts and does not do any data binning.
example
histogram(C), where C is a categorical array, plots a histogram with a bar for each category in C.
histogram(C,Categories) plots only the subset of categories specified by Categories.
histogram('Categories',Categories,'BinCounts',counts) manually specifies categories and associated bin counts. histogram plots the specified bin counts and does not do any data binning.
example
histogram(___,Name,Value) specifies additional options with one or more Name,Value pair arguments using any of the previous syntaxes. For example, you can specify 'BinWidth' and a scalar to adjust the width of the bins, or 'Normalization' with a valid option ('count', 'probability', 'countdensity', 'pdf', 'cumcount', or 'cdf') to use a different type of normalization. For a list of properties, see Histogram Properties.
histogram(ax,___) plots into the axes specified by ax instead of into the current axes (gca). The option ax can precede any of the input argument combinations in the previous syntaxes.
example
h = histogram(___) returns a Histogram object. Use this to inspect and adjust the properties of the histogram. For a list of properties, see Histogram Properties.
Input Arguments
expand all
X — Data to distribute among bins
vector | matrix | multidimensional array
C — Categorical data
categorical array
nbins — Number of bins
positive integer
edges — Bin edges
vector
Categories — Categories included in histogram
cell array of character vectors | categorical vector
counts — Bin counts
vector
ax — Target axes
Axes object | PolarAxes object
Name-Value Pair Arguments
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
Example: histogram(X,'BinWidth',5)
The histogram properties listed here are only a subset. For a complete list, see Histogram Properties.
expand all
'BarWidth' — Relative width of categorical bars
0.9 (default) | scalar in range [0,1]
'BinLimits' — Bin limits
two-element vector
'BinLimitsMode' — Selection mode for bin limits
'auto' (default) | 'manual'
'BinMethod' — Binning algorithm
'auto' (default) | 'scott' | 'fd' | 'integers' | 'sturges' | 'sqrt'
| ...
'BinWidth' — Width of bins
scalar
'DisplayOrder' — Category display order
'data' (default) | 'ascend' | 'descend'
'DisplayStyle' — Histogram display style
'bar' (default) | 'stairs'
'EdgeAlpha' — Transparency of histogram bar edges
1 (default) | scalar value between 0 and 1 inclusive
'EdgeColor' — Histogram edge color
[0 0 0] or black (default) | 'none' | 'auto' | RGB triplet or color
name
'FaceAlpha' — Transparency of histogram bars
0.6 (default) | scalar value between 0 and 1 inclusive
'FaceColor' — Histogram bar color
'auto' (default) | 'none' | RGB triplet or color name
'LineStyle' — Line style
'-' (default) | '--' | ':' | '-.' | 'none'
'LineWidth' — Width of bar outlines
0.5 (default) | positive value
'Normalization' — Type of normalization
'count' (default) | 'probability' | 'countdensity' | 'pdf' |
'cumcount' | 'cdf'
'NumDisplayBins' — Number of categories to display
scalar
'Orientation' — Orientation of bars
'vertical' (default) | 'horizontal'
'ShowOthers' — Toggle summary display of data belonging to
undisplayed categories
'off' (default) | 'on'
Plotting Commands Basic xy Plotting Commands axis Sets axis limits. fplot Intelligent plotting of functions. grid Displays gridlines. plot Generates xy plot. print Prints plot or saves plot to a file title Puts text at top of plot. xlabel Adds text label to x-axis. ylabel Adds text label to y-axis. Plot Enhancement Commands axes Creates axes objects. close Closes the current plot. close all Closes all plots. figure Opens a new figure window. gtext Enables label placement by mouse. hold Freezes current plot. legend Legend placement by mouse. refresh Redraws current figure window. set Specifies properties of objects such as axes.