TIFF with only a channel and values

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dayer
Posts: 1
Joined: 2012-12-05T09:38:18-07:00
Authentication code: 6789

TIFF with only a channel and values

Post by dayer »

Hi,

I'm looking for get a file in TIFF format and only with a channel. Red channel for example, single band, because I'll need for georeference and get pixel values.
Firstly I've replaced the colours by anothers. For example one colour to rgb(12,12,12), another to rgb(18,18,18), rgb(24,24,24), rgb(30,30,30),... And secondly I try to get a TIFF single band with:

Code: Select all

convert prueba.tiff -channel R -separate prueba-R.tiff
But when I check it with gdalinfo it says it's three bands:

Code: Select all

Band 1 Block=480x2 Type=UInt16, ColorInterp=Red
[...]
Band 2 Block=480x2 Type=UInt16, ColorInterp=Green
Band 3 Block=480x2 Type=UInt16, ColorInterp=Blue
And identify -verbose says:

Code: Select all

[...]
  Channel statistics:
    Red:
      min: 3084 (0.0470588)
      max: 65535 (1)
      mean: 62746.7 (0.957453)
      standard deviation: 12821.5 (0.195643)
      kurtosis: 17.2132
      skewness: -4.38243
    Green:
      min: 3084 (0.0470588)
      max: 65535 (1)
      mean: 62746.7 (0.957453)
      standard deviation: 12821.5 (0.195643)
      kurtosis: 17.2132
      skewness: -4.38243
    Blue:
      min: 3084 (0.0470588)
      max: 65535 (1)
      mean: 62746.7 (0.957453)
      standard deviation: 12821.5 (0.195643)
      kurtosis: 17.2132
      skewness: -4.38243
[...]
However, if I try doing this in GIMP, split it in components in layers, delete all layers except Red channel, I get a TIFF only with a band.
gdalinfo says:

Code: Select all

[...]
Band 1 Block=480x64 Type=Byte, ColorInterp=Gray
identify -verbose says:

Code: Select all

[...]
  Channel statistics:
    Gray:
      min: 12 (0.0470588)
      max: 255 (1)
      mean: 244.151 (0.957453)
      standard deviation: 49.8889 (0.195643)
      kurtosis: 17.2132
      skewness: -4.38243
[...]
Then, I try with convert and -type palette and gdalinfo says:

Code: Select all

[...]
Band 1 Block=480x34 Type=Byte, ColorInterp=Palette
  Image Structure Metadata:
    NBITS=4
  Color Table (RGB with 16 entries)
    0: 12,12,12,255
    1: 18,18,18,255
    2: 24,24,24,255
    3: 30,30,30,255
    4: 36,36,36,255
    5: 42,42,42,255
    6: 48,48,48,255
    7: 255,255,255,255
    8: 0,0,0,255
    9: 0,0,0,255
   10: 0,0,0,255
   11: 0,0,0,255
   12: 0,0,0,255
   13: 0,0,0,255
   14: 0,0,0,255
   15: 0,0,0,255
Well. But ¿I could get other values for each pixel? For example:

Code: Select all

    0: 255,255,255
    12: 12,12,12,255
    18: 18,18,18,255
    24: 24,24,24,255
    30: 30,30,30,255
    36: 36,36,36,255
[...]
Thank you very much.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: TIFF with only a channel and values

Post by snibgo »

For me, IM 6.7.9-Q16 on Windows 7:

Code: Select all

convert rose.tiff -channel R -separate rose-r.tiff
gives a greyscale (single channel) file. What version IM and platform are you on?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIFF with only a channel and values

Post by fmw42 »

In IM 6 any single channel (or grayscale) image will always be 3 equal R,G,B channels. IM 7 will have true single channel images.
Post Reply