18DIP Lab 3
18DIP Lab 3
18DIP Lab 3
“To Write and Execute Image Processing Programs using Point Processing Method”
Objective:
OpenCV
OpenCV is the huge open-source library for computer vision, machine learning, and
image processing and now it plays a major role in real-time operation which is very important in
today’s systems. By using it, one can process images and videos to identify objects, faces, or
even the handwriting of a human.
Point Operation:
Point operations are often used to change the grayscale range and distribution. The
concept of point operation is to map every pixel onto a new image with a predefined
transformation function.
g(x, y) = T(f(x, y))
All the processing done on the pixel values. Point processing operations take the form:
s = T (r)
I. Negative Image:
This is a photographic image of a dull and dark part, as well as the bright areas in the photos.
Plastics and glass, for instance, contain negative material most often. Unlike an ordinary image, a
negative one reflects on light-dark areas in both cases. Similarly, negative color images offer the
choice of altering the areas within them; from cyan, to magenta, toblues, and vice versa.
s = (L-1) – r,
Input Code:
Output:
II. Flip Image:
A flipped image or reversed image, the more formal term, is a static or moving image that is
generated by a mirror-reversal of an original across a horizontal axis. A flopped image is
mirrored across the vertical axis. The syntax for this is:
img.transpose(Image.TRANSPOSE)
Input Code:
Output:
III. Thresholding:
Thresholding is a technique in OpenCV, which is the assignment of pixel values in relation to
the threshold value provided. In thresholding, each pixel value is compared with the threshold
value.If the pixel value is smaller than the threshold, it is set to 0, otherwise, it is set to a
maximum value (generally 255).Thresholding is a very popular segmentation technique, used for
separating an object considered as a foreground from its background. In Computer Vision, this
technique of thresholding is done on grayscale images. So initially, the image must be converted
in grayscale color space. The syntax is:
Input Code:
Output:
Input Code:
Output:
function findNegative(image):
// Assuming the image is in grayscale
return image
Q2: Write down a program for performing Min-Max Stretching of an image
using open CV. Also paste its output.
Q3: Write down the names of simple Thresholding techniques
Simple thresholding techniques in image processing are fundamental for segmenting images
into foreground and background by converting grayscale images into binary images. Here are some of
the common simple thresholding techniques:
• Import the required libraries OpenCV and matplotlib. Make sure you have already installed
them.
• Read the input image using cv2.imread() method. Specify the full path of the image.
• Rotate the input image using cv2.rotate() function. Flipped using the function cv2. flip().
• Display the rotated and flipped image.
Conclusion: