You are on page 1of 15

Name:-Yogesh Pandit

Registration No:-18BCE2417
There are numerous image file types out there so it can be hard to know which file type best suits your image
needs. Some image types such a TIFF are great for printing while others, like JPG or PNG, are best for web
graphics.
The list below outlines some of the more common file types and provides a brief description, how the file is best
used, and any special attributes the file may have.

TIFF (.tif, .tiff)


TIFF or Tagged Image File Format are lossless images files meaning that they do not need to compress or lose
any image quality or information (although there are options for compression), allowing for very high-quality
images but also larger file sizes.
Compression: Lossless - no compression. Very high-quality images.
Best For: High quality prints, professional publications, archival copies
Special Attributes: Can save transparencies
Learn more about TIFF file types

Bitmap (.bmp)
BMP or Bitmap Image File is a format developed by Microsoft for Windows. There is no compression or
information loss with BMP files which allow images to have very high quality, but also very large file sizes. Due
to BMP being a proprietary format, it is generally recommended to use TIFF files.
Compression: None
Best For: High quality scans, archival copies
Learn more about BMP file types

JPEG (.jpg, .jpeg)


JPEG, which stands for Joint Photographic Experts Groups is a “lossy” format meaning that the image is
compressed to make a smaller file. The compression does create a loss in quality but this loss is generally not
noticeable. JPEG files are very common on the Internet and JPEG is a popular format for digital cameras -
making it ideal for web use and non-professional prints.

Compression: Lossy - some file information is compressed or lost


Best For: Web Images, Non-Professional Printing, E-Mail, Powerpoint
Special Attributes: Can choose amount of compression when saving in image editing programs like Adobe
Photoshop or GIMP.
Learn more about JPEG file types

GIF (.gif)
GIF or Graphics Interchange Format files are widely used for web graphics, because they are limited to only
256 colors, can allow for transparency, and can be animated. GIF files are typically small is size and are very
portable.
Compression: Lossless - compression without loss of quality
Best For: Web Images
Special Attributes: Can be Animated, Can Save Transparency
Learn more about GIF file types

PNG (.png)
PNG or Portable Network Graphics files are a lossless image format originally designed to improve upon and
replace the gif format. PNG files are able to handle up to 16 million colors, unlike the 256 colors supported by
GIF.
Compression: Lossless - compression without loss of quality
Best For: Web Images
Special Attributes: Save Transparency
Learn more about PNG file types

EPS (.eps)
An EPS or Encapsulated PostScript file is a common vector file type. EPS files can be opened in many
illustration applications such as Adobe Illustrator or CorelDRAW.
Compression: None - uses vector information
Best For: Vector artwork, illustrations
Special Attributes: Saves vector information
Learn more about EPS file types

RAW Image Files (.raw, .cr2, .nef, .orf, .sr2, and more)
RAW images are images that are unprocessed that have been created by a camera or scanner. Many digital
SLR cameras can shoot in RAW, whether it be a .raw, .cr2, or .nef. These RAW images are the equivalent of a
digital negative, meaning that they hold a lot of image information, but still need to be processed in an editor
such as Adobe Photoshop or Lightroom.
Compression: None
Best For: Photography
Special Attributes: Saves metadata, unprocessed, lots of inform
Consider your own recent photo as an input image.
a. Convert input image into gray-scale image.
Code:
import cv2
image = cv2.imread( " Yogesh 21.jpg)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow("Original image", image)
cv2.imshow("Gray image", gray) cv2.waitKey(0) cv2.destroyAllWindows()
Original Image

Grayscale Image
2. Apply the following intensity transformation functions on the input image.
i. Photographic negative.
Code:
import cv2
img = cv2.imread("Yogesh 21.jpg")
cv2.imshow("Original", img) img_not = cv2.bitwise_not(img)
cv2.imshow("PhotoNegative", img_not) cv2.waitKey(0)
cv2.destroyAllWindows()

Original Image
Photographic Negativity

ii. Gamma transformation for gamma = x and 0.y Where, x and y are two least nonzero
digits in your register number. [For eg. 19BCE0287: x=1 and y=2 ; so gamma = 1 and
0.2]
Code:-
import cv2
import numpy as np # Open the image.
img = cv2.imread("Yogesh 21.jpg")
# x = 1, y=2 so 1 and 0.2 are used for gamma in [0.2, 1.0]:
# Apply gamma correction. gamma_corrected = np.array(255 * (img / 255) ** gamma,
dtype="uint8")
# Save edited images. cv2.imwrite("gamma_transformed" + str(gamma) + ".jpg",
gamma_corrected)
Output: Original Image: Same As before After
Transformation: Gamma = 0.2

