阅读资料来源:
http://wenku.baidu.com/link?url=4f6YBgJ6QFH-5WrHSiUnnMKjmvuYXtdcfcG6OVn6LdEyTJWgC9E1Mhkzp0WxXKwwENkmZQLAG0lELLq6DNTktKThS6YCsn46kw_biWt49ZC
注:gif、bmp为索引图,jpg、png、tif全彩色
1、
bw1=zeros(100,100); bw1(2:2:98,2:2:98)=1; imshow(bw1); whos bw1;矩阵按照图像来显示的时候,0为黑,非0为白色。
每个元素表示一个像素,如果将现显示的窗口做大化,图形会被放大,1:4(笔者目测);
bw1=zeros(10,10);显示全零矩阵
2、
【例】取反显示二值图像 BW=imread('circles.tif'); imshow(~BW);
BW=imread('circles.tif'); imshow(~BW);%取反显示二值图像3、
imshow(A,jet(256));title('0.0 0.1');jet是一种色系。
输入的图像是灰度级 frayscale
4、
图像格式转换函数P33
(1)dither()
X = dither(RGB, map) % map的取值就是jet、spring、hot…… 输出的是索引图
X = dither(RGB, map, Qm, Qe) %
BW = dither(I) % 输入灰度级图像,输出二值图像
imagesc(I);无损输出 显示图像;
附录:
假设:X8-表示8位的索引图像,X16-表示16位的索引图像,X64-表示双精度的索引图像,则有:
X64=double(X8)+1 -uint8格式转double格式
X64=double(X16)+1 -uint16格式转double格式
X8=uint8(X64-1) -double格式转uint8格式
X16=uint16(X64-1) -double格式转uint16格式
X8=uint8(X16) -uint16格式转uint8格式
X16=uint16(X8) -uint8格式转uint16格式
假设:I8-表示8位的灰度图像,I16-表示16位的灰度图像,I64-表示双精度的灰度图像,则有:
I64=double(I8/255) -uint8格式转double格式
I64=double(I16/65535) -uint16格式转double格式
I8=uint8(round(I64*255)) -double格式转uint8格式
I16=uint16(round(I64*65535)) -double格式转uint16格式
I8=uint8(round(I16/257)) -uint16格式转uint8格式
I16=uint16(round(I8*257)) -uint8格式转uint16格式
假设:RGB8-表示8位的真彩图像,RGB16-表示16位的真彩图像,RGB64-表示双精度的真彩图像,则有:
RGB64=double(RGB8/255) -uint8格式转double格式
RGB64=double(RGB16/65535) -uint16格式转double格式
RGB8=uint8(round(RGB64*255)) -double格式转uint8格式
RGB16=uint16(round(RGB64*65535)) -double格式转uint16格式
RGB8=uint8(round(RGB16/257)) -uint16格式转uint8格式
RGB16=uint16(round(RGB8*257)) -uint8格式转uint16格式
假设BW8表示8位二值图像,BW64表示双精度二值图像,则有:
BW64=double(BW8) uint8格式转double格式
BW8=uint8(BW64)~=0 double格式转uint8格式
plot3(X,Y,Z,'bo')
>> finfo = imfinfo('indornot.jpg');
>> finfo
finfo =
Filename: [1x75 char]
FileModDate: '13-Dec-2014 14:14:36'
FileSize: 31969
Format: 'jpg'
FormatVersion: ''
Width: 559
Height: 598
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
>> finfo = imfinfo('hy2.jpg');finfo
finfo =
Filename: [1x70 char]
FileModDate: '24-Nov-2014 18:25:04'
FileSize: 143980
Format: 'jpg'
FormatVersion: ''
Width: 1024
Height: 768
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
Orientation: 1
XResolution: 72
YResolution: 72
ResolutionUnit: 'Inch'
Software: 'ACD Systems Digital Imaging'
DateTime: '2004:05:02 19:28:58'
YCbCrPositioning: 'Centered'
DigitalCamera: [1x1 struct]
ExifThumbnail: [1x1 struct]
>> finfo = imfinfo('hy2.bmp');finfo
finfo =
Filename: [1x70 char]
FileModDate: '13-Dec-2014 14:19:22'
FileSize: 98366
Format: 'bmp'
FormatVersion: 'Version 3 (Microsoft Windows 3.x)'
Width: 1024
Height: 768
BitDepth: 1
ColorType: 'indexed'
FormatSignature: 'BM'
NumColormapEntries: 2
Colormap: [2x3 double]
RedMask: []
GreenMask: []
BlueMask: []
ImageDataOffset: 62
BitmapHeaderSize: 40
NumPlanes: 1
CompressionType: 'none'
BitmapSize: 98304
HorzResolution: 2835
VertResolution: 2835
NumColorsUsed: 0
NumImportantColors: 0
>> finfo = imfinfo('hy2.png');finfo
finfo =
Filename: [1x70 char]
FileModDate: '13-Dec-2014 14:21:25'
FileSize: 1908235
Format: 'png'
FormatVersion: []
Width: 1024
Height: 768
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: []
Histogram: []
InterlaceType: 'none'
Transparency: 'alpha'
SimpleTransparencyData: []
BackgroundColor: []
RenderingIntent: 'perceptual'
Chromaticities: [0.3127 0.3290 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600]
Gamma: 0.4545
XResolution: 2835
YResolution: 2835
ResolutionUnit: 'meter'
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: '2 May 2004 19:28:58 +0000'
Title: []
Author: []
Description: []
Copyright: []
CreationTime: []
Software: 'ACD Systems Digital Imaging'
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: []
>> finfo = imfinfo('hy2.tif');finfo
finfo =
Filename: [1x70 char]
FileModDate: '13-十二月-2014 14:21:09'
FileSize: 1607734
Format: 'tif'
FormatVersion: []
Width: 1024
Height: 768
BitDepth: 32
ColorType: 'truecolor'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: [8 8 8 8]
Compression: 'LZW'
PhotometricInterpretation: 'RGB'
StripOffsets: [1x256 double]
SamplesPerPixel: 4
RowsPerStrip: 3
StripByteCounts: [1x256 double]
XResolution: 72.0090
YResolution: 72.0090
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [255 255 255 255]
MinSampleValue: [0 0 0 0]
Thresholding: 1
Offset: 1590054
Software: 'ACD Systems Digital Imaging'
DateTime: '2004:05:02 19:28:58'
Predictor: 'Horizontal differencing'
ExtraSamples: 2
YCbCrPositioning: 'Centered'
XMP: [1x2439 char]
DigitalCamera: [1x1 struct]
ExifVersion: [48 50 49 48]
SubsecTime: '970'
ColorSpace: 'Uncalibrated'
CPixelXDimension: 1024
CPixelYDimension: 768
UnknownTags: [7x1 struct]
>> finfo = imfinfo('hy2.gif');finfo
finfo =
Filename: [1x70 char]
FileModDate: '13-Dec-2014 14:20:50'
FileSize: 402899
Format: 'GIF'
FormatVersion: '89a'
Left: 1
Top: 1
Width: 1024
Height: 768
BitDepth: 8
ColorType: 'indexed'
FormatSignature: 'GIF89a'
BackgroundColor: 1
AspectRatio: 0
ColorTable: [256x3 double]
Interlaced: 'no'
DelayTime: 0
TransparentColor: 253
DisposalMethod: 'DoNotspecify'