This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, September 19, 2007 10:45:50 AM(UTC)
Groups: Registered
Posts: 14
Hi,
Can any body help me with an example of how to determine the Photometric Interpretation (MinIsWhite or MinIsBlack,...) of a TIFF Image.
I have the RasterCodecs and the CodecsImageInfo handy. But I dont know how to get the photometric interpretation value out of this.
Any help is greatly appreciated.
Thanks,
Pradeep
#2
Posted
:
Wednesday, September 19, 2007 12:27:01 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
You can set the photometric interpretation for saving tiff files with the following property:
RasterCodecs.Options.Tiff.Save.PhotometricInterpretation
I
would slightly alter the structure of your code to prevent redundant
calls to rasterCodecs.GetInformation(). Also, info.Format retrieves
the format of the image, not the compression. To retrieve the
compression of an image use info.Compression which is a string, not an
enumeration like info.Format. Format refers to the image type like
tif, gif, cmp, pdf, etc. Compression refers to the scheme used in
producing the file LZW, RLE, CCITT, ZipLib(Png), etc.
CodecsImageInfo info;
RasterCodecs.Startup();
RasterCodecs rasterCodecs = new RasterCodecs();
int totalPages = rasterCodecs.GetInformation(fullPathOfImage, true).TotalPages;
for(short currentPageNumber = 1; currentPageNumber<=totalPages; currentPageNumber++)
{
info = rasterCodecs.GetInformation(fullPathOfImage, false, currentPageNumber);
RasterImageFormatformat = info.Format;
string compression = info.Compression
}
#3
Posted
:
Wednesday, September 19, 2007 12:38:42 PM(UTC)
Groups: Registered
Posts: 14
Thanks for the quick response Boyd,
Couple of questions with this::
1) How do I GET the PhotometricInterpretation from an image which is loaded using RasterCodecs (Not set). I understand I can compare it with an enum some how using PHOTMTRICINTERP or similar. But I don't know exactly how?
2) What does RasterCodecs.Startup() do?
Thanks,
Pradeep
#4
Posted
:
Thursday, September 20, 2007 4:35:48 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Pradeep,
If you have a question on what a particular method does, please refer to the help files as all methods in the toolkit provide a brief description of what they do. I pulled this directly from the help file on RasterCodecs.Startup():
"Initializes the required data to start the LEADTOOLS I/O Library."
Also, there is no direct way to retrieve the PhotometricInterpretation of a loaded tif image, but you can retrieve the CodecsColorSpaceType value of a loaded tif image using:
CodecsImageInfo info = codecs.GetInformation("tif image", ...);
CodecsColorSpaceType colorType = info.ColorSpace;
When you want to save an image using PhotometricInterpretation you must do it like this:
codecs.Options.Tiff.Save.PhotometricInterpretation = CodecsTiffPhotometricInterpretation.DESIREDTYPE;
codecs.Options.Tiff.Save.UsePhotometricInterpretation = true;
codecs.Save(image, "c:\\test.tif", RasterImageFormat.Tif, image.BitsPerPixel);
#5
Posted
:
Thursday, September 20, 2007 5:37:46 AM(UTC)
Groups: Registered
Posts: 14
Boyd,
Please excuse my ignorance.
When I use CodecsColorSpace I get the following options
Bgr BGR colorspace
Yuv YUV colorspace
Cymk CMYK colorspace
CieLab CIELab colorspace
How do I know if the image is a "COLOR" or "BLACKandWHITE".
Basically, I want to read the TIFF image and get the PhotometricInterpretation as "min-is-white" or "min-is-black" or "..."
Can you please help me with this?
Thanks,
Pradeep
#6
Posted
:
Thursday, September 20, 2007 7:48:39 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Refer to the documentation on the ReadTag method. I pass in 262 as the third parameter because that is the id of photometric interpretation in the tiff standard.
RasterTagMetadata readTag = codecs.ReadTag("c:\\test.tif", 1, 262);
byte[] readTagData = readTag.GetData();
Console.WriteLine("Photometric Interpretation = {0}", readTagData[0]);
Here are the values that the integers correspond to. I did this by writing a small test program.
CodecsTiffPhotometricInterpretation.CieLab = 8
CodecsTiffPhotometricInterpretation.Mask = 4
CodecsTiffPhotometricInterpretation.MinimumIsBlack = 1
CodecsTiffPhotometricInterpretation.MinimumIsWhite = 0
CodecsTiffPhotometricInterpretation.Palette = 3
CodecsTiffPhotometricInterpretation.Rgb = 2
CodecsTiffPhotometricInterpretation.Separated = 5
CodecsTiffPhotometricInterpretation.YcbCr = 6
#7
Posted
:
Thursday, September 20, 2007 11:14:54 AM(UTC)
Groups: Registered
Posts: 14
Thanks a lot Boyd,
I was able to get to the photometric vallues using the routine you have specified.
I shall get back to you if I have any further queries.
Pradeep
--GREAT TECH SUPPORT--
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.