Output: Original Image: Same As before After


Transformation: Gamma = 1.0
iii. Logarithmic transformation for c =x and y Where, x and y are the
smallest and largest nonzero digits among last for digits in your
register number. [For eg. 19BCE0287: x=2 and y=8 ;
Code:
import
cv2
import
math
import
numpy as
np

def logTransform(c, img): h, w =


img.shape[0], img.shape[1] new_img =
np.zeros((h, w)) for i in range(h):
for j in range(w): new_img[i, j] = c
* (math.log(1.0 + img[i, j]))

new_img = cv2.normalize(new_img, new_img, 0, 255,

cv2.NORM_MINMAX) return new_img

# replace as your
image path img =
cv2.imread(
r"C:\\Users\\Saugat\\Desktop\\Semester 5\\Image
processing\\Theory\\Assignment\\Notebook\\ Saugat.jpg",
0,
)

log_img = logTransform(2.0, img) // Only this value need to be


changed cv2.imshow("log_img", log_img) cv2.imwrite(
r"C:\\Users\\Saugat\\Desktop\\Semester 5\\Image
processing\\Theory\\Assignment\\Notebook\\
)
cv2.waitKey(0)
NOTE:-

For both values c = 2.0 and 4.0 the code is same and only the values passed to the
function as highlighted above needs to be changed.

For c=2

For c=4
Apply average filtering (3X3 filter) with following two boundary options
Code: import cv2

# path path = r"Saugat_1.jpg"

# Reading an image in default mode image = cv2.imread(path)

# Window name in which image is displayed window_name = "Image"

# ksize ksize = (30, 30)

# Using cv2.blur() method image = cv2.blur(


image, ksize, cv2.BORDER_DEFAULT //Here Border_Default provides zero padding ) # The
Border_Default provides zero padding

# Displaying the image cv2.imshow(window_name, image)

cv2.waitKey(0) cv2.destroyAllWindows()
i. Zero padding

ii. Replicate
d. Apply any smoothening filter on spatial domain
# Low Pass Spatial Domain Filtering # to observe the blurring effect

import cv2 import numpy as np

# Read the image img = cv2.imread("Saugat_1.jpg", 0)

# Obtain number of rows and columns


# of the image m, n = img.shape

# Develop Averaging filter(3, 3) mask mask = np.ones([3, 3], dtype=int) mask = mask / 9

# Convolve the 3X3 mask over the image img_new = np.zeros([m, n])

for i in range(1, m - 1): for j in range(1, n - 1): temp = ( img[i - 1, j - 1] * mask[0,


0] + img[i - 1, j] * mask[0, 1]
+ img[i - 1, j + 1] * mask[0, 2]
+ img[i, j - 1] * mask[1, 0]
+ img[i, j] * mask[1, 1]
+ img[i, j + 1] * mask[1, 2]
+ img[i + 1, j - 1] * mask[2, 0]
+ img[i + 1, j] * mask[2, 1]
+ img[i + 1, j + 1] * mask[2, 2]
)

img_new[i, j] = temp

img_new = img_new.astype(np.uint8) cv2.imwrite("Saugat_Smoothed_image.jpg", img_new)


e. Apply the following filters on the image and find the difference.
i. Sobel filter
Original Image
Soble x

Soble y
Total Soble

Perwitt:
Perwitt x

You might also like