read_tiff - simple question [message #14502] |
Sun, 28 February 1999 00:00 |
Harald von der Osten-
Messages: 15 Registered: February 1999
|
Junior Member |
|
|
Hi all,
I am trying to read an existing tiff image. Doing this exactly as
proposed in the online help menue I only get error messages. For
example:
device, true=24
image=read_tiff(�zeraqon.tif�, r, g, b)
tvlct, r, g, b
tv, image
leads to the error message unknown variable r in tvlct. What is missing?
By the way: Does something exist like an archive including all the
discussion in this newsgroup, so that beginners like me can first have a
look on this before asking such simple questions in this newsgroup?
Thanks a lot,
Harald
--
Harald von der Osten-Woldenburg
Geophysical Prospection of Archaeological Sites
Landesdenkmalamt Baden-Wuerttemberg
Silberburgstrasse 193
D-70178 Stuttgart
http://delos.lf.net/~hvdosten/index.html: Geomagnetics and Geoelectrics
http://www.region-lb.de/HomeSites/HvdOsten: Ground Penetrating Radar and
EMI
|
|
|
Re: read_tiff - simple question [message #14505 is a reply to message #14502] |
Sun, 28 February 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Harald von der Osten-Woldenburg (hvdosten@ludwigsburg.netsurf.de) writes:
> thank you very much for your answer. Your code did it and you were right, the
> TIFF-file was a 3 x m x n array.
>
> Just the last question: How can I split the image into three 2-dim arrays and
> after working with them to create again a 3 x m x n array (TIFF-file) with
> these three new files?
You can easily separate a 24-bit image into the three
"channels" or "color planes" that make up the 24-bit image.
For example:
image24 = Read_Tiff('zeragon.tif')
red = Reform(image24[0,*,*])
green = Reform(image24[1,*,*])
blue = Reform(image24[2,*,*])
Now, suppose you want to brighten the red values up a bit.
You could do something like this:
red_brightened = Byte(red * 1.2) < 255B
To put the brightened red plane back into the 24-bit image
all you do is this:
image24[0,*,*] = red_brightened
Of course, you can do the same thing "in situ" as it were.
For example, the same brightening with the green channel:
image24[1,*,*] = Byte( (image24[1,*,*] * 1.2) ) < 255B
If you want to put the planes back together again in a
new 24-bit image, you could do something like this:
dims = Size(image24, /Dimensions)
new_image24 = BytArr(3, dims[1], dims[2])
new_image24[0,*,*] = red_brightened
new_image24[1,*,*] = green
new_image24[2, *,*] = image24[2,*,*]
Image subscripting. Ain't it wonderful! :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Note: This follow-up was e-mailed to the cited author.]
|
|
|
Re: read_tiff - simple question [message #14506 is a reply to message #14502] |
Sun, 28 February 1999 00:00  |
Harald von der Osten-
Messages: 15 Registered: February 1999
|
Junior Member |
|
|
Dear David,
thank you very much for your answer. Your code did it and you were right, the
TIFF-file was a 3 x m x n array.
Just the last question: How can I split the image into three 2-dim arrays and
after working with them to create again a 3 x m x n array (TIFF-file) with
these three new files?
Thanks again for your help!!!
Harald
David Fanning wrote:
>
> My guess is that this is a 24-bit image in this
> TIFF file, so there are no R, G, and B vectors that
> would create an associated color palette. The RGB
> information is included inside the image itself. You
> can easily test this by looking at image, r, g, and b
> with the HELP command:
>
> Help, image, r, g, b
>
> I think you will find that image is a 3-by-m-by-n array
> and that r, g, and b are undefined. Try this code:
>
> Device, True=24
> image = Read_Tiff('zeragon.tif')
> TV, image, True=1 ; if image is 3-by-whatever
>
>
--
Harald von der Osten-Woldenburg
Geophysical Prospection of Archaeological Sites
Landesdenkmalamt Baden-Wuerttemberg
Silberburgstrasse 193
D-70178 Stuttgart
http://delos.lf.net/~hvdosten/index.html: Geomagnetics and Geoelectrics
http://www.region-lb.de/HomeSites/HvdOsten: Ground Penetrating Radar and EMI
|
|
|
Re: read_tiff - simple question [message #14507 is a reply to message #14502] |
Sun, 28 February 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Harald von der Osten-Woldenburg (hvdosten@ludwigsburg.netsurf.de) writes:
> I am trying to read an existing tiff image. Doing this exactly as
> proposed in the online help menue I only get error messages. For
> example:
>
> device, true=24
> image=read_tiff(�zeraqon.tif�, r, g, b)
> tvlct, r, g, b
> tv, image
>
> leads to the error message unknown variable r in tvlct. What is missing?
My guess is that this is a 24-bit image in this
TIFF file, so there are no R, G, and B vectors that
would create an associated color palette. The RGB
information is included inside the image itself. You
can easily test this by looking at image, r, g, and b
with the HELP command:
Help, image, r, g, b
I think you will find that image is a 3-by-m-by-n array
and that r, g, and b are undefined. Try this code:
Device, True=24
image = Read_Tiff('zeragon.tif')
TV, image, True=1 ; if image is 3-by-whatever
You can find out exactly what is in the TIFF file before
you try to read it by using the new QUERY_TIFF function:
is_tiff = Query_TIFF('zeragon.tif', tiff_info)
IF is_tiff THEN Help, tiff_info, /Structure ELSE $
Print, 'Not a TIFF file'
This will tell you whether the file contains a palette,
whether it is a 24-bit or 8-bit image, what its dimensions
are, etc. Very handy.
> By the way: Does something exist like an archive including all the
> discussion in this newsgroup, so that beginners like me can first have a
> look on this before asking such simple questions in this newsgroup?
You can always visit the IDL FAQ, maintained by Mike
Schienle at:
http://www.ivsoftware.com/pub/idl_faq.html
And I have plenty of IDL programming tips on my site as well:
http://www.dfanning.com/documents/tips.html
But I don't think anyone minds simple questions in the newsgroup
if the people seeking answers are sincere in their efforts to
learn IDL. :-)
Cheers,
David
P.S. I've just received the latest batch of IDL books from
the printer. This version has been updated rather extensively
for IDL 5.2. I have also increased the amount of discussion
on 8-bit verses 24-bit image display, as this continues to
be a source of confusion for many IDL users as we make the
transition from 8-bit to 24-bit computers.
I also have about 8 books from the previous Dec 98 version of the
book that I will sell to students cheaply, if anyone is interested.
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Note: This follow-up was e-mailed to the cited author.]
|
|
|