Skip to main content

how to display tiff image with an annotation

14 replies [Last post]
neian
Offline
Joined: 2006-10-27
Points: 0

Hi, im just new to JAI and I'm having a problem displaying a tiff image with a Wang annotation. Actually, I was able to display the image but the annotation didnt appear in the JPanel.
Below is the code I used to display the image in a JPanel. I am using DisplayJAI which is in the JAI tutorial I found.
I tried looking for any topics regarding my problem but discussions of image with annotations are few.
Please help. Thanks.

ByteArraySeekableStream stream = null;
try{
ImageBean imageBean = new TestJAI().retrieveImage("");
stream = new ByteArraySeekableStream(imageBean.getImageField()); //
}catch(Exception e){
e.printStackTrace();
}
PlanarImage image = JAI.create("stream", stream);
JFrame frame = new JFrame();
Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
// Create an instance of DisplayJAI.
DisplayJAI dj = new DisplayJAI(image);
contentPane.add(new JScrollPane(dj),BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(image.getWidth(),image.getHeight()); // adjust the frame size.
frame.setVisible(true); // show the frame.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bpb
Offline
Joined: 2004-06-23
Points: 0

Where is the annotation stored in the image file?

Brian

> Hi, im just new to JAI and I'm having a problem
> displaying a tiff image with a Wang annotation.
> Actually, I was able to display the image but the
> e annotation didnt appear in the JPanel.
> Below is the code I used to display the image in a
> JPanel. I am using DisplayJAI which is in the JAI
> tutorial I found.
> I tried looking for any topics regarding my problem
> but discussions of image with annotations are few.
> Please help. Thanks.
>
> ByteArraySeekableStream stream = null;
> try{
> ImageBean imageBean = new
> new TestJAI().retrieveImage("");
> stream = new
> = new
> ByteArraySeekableStream(imageBean.getImageField());
> //
> }catch(Exception e){
> e.printStackTrace();
> }
> PlanarImage image = JAI.create("stream", stream);
> JFrame frame = new JFrame();
> Container contentPane = frame.getContentPane();
> contentPane.setLayout(new BorderLayout());
> // Create an instance of DisplayJAI.
> DisplayJAI dj = new DisplayJAI(image);
> contentPane.add(new
> w JScrollPane(dj),BorderLayout.CENTER);
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>
> frame.setSize(image.getWidth(),image.getHeight());
> ; // adjust the frame size.
> frame.setVisible(true); // show the frame.

neian
Offline
Joined: 2006-10-27
Points: 0

the image that I got is already in bytes[], so I think the annotation is integrated in the binary data.

> Where is the annotation stored in the image file?
>
> Brian
>

bpb
Offline
Joined: 2004-06-23
Points: 0

Do you mean that the annotation is in the metadata or "burned" into the image pixels?

> the image that I got is already in bytes[], so I
> think the annotation is integrated in the binary
> data.
>
>
> > Where is the annotation stored in the image file?
> >
> > Brian
> >

neian
Offline
Joined: 2006-10-27
Points: 0

I think it is burned into the image pixels.
What would be the difference if the annotation is in the metadata?
Does the image having a Wang annotation affect the capabilities of JAI to display it? Will I need to call another software to be able to show the image?
Thank you for taking time to answer my questions.

> Do you mean that the annotation is in the metadata or
> "burned" into the image pixels?
>
> > the image that I got is already in bytes[], so I
> > think the annotation is integrated in the binary
> > data.
> >
> >
> > > Where is the annotation stored in the image
> file?
> > >
> > > Brian
> > >

Brian Burkhalter

On Mon, 6 Nov 2006, jai-interest@javadesktop.org wrote:

> I think it is burned into the image pixels.
> What would be the difference if the annotation is in the metadata?

Then for it to appear visually you would have to extract if from the metadata
and write it to your graphics object.

> Does the image having a Wang annotation affect the capabilities of JAI to display it? Will I need to call another software to be able to show the image?

Of course not as long as the image is TIFF-compliant.

> Thank you for taking time to answer my questions.
>
>> Do you mean that the annotation is in the metadata or
>> "burned" into the image pixels?
>>
>>> the image that I got is already in bytes[], so I
>>> think the annotation is integrated in the binary
>>> data.
>>>
>>>
>>>> Where is the annotation stored in the image
>> file?
>>>>
>>>> Brian
>>>>
> [Message sent by forum member 'neian' (neian)]
>
> http://forums.java.net/jive/thread.jspa?messageID=170774
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

neian
Offline
Joined: 2006-10-27
Points: 0

Hello Brian,
how can I get the metadata from the tiff image? I can only use JAI since our system uses jdk 1.3xx. I think imageio is good only for jdk 1.4 and above.
thanks.

> On Mon, 6 Nov 2006, jai-interest@javadesktop.org
> wrote:
>
> > I think it is burned into the image pixels.
> > What would be the difference if the annotation is
> in the metadata?
>
> Then for it to appear visually you would have to
> extract if from the metadata
> and write it to your graphics object.
>
> > Does the image having a Wang annotation affect the
> capabilities of JAI to display it? Will I need to
> call another software to be able to show the image?
>
> Of course not as long as the image is TIFF-compliant.
>
> > Thank you for taking time to answer my questions.
> >
> >> Do you mean that the annotation is in the metadata
> or
> >> "burned" into the image pixels?
> >>
> >>> the image that I got is already in bytes[], so I
> >>> think the annotation is integrated in the binary
> >>> data.
> >>>
> >>>
> >>>> Where is the annotation stored in the image
> >> file?
> >>>>
> >>>> Brian
> >>>>
> > [Message sent by forum member 'neian' (neian)]
> >
> >
> http://forums.java.net/jive/thread.jspa?messageID=1707
> 74
> >
> >
> ------------------------------------------------------
> ---------------
> > To unsubscribe, e-mail:
> interest-unsubscribe@jai.dev.java.net
> > For additional commands, e-mail:
> interest-help@jai.dev.java.net
> >
> >
>
> ----------------
> Brian Burkhalter
> Java Media, Imaging, and Graphics
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
> This email message is for the sole use of the
> intended recipient(s)
> and may contain confidential and privileged
> information. Any
> unauthorized review, use, disclosure or distribution
> is prohibited.
> If you are not the intended recipient, please contact
> the sender by
> reply email and destroy all copies of the original
> message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>
> ------------------------------------------------------
> ---------------
> To unsubscribe, e-mail:
> interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail:
> interest-help@jai.dev.java.net

Brian Burkhalter

Starting here

http://download.java.net/media/jai/javadoc/1.1.3/jai-apidocs/javax/media...

should lead you to the answer.

Brian

On Mon, 6 Nov 2006, jai-interest@javadesktop.org wrote:

> Hello Brian,
> how can I get the metadata from the tiff image? I can only use JAI since our system uses jdk 1.3xx. I think imageio is good only for jdk 1.4 and above.
> thanks.
>
>> On Mon, 6 Nov 2006, jai-interest@javadesktop.org
>> wrote:
>>
>>> I think it is burned into the image pixels.
>>> What would be the difference if the annotation is
>> in the metadata?
>>
>> Then for it to appear visually you would have to
>> extract if from the metadata
>> and write it to your graphics object.
>>
>>> Does the image having a Wang annotation affect the
>> capabilities of JAI to display it? Will I need to
>> call another software to be able to show the image?
>>
>> Of course not as long as the image is TIFF-compliant.
>>
>>> Thank you for taking time to answer my questions.
>>>
>>>> Do you mean that the annotation is in the metadata
>> or
>>>> "burned" into the image pixels?
>>>>
>>>>> the image that I got is already in bytes[], so I
>>>>> think the annotation is integrated in the binary
>>>>> data.
>>>>>
>>>>>
>>>>>> Where is the annotation stored in the image
>>>> file?
>>>>>>
>>>>>> Brian
>>>>>>
>>> [Message sent by forum member 'neian' (neian)]
>>>
>>>
>> http://forums.java.net/jive/thread.jspa?messageID=1707
>> 74
>>>
>>>
>> ------------------------------------------------------
>> ---------------
>>> To unsubscribe, e-mail:
>> interest-unsubscribe@jai.dev.java.net
>>> For additional commands, e-mail:
>> interest-help@jai.dev.java.net
>>>
>>>
>>
>> ----------------
>> Brian Burkhalter
>> Java Media, Imaging, and Graphics
>> Sun Microsystems, Inc.
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~~~~~~~
>> This email message is for the sole use of the
>> intended recipient(s)
>> and may contain confidential and privileged
>> information. Any
>> unauthorized review, use, disclosure or distribution
>> is prohibited.
>> If you are not the intended recipient, please contact
>> the sender by
>> reply email and destroy all copies of the original
>> message.
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~~~~~~~
>>
>> ------------------------------------------------------
>> ---------------
>> To unsubscribe, e-mail:
>> interest-unsubscribe@jai.dev.java.net
>> For additional commands, e-mail:
>> interest-help@jai.dev.java.net
> [Message sent by forum member 'neian' (neian)]
>
> http://forums.java.net/jive/thread.jspa?messageID=170904
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

neian
Offline
Joined: 2006-10-27
Points: 0

Hello,
I was able to get the tags and fields of the image using TiffDirectory. However, I wasnt able to get the tags that has the Wang annotations. I read that this type of annotation has private IFDs. Is there a way to get the value for private IFDs?
Thanks.
Below is the code I used
TIFFDirectory tDir = new TIFFDirectory(stream, 0);
for (int i=0;i TIFFField tiffField = tDir.getFields()[i];
System.out.println("tag = " + tiffField.getTag());
System.out.println("type = " + tiffField.getType());
if (tiffField.getTag() == 305){
System.out.println("data = " + tiffField.getAsString(0));
}
}

> Starting here
>
> http://download.java.net/media/jai/javadoc/1.1.3/jai-a
> pidocs/javax/media/jai/operator/TIFFDescriptor.html
>
> should lead you to the answer.
>
> Brian
>
> On Mon, 6 Nov 2006, jai-interest@javadesktop.org
> wrote:
>
> > Hello Brian,
> > how can I get the metadata from the tiff image?
> I can only use JAI since our system uses jdk 1.3xx.
> . I think imageio is good only for jdk 1.4 and
> above.
> > thanks.
> >

bpb
Offline
Joined: 2004-06-23
Points: 0

Private IFDs should be loaded but as to the interpretation thereof you are on your own.

> Hello,
> I was able to get the tags and fields of the image
> age using TiffDirectory. However, I wasnt able to
> get the tags that has the Wang annotations. I read
> that this type of annotation has private IFDs. Is
> there a way to get the value for private IFDs?
> Thanks.
> Below is the code I used
> TIFFDirectory tDir = new TIFFDirectory(stream,
> am, 0);
> for (int i=0;i > TIFFField tiffField = tDir.getFields()[i];
> System.out.println("tag = " +
> ag = " + tiffField.getTag());
> System.out.println("type = " +
> + tiffField.getType());
> if (tiffField.getTag() == 305){
> System.out.println("data = " +
> + tiffField.getAsString(0));
> }
> }
>
> > Starting here
> >
> >
> http://download.java.net/media/jai/javadoc/1.1.3/jai-a
>
> >
> pidocs/javax/media/jai/operator/TIFFDescriptor.html
> >
> > should lead you to the answer.
> >
> > Brian
> >
> > On Mon, 6 Nov 2006, jai-interest@javadesktop.org
> > wrote:
> >
> > > Hello Brian,
> > > how can I get the metadata from the tiff
> image?
> > I can only use JAI since our system uses jdk
> 1.3xx.
> > . I think imageio is good only for jdk 1.4 and
> > above.
> > > thanks.
> > >

neian
Offline
Joined: 2006-10-27
Points: 0

Can I ask for some examples on how to deal with private IFDs?
Thanks.

> Private IFDs should be loaded but as to the
> interpretation thereof you are on your own.
>
> > Hello,
> > I was able to get the tags and fields of the image
> > age using TiffDirectory. However, I wasnt able to
> > get the tags that has the Wang annotations. I
> read
> > that this type of annotation has private IFDs. Is
> > there a way to get the value for private IFDs?
> > Thanks.
> > Below is the code I used
> > TIFFDirectory tDir = new TIFFDirectory(stream,
> > am, 0);
> > for (int i=0;i > > TIFFField tiffField = tDir.getFields()[i];
> > System.out.println("tag = " +
> > ag = " + tiffField.getTag());
> > System.out.println("type = " +
> > + tiffField.getType());
> > if (tiffField.getTag() == 305){
> > System.out.println("data = " +
> > + tiffField.getAsString(0));
> > }
> > }
> >

frankm
Offline
Joined: 2006-11-23
Points: 0

If you have the TiffDirectory you just have to call the getField method:

TIFFDirectory dir = (TIFFDirectory)firstImage.getProperty("tiff_directory");

TIFFField field = dir.getField( 32932 );

The WANG Annotations are stored within the Tiff Tag ID 32932 ... but I think JAI is not able to handle/display the WANG annotations.

If you want to display the annotations you have to interpret the tag yourself. field.getAsBytes() is the last thing JAI can do for you :-(

Please let me know if I'm wrong.

neian
Offline
Joined: 2006-10-27
Points: 0

thank you very much, frankm.
I will try to see if I can do some work around for this and will try to share it here.

> If you have the TiffDirectory you just have to call
> the getField method:
>
> TIFFDirectory dir =
> (TIFFDirectory)firstImage.getProperty("tiff_directory"
> );
>
> TIFFField field = dir.getField( 32932 );
>
> The WANG Annotations are stored within the Tiff Tag
> ID 32932 ... but I think JAI is not able to
> handle/display the WANG annotations.
>
> If you want to display the annotations you have to
> interpret the tag yourself. field.getAsBytes() is the
> last thing JAI can do for you :-(
>
>
> Please let me know if I'm wrong.

frankm
Offline
Joined: 2006-11-23
Points: 0

If you are interested in WANG Annotation Specification have a look at

http://support.global360.com/content/I4W/documentation/annospec.htm

good luck!

Message was edited by: frankm

domac
Offline
Joined: 2012-04-27
Points: 0

The link:

http://support.global360.com/content/I4W/documentation/annospec.htm

is out of order. Is there anybody who can give me the WANG Annotation Specification?

I have googled for hours, but I couldn't find it. :(