What Is the Image Processing Toolbox?
The Image Processing Toolbox is a collection of functions that extend the capability of the MATLAB® numeric computing environment. The toolbox supports a wide range of image processing operations, including:
- Spatial image transformations
- Morphological operations
- Neighborhood and block operations
- Linear filtering and filter design
- Transforms
- Image analysis and enhancement
- Image registration
- Deblurring
- Region of interest operations
Clear the MATLAB workspace of any variables and close open figure windows.
imread
command. Let's read in a TIFF image named pout.tif
(which is one of the sample
images that is supplied with the Image Processing Toolbox), and store it in an
array named I
.imshow
to display I
.Enter the
whos
command to see how I
is
stored in memory.MATLAB responds with
Perform Histogram Equalization
As you can see,
pout.tif
is a somewhat low contrast image. To see the distribution of intensities in pout.tif
in its current state, you can
create a histogram by calling the imhist
function. (Precede the call to imhist
with the figure
command so
that the histogram does not overwrite the display of the image I
in the current figure window.)
·
·
Notice how the intensity range is rather narrow. It does
not cover the potential range of [0, 255], and is missing the high and low
values that would result in good contrast.Now call
histeq
to spread the intensity values over the full range, thereby improving the
contrast of I
. Return the
modified image in the variable I2
.I2
, in a new figure window.
·
·
Call imhist
again, this time for I2
.
·
·
See how the pixel values now extend across the full range
of possible values.Write the Image
Write the newly adjusted image
I2
back to disk. Let's say you'd like to
save it as a PNG file. Use imwrite
and specify a filename that includes the extension 'png'
.Check the Contents of the Newly Written File
Now, use the
imfinfo
function to see what was written to disk. Be sure not to end the line with a
semicolon so that MATLAB displays the results. Also, be sure to use the same path (if any) as you did for the
call to imwrite
, above.Clear the MATLAB workspace of any variables and close open figure windows. Read and display the intensity image
rice.tif
.
·
·
Use Morphological Opening to Estimate the Background
Notice that the background illumination is brighter in the center of the image than at the bottom. Use the
imopen
function to estimate the background illumination. Use the
surf
command to create a surface display of the background approximation, background
. The surf
function requires data of class double
, however, so you first need to
convert background
using the
double
command. uint8
data and reverses the y-axis of
the display to provide a better view of the data (the pixels at the bottom of
the image appear at the front of the surface plot). Subtract the Background Image from the Original Image
Now subtract the background image,
background
, from the original image, I
, to create a more uniform background.
·
·
Adjust the Image Contrast
The image is now a bit too dark. Use
imadjust
to adjust the contrast.
·
·
Create a new binary thresholded image,
bw
, by using the functions graythresh
and im2bw
.
·
·
Now call the whos
command to see what type of array the thresholded image bw
is.To determine the number of grains of rice in the image, use the
bwlabel
function. This
function labels all of the connected components in the binary image bw
and returns the number of objects it
finds in the image in the output value, numobjects
.- The size of the objects
- The accuracy of your approximated background
- Whether you set the connectivity parameter to 4 or 8
- Whether or not any objects are
touching (in which case they may be labeled as one object) In the example,
some grains of rice are touching, so
bwlabel
treats them as one object.
Examine the Label Matrix
You may find it helpful to take a closer look at
labeled
to see what bwlabel
has created. Use the imcrop
command to select and display
pixels in a region of labeled
that includes an object and some background.To ensure that the output is displayed in the MATLAB window, do not end the line with a semicolon. In addition, choose a small rectangle for this exercise, so that the displayed pixel values don't wrap in the MATLAB command window.
The syntax shown below makes
imcrop
work interactively. Your mouse cursor becomes a
cross-hair when placed over the image. Click at a position in labeled
where you would like to select
the upper left corner of a region. Drag the mouse to create the selection
rectangle, and release the button when you are done. To view a label matrix in this way, use the
label2rgb
function. Using this function,
you can specify the colormap, the background color, and how objects in the
label matrix map to colors in the colormap.
·
·
9. Measure Object Properties in the
ImageThe
regionprops
command measures object or region properties in an image and returns them in a
structure array. When applied to an image with labeled components, it creates
one structure element for each component. Use regionprops
to create a structure array containing some
basic properties for labeled
.Area
field in the 51st element in the graindata
structure array. Note that structure field names are case sensitive, so you
need to capitalize the name as shown.allgrains
,
which holds just the area measurement for each grain, use this code:whos
command to see how MATLAB allocated the allgrains
variable.allgrains
is a one-row array of 80 elements, where each element contains the area measurement
of a grain. Check the area of the 51st element of allgrains
.Compute Statistical Properties of Objects in the Image
Now use MATLAB functions to calculate some statistical properties of the thresholded objects. First use
max
to find the size of the largest grain. (If you have
followed all of the steps in this exercise, the "largest grain" is
actually two grains that are touching and have been labeled as one object).find
command to return the component label of this large-sized grain.
·
www.mathworks.com/products/image/
www.mathtools.net/MATLAB/Image_Processing/
www.amath.colorado.edu/courses/4720/2000Spr/Labs/Worksheets/Matlab_tutorial/matlabimpr.html
www.imageprocessingplace.com/DIPUM/dipum_book_description/book_description.htm
This is a very helpful elaboration for beginners. as a freshers this step by step process is helpful for me.keep updating.
ReplyDelete