Convert 4-band indexed image to digital numbers
Show older comments
Hi All,
I have a 4-band image (including Red,Green,Blue and NIR bands) and would like to access each band of the image with the digital numbers to be within 0-255. The problem is that each band of the image is an indexed image so when I use ind2gray (g1=ind2gray(RGBN(:,:,1),gray)), the values all become 65535 for g1, which isn't obviously correct. If I use g1=ind2rgb(RGBN(:,:,1),gray)), then g1 become an RGB image alone which isn't what I want. Indeed, each band is a single intensity image and the combination of bands (like R G and B) will become true-color image.
Does anybody know how I can access each band and change its values to be within 0-255? Here is some info about the image using imfinfo command:
info =
Filename: RGBN
FileModDate: '25-Jun-2014 16:06:39'
FileSize: 31712267
Format: 'tif'
FormatVersion: []
Width: 1796
Height: 1654
BitDepth: 64
ColorType: 'grayscale'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: [16 16 16 16]
Compression: 'LZW'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: []
SamplesPerPixel: 4
RowsPerStrip: 4.2950e+09
StripByteCounts: []
XResolution: []
YResolution: []
ResolutionUnit: 'None'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: 128
TileLength: 128
TileOffsets: [195x1 double]
TileByteCounts: [195x1 double]
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [65535 65535 65535 65535]
MinSampleValue: [0 0 0 0]
Thresholding: 1
Offset: 8
Predictor: 'None'
ExtraSamples: [3x1 double]
SampleFormat: {4x1 cell}
ModelPixelScaleTag: [3x1 double]
ModelTiepointTag: [6x1 double]
GDAL_METADATA: '<GDALMetadata>
<Item name="DataType">Generic</Item>
</GDALMetadata>
'
GDAL_NODATA: '65536'
Thanks, Mehdi
Answers (0)
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!