Remarks
Welcome to Section 1 of Introduction to Image Processing.
This section provides an overview of the field of image processing and some examples of things that are covered in this course.
Importing Images
The first step in almost any image processing task is getting the images into the computer or importing the images into the software that will be used for the processing.
One way of doing that is to connect the computer and the software to a camera.
This shows the CurrentImage function in the Wolfram Language™, which captures an image from a camera connected to this computer and imports the image into this Wolfram Language session:
CurrentImage[]

You can also import images from files on your computer or from the internet.
For example, this imports a JPEG image from a file on the internet. JPEG is one of the dozens of common image formats:
❤
img = Import[ "https://cdn.pixabay.com/photo/2017/12/09/08/18/pizza-3007395_1280.\
jpg", ImageSize -> 640]

Images can also be generated by the computer.
For example, this uses the Image function to create an image from a table of numbers:
❤
Image[Abs@Table[Sin[.1 x y], {x, 1, 200}, {y, 1, 500}]]
Images can also be created from things displayed on the computer screen.
For example, this displays a plot and then uses the Rasterize function to convert that display to an image:
❤
Plot[Tan[x], {x, -1, 1}, PlotStyle -> Black]
❤
Rasterize[%, Background -> Yellow]
The image can then be edited or modified like any other image:
Adjusting Brightness and Contrast
After an image has been imported, there are a variety of things that can be done to modify the image, either for aesthetic reasons or to prepare the image for further analysis.
For example, this shows a
Manipulate result with controls for modifying the brightness and contrast in an image:
Operations for adjusting brightness and contrast are discussed in Sections 2 and 3.
Histogram Operations
Contrast and brightness adjustment work by changing the image histogram, which is the distribution of colours and intensities in an image:
There are several common operations that involve other modifications of the image histogram.
For example, this shows an operation called colour transfer or histogram matching, which modifies the distribution of colours in one image to match the distribution of colours in another image:
Histogram matching and some related operations are discussed in Section 4.
Geometric Operations
Another group of basic image operations includes geometric operations like cropping, rotating and resizing an image.
For example, this shows a cropped and rotated version of the sample image created using the ImageRotate and ImageTrim functions:
Here is a Manipulate result that shows these geometric operations with sliders to control the amount of cropping, resizing and rotating:
Manipulate[
Image[ImageTrim[
ImagePerspectiveTransformation[img,
RotationTransform[\[Theta] Degree, ImageDimensions[img]/2],
DataRange -> Full], {pt - r, pt + r}, r, Padding -> Gray],
ImageSize -> 200], {{pt, ImageDimensions[img]/2}, {0, 0},
ImageDimensions[img]}, {{r, 100}, 25, 200}, {\[Theta], 0, 360},
ControlPlacement -> Left]
Basic geometric operations are covered in Section 8.
Segmentation
A key step in many image processing tasks is image segmentation, which means separating out different parts of the image.
There are many methods of segmentation. This shows segmentation using the Binarize function, which separates the image into two segments based on brightness.
The segmentation is represented here by a black-and white-image, with the bright segment identified by the white parts of that result and the darker segment identified by the black parts:
Binarize[img]
image segmentation is introduced in Section 5.
Once the image has been segmented, many things can be done with it.
For example, this picks out the biggest components in that segmentation, which in this example are the slices of pizza:
This input uses the ComponentMeasurements function to count the number of pieces in that segmentation and gives the size of each piece:
ComponentMeasurements[%, "Count"]
Out=
That example also introduces an area of image processing called image analysis, where the idea is to get information from the image instead of just modifying the image to get another image.
Selective Coloring
An image segment can also be used as a mask to provide a way to do things to selected parts of an image.
For example, this shows a segmentation that separates the pizza from everything else in the image:
mask = SelectComponents[
Binarize[img, .19], #Count > 5000 && #AdjacentBorderCount == 0 &,
CornerNeighbors -> False]
Out=
This uses that segment as a mask to remove the colour from everything other than the masked part of the image, so the background becomes black and white and the pizza remains in colour:
There are many other things that can be done in colour.
Here is an input that uses the ColorDistance function to segment the image based on similarity to the colour green, which identifies the green things on the pizza:
These operations and some basic colour theory are discussed in Section 6.
Clustering
Another method of segmentation is called clustering, which works by grouping similar colours in an image.
This shows segmentation by clustering used to separate the sample image into five segments. The Colorize function is used here to display each segment in a contrasting colour:
Segmentation by clustering is discussed in Section 7.
Image Enhancement
Another broad area of image processing is an image enhancement, which includes tools for reducing noise in images or repairing defects in images.
For example, here is a noisy version of the sample image:
This input shows smoothing out the noise using a Gaussian filter:
There are many other methods of noise reduction. This shows a method called a mean shift filter that does a slightly better job of preserving sharp edges in the image:
Image defects can also be corrected using a method called inpainting, which works by filling in defects using colours and textures from the surrounding parts of the image.
For inpainting, the part of the image that is to be filled in is identified by a mask.
This shows inpainting used with a mask that identifies everything other than the pizza as the part of the image to be filled in, which basically removes the background:
With a few adjustments, the background can also be filled in with more pizza:
Tools for noise reduction and other image enhancements are discussed in Section 9.
CurrentImage[]
CurrentImage[]
CurrentImage[]
manipulate:
English - Sinhala