Download presentation
Presentation is loading. Please wait.
1
Computer Application in Engineering Design
Lecture No 04 Engr. Aamir Arsalan
2
Image and digital images
A digital image differs from a photo in that the values are all discrete. • Usually they take on only integer values. • A digital image can be considered as a large array of discrete dots, each of which has a brightness associated with it. These dots are called picture elements, or more simply pixels. • The pixels surrounding a given pixel constitute its neighborhood A neighborhood can be characterized by its shape in the same way as a matrix: we can speak of a 3x3 neighborhood, or of a 5x7 neighborhood.
3
Pixel neighbourhood
4
Aspects of image processing
Image Enhancement: Processing an image so that the result is more suitable for a particular application. (sharpening or deblurring an out of focus image, highlighting edges, improving image contrast, or brightening an image, removing noise). Image Restoration: This may be considered as reversing the damage done to an image by a known cause. (removing of blur caused by linear motion, removal of optical distortions). Image Segmentation: This involves subdividing an image intoconstituent parts, or isolating certain aspects of an image.(finding lines, circles, or particular shapes in an image, in an aerial photograph, identifying cars, trees, buildings, or roads.
5
Types of digital image Binary: Each pixel is just black or white. Since there are only two possible values for each pixel (0,1), we only need one bit per pixel. Grayscale: Each pixel is a shade of gray, normally from 0 (black) to 255 (white). This range means that each pixel can be represented by eight bits, or exactly one byte. Other greyscale ranges are used, but generally they are a power of 2. True Color, or RGB: Each pixel has a particular color; that color is described by the amount of red, green and blue in it. If each of these components has a range 0–255, this gives a total of 2563 different possible colors. Such an image is a “stack” of three matrices; representing the red, green and blue values for each pixel. This means that for every pixel there correspond 3 values.
6
Binary Image
7
Greyscale Image
8
Color Image
9
General commands imread: Read an image
figure: creates a figure on the screen. imshow(g): which displays the matrix g as an image. impixel(i,j): the command returns the value of the pixel (i,j) iminfo: Information about the image.
10
Data types
11
Image Information
12
Converting between different
data type gray2ind - intensity image to index image im2bw - image to binary im2double - image to double precision im2uint8 - image to 8-bit unsigned integers im2uint16 - image to 16-bit unsigned integers ind2gray - indexed image to intensity image mat2gray - matrix to intensity image rgb2gray - RGB image to grayscale rgb2ind - RGB image to indexed image
13
Spatial Resolution Spatial resolution is the density of pixels over the image: the greater the spatial resolution, the more pixels are used to display the image. Halve the size of the image: It does this by taking out every other row and every other column, thus leaving only those matrix elements whose row and column indices are even. Double the size of the image: all the pixels are repeated to produce an image with the same size as the original, but with half the resolution in each direction.
14
Arithmetic operations
Point Processing: Arithmetic operations These operations act by applying a simple function y=f(x) to each gray value in the image. Simple functions include adding or subtract a constant value to each pixel: y = x±C (imadd, imsubtract) Multiplying each pixel by a constant: y = C·x (immultiply, imdivide) Complement: For a grayscale image is its photographic negative.
15
Arithmetic operations:
Addition, subtraction
16
Arithmetic operations: Multiplication, division
17
Complement
18
Addition Image: I Image: I+50
19
Subtraction Image: I Image: I-80
20
Multiplication Image: I Image: I*3
21
Division Image: I Image: I/2
22
Complement Image: I Image: 255-I
23
What is the Image Processing Toolbox?
The Image Processing Toolbox is a collection of functions that extend the capabilities of the MATLAB’s numeric computing environment. The toolbox supports a wide range of image processing operations, including: Geometric operations Neighborhood and block operations Linear filtering and filter design Transforms Image analysis and enhancement Binary image operations Region of interest operations 23
24
Images in MATLAB MATLAB can import/export several image formats:
BMP (Microsoft Windows Bitmap) GIF (Graphics Interchange Files) HDF (Hierarchical Data Format) JPEG (Joint Photographic Experts Group) PCX (Paintbrush) PNG (Portable Network Graphics) TIFF (Tagged Image File Format) XWD (X Window Dump) raw-data and other types of image data Data types in MATLAB Double (64-bit double-precision floating point) Single (32-bit single-precision floating point) Int32 (32-bit signed integer) Int16 (16-bit signed integer) Int8 (8-bit signed integer) Uint32 (32-bit unsigned integer) Uint16 (16-bit unsigned integer) Uint8 (8-bit unsigned integer) 24
25
Images in MATLAB • Binary images : {0,1}
• Intensity images : [0,1] or uint8, double etc. • RGB images : m × n × 3 • Multidimensional images: m × n × p (p is the number of layers) 25
26
Image Import and Export
Read and write images in Matlab img = imread('apple.jpg'); dim = size(img); figure; imshow(img); imwrite(img, 'output.bmp'); Alternatives to imshow imagesc(I) imtool(I) image(I) The imagesc function scales image data to the full range of the current colormap and displays the image. imtool opens a new Image Tool in an empty state. imtool(I) displays the grayscale image I. image(C) displays matrix C as an image. 26
27
Images and Matrices How to build a matrix (or image)? Intensity Image:
[0, 0] How to build a matrix (or image)? Intensity Image: row = 256; col = 256; img = zeros(row, col); img(100:105, :) = 0.5; img(:, 100:105) = 1; figure; imshow(img); o Row 1 to 256 o Column 1 to 256 [256, 256] 27
28
Images and Matrices Binary Image: row = 256; col = 256;
img = rand(row, col); img = round(img); figure; imshow(img);
29
Image Conversion gray2ind - intensity image to index image
im2bw - image to binary im2double - image to double precision im2uint8 - image to 8-bit unsigned integers im2uint16 - image to 16-bit unsigned integers ind2gray - indexed image to intensity image mat2gray - matrix to intensity image rgb2gray - RGB image to grayscale rgb2ind - RGB image to indexed image 29
30
Image Operations RGB image to gray image Image resize Image crop
Image rotate Image histogram Image histogram equalization Image DCT/IDCT Convolution 30
31
Questions??
32
Thank You!!!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.