Questions on reading in JPEG2000 Images

I am currently having an issue reading in jpeg2000 images. The issue is that I cannot find a way to extract metadata that is in the file and also extracting an area of interest in the image is painfully slow. i tried doing a ImageReader.getImageMetadata() but it doesn't return anything useful that i was looking for in the metadata portion. Below is a snippet of the a dummy code i put together. Its intention is to read a 10x10 block starting in the 0,0 location. This code is painfully slow. Am i doing something wrong? Error handling is left for now.
J2KImageReader j2kImageReader = (J2KImageReader) ImageIO
.getImageReadersByFormatName(
"jpeg2000").next();
j2kImageReader.setInput(new FileImageInputStream(new File(p_fileLocation)));
ImageReadParam imageReadParam = j2kImageReader.getDefaultReadParam();
imageReadParam.setSourceRegion(new Rectangle(0, 0, 10, 10));
IIOImage image = j2kImageReader.readAll(0, imageReadParam);

Also i forgot to mentioned that the above code looks like it is scanning and reading in all the pixels and returning the ones that i specified in the ImageReadParam class

Similar Messages

  • Why am I getting a blue box with question mark instead of logo image?  It happens in my signature (in gmail) and in mailchimp (again, only with the logo).

    Why am I getting a blue box with question mark instead of logo image?  It happens in my signature (in gmail) and in mailchimp (again, only with the logo).

    The question mark in the box, if it looks like this:   means that safari cannot find the linked image.  On windows machines, this would be the equivilant of  the small "page-with-a-red-X" logo that appears in the same scenario.  Check the reference to the image and make sure that the image is in the correct location, and is accessable by the reference.

  • Read the raw image file

    I want to read the raw image file , i have the basic labview 8.0 version

    That is a broad question... I'll make some asumptions.
    I think you have a file with some raw image format. This can be quite a few formats. Every camera firm has it's own proprietry format. Often, when talking about a raw image, it is simply a 2d array of colors. So you'll have a file with numbers that are U8's that represent R G B, alpha R G B, B G R, etc., or a U32 that represent the same, combined in one U32...
    The data can be stored binary or ASCII. Both formats are handled differently.
    The ASCII format can be one large array of data, or seperated with enters for each scan line.
    In both cases, you might need to remove information, like height and width, from the data before parsing the image data.
    You can use the "Spreadsheet String To Array" to convert the a ASCII string to a LabVIEW 1D or 2D array. Or use "Read From Spreadsheet File.vi" to read the file directly as an array. Use Reshape Array to convert a 1D array to a 2D array.
    The binary file is a bit different. Use "Read Binary File". It will get you a string. This string is a converted array of U8, the string doesn't need to be ASCII. convert this string to an array of U8's, with "String To Byte Array". Convert the 1D array just like before.
    Now you have a 2D array. You can convert it into a pixmap with "Flatten Pixmap.vi". You can then display it in a picture control with "Draw Flattened Pixmap.vi".
    Regards,
    Wiebe.

  • Need to read/paint large images fast. Help!

    Hello Java community,
    I am having trouble writing a program which can read large image files from disk (~ 1-2 MB) and paint them to the screen while maintaining a frame rate of 15 or 20 fps. Right now I am doing this through a Producer/Consumer scheme. I have one thread which constantly creates ImageIcons (using the constructor which accepts a String file path), and places them on a blocking queue (production) with a maximum capacity of 5 or 10. I have a second thread which removes an image from the queue (consumption) and paints it to the JFrame every so many milliseconds to honor the frame rate.
    My problem is that this approach is not fast enough or smooth enough. With smaller images it works fine, but with larger images it cannot maintain a high frame rate. It also seems to consume more memory than it should. I am assuming that once I paint a new ImageIcon, the old one goes out of scope and is freed from memory by the Garbage Collector. However, even with a queue capacity of 5 or 10, I am getting out-of-memory exceptions. I plan on trying the flush() method of the Image class to see if that helps to recover resources. After searching around a bit, I see that there are many different ways to read/load an image, but giving a local path to an ImageIcon and letting it load the image seems to be a safe way to go, especially because in the documentation for ImageIcon, it says that it pre-loads the image using Media Tracker.
    Any help, ideas, or links would be appreciated!
    Thanks,
    Elliot

    Thanks for another insightful response.
    I've played a bit more, so let me update you. I am preloading images, the blocking queue (FIFO) is full when the animation begins. Right now, the queue capacity is 10, but for smaller images it can be closer to 40 or 50. The image reader queue reads images and places them in this queue. Oddly, the problem does not seem to be that the reader thread can't keep up. I added a print statement which displays the size of the queue before each removal and it remains very close to the capacity, at least for the my test images which are only 400 x 400, approximately 100 KB each.
    I've tried animating the images in two distinct ways. My first approach, as I mentioned in the original question, was to animate the images using purely swing components and no manual painting of any kind. This is always nice because it frames the image perfectly and the code is minimal. To accomplish this I simply had the image reader thread pass in the image path to the constructor of ImageIcon and put the resulting ImageIcon in the queue. The animator thread had a simple swing timer which fired an ActionEvent every so-many milliseconds (in the event dispatch thread). In the actionPerformed method I simply wrote a few lines to remove the head of the queue and I used the JLabel setIcon(ImageIcon) to update the display. The code for this was very nice, however the animation was choppy (not flickering).
    In my second approach, which was a bit longer, I created a class called AnimationPanel which extended JPanel and implemented Runnable. I simply overrode paintComponent and inside I painted a member Image which was set in the thread loop. Rather than storing ImageIcons, the queue stored Images. The reader thread used ImageIO.read(...) to generate an Image. I used simple logic in the thread loop to monitor the fps and to fire repaints. This approach suffered from the same problem as the one above. The animation was choppy.
    I found the following things to be true:
    - the reader can keep up with the animator
    - if I run the image reader and perform a basic polygon animation, both of my approaches animate smoothly at high frame rates. In other words, it's not the work (disk reads) being done by the reader that is causing the lag
    - I believe the slowness can be attributed to the following calls: label.setIcon(imageIcon) or g.drawImage(image, 0, 0, this). This leads me to believe that the images are not fully processed as they are being placed on the queue. Perhaps Java is waiting until they are being used to fully read/process the images.
    - I need to find a way to process the images fully before trying to paint them, but the I felt that my approaches above were doing that. I considered have the reader frame actually generate a JLabel or some object that can be displayed without additional processing.
    - your idea about AWT components is a good one and I plan on trying that.
    Elliot

  • Forms6i, read and write Images to BLOB

    I read and write jpg's to the database with this commands:
    Read_Image_File (V_Filename, 'JPG', 'BILDER.IM_BILD');
    Write_Image_File (V_Filename, 'JPG', 'BILDER.IM_BILD', No_Compression, Original_Depth);
    My problem is, that forms stores a jpg-format to the db, that cannot be read from java-programs.
    The other way, when java stores jpg's to the BLOB, then forms can work fine with this images too and java also...
    What does forms do, when it stores jpg's to the db, so that other programs cannot use the images?
    Gerd

    When you post code, please use the code tags using the code button available on the message entry page. It makes it much easier to read.
    Do you have a question?

  • How to reduce the size of a jpeg2000 image ?

    Hi all,
    I use Java ImageIO to :
    - create JPEG images from JPEG2000 images
    - create JPEG2000 images from JPEG images
    The transformation JPEG2000 to JPEG works fine. The transformation JPEG to JPEG2000 works too, but the JPEG2000 images that I get have a size too big.
    => For a JPEG image 640x480 with a size 43 Kb, I get a JPEG2000 image with a size 170 Kb
    => For a JPEG image 800x600 with a size 66 Kb, I get a JPEG2000 image with a size 276 Kb
    I tried to change many parameters in the J2KImageWriteParam object :
    final J2KImageWriteParam paramJ2K = new J2KImageWriteParam();
    paramJ2K.setLossless(false);
    paramJ2K.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    paramJ2K.setCompressionType("JPEG2000");
    paramJ2K.setCompressionQuality(0.5F);
    paramJ2K.setEncodingRate(Double.MAX_VALUE);
    paramJ2K.setFilter(J2KImageWriteParam.FILTER_53);
    //      paramJ2K.setWriteCodeStreamOnly(true);
    //      paramJ2K.setComponentTransformation(true);
    //      paramJ2K.setProgressionType("res"); //Resolution-Layer-Component-Position
    //      paramJ2K.setProgressionType("layer"); //Layer-Resolution-Component-Position
    //      paramJ2K.setProgressionType("res-pos"); //Resolution-Position-Component-Layer
    //      paramJ2K.setProgressionType("pos-comp"); //Position-Component-Resolution-Layer
    //      paramJ2K.setProgressionType("comp-pos"); //Component-Position-Resolution-Layer But, whatever the values, I still have the same size.
    Can someone help me please ?
    Thanx

    Hi,
    I found a solution, for those interested :
    I change filter to have this :
    paramJ2K.setFilter(J2KImageWriteParam.FILTER_97);So I get a JPEG2000 with very good quality and a size ~40 Kb.
    Nevertheless, whatever the value I set for compression quality and encoding rate, it has no effect on the quality and the size of the JPEG2000 image, I don't know why...

  • Flash Can't Display JPEG2000 Images?

    I am building a Flash interface to display high quality
    photos on a CD that will be included in a book. However, the author
    has decided to use JPEG2000 images and they will not load using my
    image loader. JPG will work just fine, but Flash does not seem to
    recognize the JPEG2000 format. Is there a workaround for this, or
    do I tell him to resave as JPG?

    i don't think there's a way to display that format in
    flash.

  • Questions on reading a file...

    Hi All,
    I have a few questions on reading a file...
    1st of all ... if I have
    BufferedReader inFile = new BufferedReader (new FileReader("tickets.txt"));and I do inFile.readLine(); will it read the next line everytime I do that? ... say I had a file that had 5 lines of text and I did inFile.readLine(); 5 times will I get the first line 5 times or will I get each line?
    If the is a blank line in the file will it return null?
    how can I feed the file name to args[0] and what is that for?
    Thanks,
    Mike

        public static void main(String args[]) {       
            BufferedReader inFile = null;   
            try {
                inFile = new BufferedReader (new FileReader(args[0]));   
                for (int i = 0; i < reservation.length; i++) {
                    readFile(reservation, inFile, arrayCounter, numberOfReadItems);*/
                    inFile.close();
            catch (ArrayIndexOutOfBoundsException aioobe) {
                System.out.println("Parameter required");
                System.exit(0);
            catch (FileNotFoundException fnfe) {
                System.out.println("File not found");
                System.exit(0);
            catch (IOException ioe) {
                System.out.println("Failed to close file");
                System.exit(0);

  • Read Error of images in libre office

    read error in images of LibreOffice
    Hi, when loading this file, do not load images in the document, this only happens since version 3.5, instead of pictures, a box appears with the message "read error".
    The file I downloaded from the Internet, the images are correctly loaded into abiword.
    I would appreciate your help, thanks.
    The File

    Crystal Reports is limited in how it works with images - large images or a large number of images, etc. Much as CR is not a good database archiving tool, it's not a very good graphics presenter. I find stand-alone versions of CR are a bit better, but that may just be a perception. My recommendations:
    1) Try an eval of a stand-alone version of CR:
    http://www.sap.com/solutions/sapbusinessobjects/sme/freetrials/index.epx
    Go for CR 2008 as CR 2011 does not have any SDK
    2) Make sure the picture  blob  what ever, never spills beyond the designer pane of the report. This may change from site to site depending on printer drivers used (CR depends on these to render the report)
    3) Have a look at the article [Causes of "Background Processing" error|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50a6f5e8-8164-2b10-7ca4-b5089df76b33]
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Reading 8kb tiff image and then writing into backend. please help

    Hi All, Please Help ..
    My aim is to read a tiff image which of 8kb 1732x717 size, and then store it into backend.
    what I did is read the image into bufferedImage and then used tiffencodeparam with compression_none but the problem is size is too much after encoding.
    code sample
    BufferedImage image = ImageIO.read(tiff_filename); to read tiff image
    to write tiff image
    TiffEncodeParam p = new TiffEncodeParam();
    p.setCompression(TiffEncdeParam.COMPRESSION_NONE);
    FileOutputStream out = new FIleOutputStream(tiff_filename);
    ImageEncoder e = ImageCodec.createImageEncoder(""TIFF,out,p);
    e.encode(image);
    out.close();

    I got all my pictures AND everything else back, folders, ratings, keywords etc
    Fortunately I had a backup of the entire iPhoto library folder, it was about 3 months old (I know shame on me) so I didn't want to just use the entire backup folder and lose 3 months of photos.
    So I just copied the AlbumData.xml file and the Library6.iPhoto file. PRESTO all my pictures were back WITH all the folders,keywords etc, etc intact!! (up till the 3 month old backup point).
    Then I just re-imported the missing 3 months worth of pictures from the original folder in the iphoto library folder. So all I had to recreate was 3 months worth of customization. WHEW!!
    Reading through the discussions it seems there is a fair number of users where iPhoto would go empty, but they knew the images were still on the computer. I am not a programmer, but it seems silly to me the their are files that get re-written everytime iPhoto closes....computers crash. and then what happens to the files? Mine got corrupted, lesson learned BACKUP more frequently!!
    Thanks to Old Toad who steered me to the Library6.iPhoto as a possible troublemaker in another thread!

  • Reading Mac Disk Image on PC

    Are there any tools for reading a Disk Image created with Disk Utility on a Windows computer?

    Does this page contain anything useful?
    (20542)

  • Read Binary(raw Image) data from a file

    Hi
    PLEASE HELP, I want to Read Binary(Raw Image)data (16 bit integer) from a file and display on the JPanel or JFrame.

    Hi, you'll need to use MemoryImageSource.
    You read each RGB triple and add it to a pixel[].
    Heres the roughg idea.
    Hope that helps.
    Harley.
    int width,height;
    int[] pixels = new int[width*height];
    while(!fileDone)
    for(int i=0; i<(width*height) i++){
    int rgb = inputStream.readInt();
    pixels[i] = rgb;
    DirectColorModel colorModel = new DirectColorModel(16,0xff00,0x00ff,0x00ff);
    MemoryImageSource memImage = new MemoryImageSource(width,height,pixels,0,width));

  • Color Changed when reading a Tiff Image

    I have created a ImageIcon of a tiff image by using the following code. but when reading some images the color is Mis-Matching
    BufferedImage bufImage = ImageIO.read( <tiff file path> );
    JLabel jLabel= new JLabel(new ImageIcon(bufImage));whats the reason for this?.. anybody send me the code snippet to read the tiff image in its original color.. please..

    Thanks for the reply.
    When I render a tiff format image, I have a choice to either render with a alpha or not. I pick with alpha.
    In CS2 Photoshop when I would open that tiff file, my image would come up and I would be able to see the whole image I rendered. The alpha would be in the channel tab where I would make active and apply to my image if I wanted to.
    Now in CS5 when I open that same tiff file my image opens up with the alpha applied already. What I mean by applied is my background is gone or transparent. I have no other layer to turn on. Just my image with no background. Also in the channel tab I have no alpha I would have to create one from the original image.
    I hope this explains my issue better, if not let me know I'll have to do some screen shot for you.

  • Iphoto question. I have 8 images in an event. One is out of order. I have tried to copy and paste, and to drag and drop, but I cannot get it to move. Can anyone help?

    I have an iphoto question. I have 8 images in an event. One is out of order. I have tried to copy and paste, and  i have tried to drag and drop, but it won't move. Any help?

    IPhoto forum:
    https://discussions.apple.com/community/ilife/iphoto

  • PC Users cannot read the JPG images attached to my emails

    Several users of PC's, running Vista or Win 7, have difficulties to read the JPG images attached to my emails. All they see is an endless list of numbers and signs (in fact the binary data of the image).
    The problem can only be solved by zipping the images.
    is this due to a setup option in MAIL, or do you know how to solve this issue?
    Patrick

    If I had to guess, I would bet that your images do not have a ".jpg" or ".jpeg" extension on the end. This is how PCs identify the file - and Macs, too, these days, unfortunately. You also should make sure that Edit -> Attachments -> Always Send Windows-Friendly Attachments is checked.

Maybe you are looking for