Download - Image Display
![Page 1: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/1.jpg)
1
Image Display• MATLAB functions for displaying image• Bit Planes• Spatial resolution• Quantization • Dithering
![Page 2: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/2.jpg)
2
MATLAB Functions
• Command: image– display matrix as image– default: use current color map to assign color
• Command: imshow– display uint8 matrix as image– for double matrix, display in the range of [0,1]
![Page 3: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/3.jpg)
3
MATLAB: image Function
• Require mapping to display grayscale images• No mapping required for true color images• Commands to add after image:
– truesize : display one matrix element as one pixel– axis off : turn off axis labelling– colormap(gray(num_color)) : adjust color map
to grayscale– Note: Find the number of gray level by command
size(unique(matrix))
![Page 4: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/4.jpg)
4
Notes on Color Map
• Mapping to fewer color than required.– Result: Brighter image or Darker image
• Mapping to more color than required – Result: Brighter image or Darker image
![Page 5: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/5.jpg)
5
Notes on Color Map
• Mapping to fewer color than required produces brighter image. (pixel whose intensity higher than the defined value assigned the highest value (white))
• Mapping to more color than required produces darker image. (no pixels mapped to white)
• For indexed color image, map to the image’s palette.
![Page 6: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/6.jpg)
6
imshow for Double Matrix
• Range is [0,1] not [0,255].
• How to do it?– imshow(double_matrix/255)
• Vary the brightness of the image:– imshow(double_matrix/value)
• value > 255: darker; value < 255: brighter
![Page 7: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/7.jpg)
7
Conversion: Double to Uint Image
• Manually>> b = double(a);
>> c = b/255;
• Specific command: im2double>> d = im2double(a);
• Note: im2double automatically scale the output to the range of [0,1]
![Page 8: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/8.jpg)
8
Conversion: Double to Uint Image
• Manually>> a = uint8(c * 255);
• Specific command: im2uint8>> a = im2uint8(c);
• Note: im2uint8 automatically scale the input (range [0,1]) to the range of [0,255]
![Page 9: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/9.jpg)
9
Display Binary Image
• Use uint8 data type with logical flag on>> imshow(logical(binary_matrix))
Or
>> imshow(double(binary_matrix))
• For normal grayscale image>> logical_matrix = integer_matrix > threshold
• Conversion: logical to uint8
>> matrix = + matrix
![Page 10: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/10.jpg)
10
Bit Plane
• 8-bit unsigned integer
• Bit plane: binary image whose pixel is the value at the particular bit in the 8-bit unsigned integer
MSB Most Significant Bit PlaneLSB Least Significant Bit Plane
![Page 11: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/11.jpg)
11
Bit Plane: Lena
Bit Plane#0 Bit Plane#1 Bit Plane#2 Bit Plane#3
Bit Plane#4 Bit Plane#5 Bit Plane#6 Bit Plane#7
![Page 12: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/12.jpg)
12
Bit Plane Construction: Example>> c = imread(‘cameraman.tif’);>> cd = double(c);>> c0 = mod(cd,2);>> c1 = mod(floor(cd/2),2);>> c2 = mod(floor(cd/4),2);>> c3 = mod(floor(cd/8),2);>> c4 = mod(floor(cd/16),2);>> c5 = mod(floor(cd/32),2);>> c6 = mod(floor(cd/64),2);>> c7 = mod(floor(cd/128),2);
>>>>>>>>
![Page 13: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/13.jpg)
13
Spatial Resolution
• Density of the pixels over the image
• Higher spatial resolution = more pixels in the image
• Change spatial resolution by imresize command
Syntax: imresize(matrix, scale, method)
imresize(matrix, scale)
method: ‘nearest’ , ‘bilinear’, ‘bicubic’
![Page 14: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/14.jpg)
14
Decrease Spatial Resolution
• E.g. Lower the resolution by half on x and y axis
>> imresize(x,1/2);
![Page 15: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/15.jpg)
15
Increase Spatial Resolution
• E.g. Increase the spatial resolution by two on X and Y axes>> imresize(x,2);
![Page 16: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/16.jpg)
16
Interpolation Example450% Scaled up
Nearest Neighbor
Bilinear
Bicubic
http://www.dpreview.com/learn/?/key=interpolation
![Page 17: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/17.jpg)
17
Quantization
• Digitize the image so that the number of the unique value is within the available range
0
1
2
3
0 1 2 3
![Page 18: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/18.jpg)
18
Uniform QuantizationQuantized value
Input value0
1
2
3
MAX0.75MAX0.5MAX0.25MAX
x
![Page 19: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/19.jpg)
19
Uniform Quantization
Original values Output value 0 - 63 0 64 -127 1 128 -191 2 192 - 255 3
MAX = 255
![Page 20: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/20.jpg)
20
Quantization: Example
2 lev
el
3 level
![Page 21: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/21.jpg)
21
Quantization in MATLAB
• Quantization is simply applying flooring function after division
• Input image matrix = x• Number of output grayscales = n• Quantized output: f = floor(double(x)/n);
![Page 22: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/22.jpg)
22
Quantization in MATLAB: Method 1
Command Number of grayscales
uint8(floor(double(x)/2)*2) 128 uint8(floor(double(x)/4)*4) 64
uint8(floor(double(x)/8)*8) 32
uint8(floor(double(x)/16)*16) 16
uint8(floor(double(x)/32)*32) 8
uint8(floor(double(x)/64)*64) 4
uint8(floor(double(x)/128)*128) 2
![Page 23: Image Display](https://reader036.vdocument.in/reader036/viewer/2022062314/568132aa550346895d99514a/html5/thumbnails/23.jpg)
23
Quantization in MATLAB: Method 2 Command Number of grayscales
imshow(grayslice(x,128),gray(128)) 128 imshow(grayslice(x,64),gray(64)) 64
imshow(grayslice(x,32),gray(32)) 32
imshow(grayslice(x,16),gray(16)) 16
imshow(grayslice(x,8),gray(8)) 8
imshow(grayslice(x,4),gray(4)) 4
imshow(grayslice(x,2),gray(2)) 2
grayslice produces a uint8 version of image x, gray(n) produces a color map of n values.