JPEG Image Scaling Speed

I've got an application where I'm drawing images to the display from a TCP/IP stream. I'm unable to acheive much better than 8 or 9 fps and the real CPU consuming task seems to be the JPEG image scaling. The frames are being scaled by about 2x but the same color depth is retained. I'm running this application on a dual, 1 Ghz PIII with Red Hat 7.1 and JDK 1.3.1. Any suggestions on how to enhance the performance of Java's image scaling would be appreciated.

You could try using bufferedImages and doing the scaling yourself. I can re-draw a bufferedImage by altering it's raster data
ie..
byte [] data = bi.getData().getDataBuffer().getData();
I get up to 100 fps edditing a 640x480 area. You will have to account for things like bit depth yourself, and scaling algo's, but it might be worth it.
Also check the Bug database, I believe your problem MAY be related to a bug where scaling always converts the entire image to format -> RGBA -> scaled format.

Similar Messages

  • Scaling Binary JPEG images

    Sorry if this is in the wrong forum.
    I am extracting JPEG images stored in a blob field in a DB. I can obtain the bytes of the JPEG in a couple different ways but I have had no luck in scaling the images.
    I need to simple scale the image, and then return the new image preferably in a byte[] or something that I can convert to a byte[].
    I have come accross several past post, and at times seems to work. None of them actually return an image or errors so I am not sure where it fails.
    I tried a modified version of the following which was an example on making thumbnails out of a larger image.
    Here's the url to that example
    http://developer.java.sun.com/developer/TechTips/1999/tt1021.html
    After modifying the code, when I went to test I recieved a weird error in a log file that basically said something could not use :0 which is refering to my monitor.
    This is and will be used in a Linux env, but does not or should not invlove X in anyway. I have come accross other example that talk about a frame.addnotify() method that is supposed to resolve this issue when not outputing to a monitor.
    After adding that, the error is not there, but neither is my scaled image.(which wasn't there before either)
    If this sound strange, that's beacuse I am creating a custom Generator object. Generator being a Servlet created by Macromedia to generate Flash movies and etc. on the fly.
    For some reason in the API it lacks the ability to scale a JPEG image. Yet to be able to put the image into Flash, I must get the image's byte[].
    Please help, I have played around with this one for some time now, and have tried more things than I could document here.
    Any assistance is greatly appreciated!
    Sincerely,
    William L. Thomson Jr.
    Support Group
    Obsidian-Studios Inc.
    439 Amber Way
    Petaluma, Ca. 94952
    Phone/Fax 707.766.9509

    HI,
    The code is not very well organized, but should be clear enough for your reference.
    import java.awt.image.*;
    import java.awt.Image;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import javax.swing.ImageIcon;
    byte[] b; /* your binary image */
    Image inImage = new ImageIcon(b).getImage();
    int iH=inImage.getHeight(null);
    int iW=inImage.getWidth(null);
    BufferedImage outBImage = new BufferedImage(iW,iH,BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = outBImage.createGraphics();
    g2d.drawImage(inImage,null,null);
    g2d.dispose();
    double scale=0.5; /* rescale the image to 50% of its original size*/
    int scaledW=(int)iW*scale;
    int scaledH=(int)iH*scale;
    BufferedImage dstbimg = new BufferedImage(scaledW, scaledH,BufferedImage.TYPE_INT_RGB);
    AffineTransform tx = new AffineTransform();
    tx.scale(scale, scale);
    Graphics2D g2d = dstbimg.createGraphics();
    RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    qualityHints.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
    g2d.setRenderingHints(qualityHints);
    g2d.drawImage(outBImage, tx, null);
    g2d.dispose();
    /* dstbimg is the scaled BufferedImage */

  • How do I control the quality of JPEG images?

    I've written a program that scales a set of JPEG images down to various dimensions. I'm happy with the speed of execution, but quality of the images could be better. How do I specify the quality of the JPEG images I create? In graphics editors, I'm given the option of controlling the lossy-ness (?) of JPEGs when I save them, either reducing image qualify to shrink the file size or vice versa. How can I do this programmatically?
    Thanks

    Hi Jhm,
    leaving aside the scaling algorithm, to save an arbitrary image with 100% quality you'd use
    something like the following code snipet below
    regards,
    Owen
    // Imports
    import java.awt.image.*;
    import com.sun.image.codec.jpeg.*;
    public boolean saveJPEG ( Image yourImage, String filename )
        boolean saved = false;
        BufferedImage bi = new BufferedImage ( yourImage.getWidth(null),
                                               yourImage.getHeight(null),
                                               BufferedImage.TYPE_INT_RGB );
        Graphics2D g2 = bi.createGraphics();
        g2.drawImage ( yourImage, null, null );
        FileOutputStream out = null;
        try
            out = new FileOutputStream ( filename );
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder ( out );
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam ( bi );
            param.setQuality ( 1.0f, false );   // 100% high quality setting, no compression
            encoder.setJPEGEncodeParam ( param );
            encoder.encode ( bi );
            out.close();
            saved = true;
        catch ( Exception ex )
            System.out.println ("Error saving JPEG : " + ex.getMessage() );
        return ( saved );
    }

  • Firefox 3.6.8 causing all JPEG images to be compressed like AOL 9.0

    System Setup:
    Windows 7 Home Premium x64
    NVIDIA GeForce 9500 GT (newest drivers installed)
    Aero is running, switched it off to troubleshoot. Problem persisted.
    Steps to Create the Problem:
    1.) Updated to 3.6.8 from 3.5.11.
    2.) Loaded up my website: http://www.columbuswebseo.com
    3.) I noticed that the background image looks compressed (where it has a gradient around the blurred light specks in top right corner) . Like a highly compressed JPEG image from AOL days (to speed up page load times).
    4.) Messed with all FireFox, Windows 7, NVIDIA, physical Dell LCD monitor color settings. Even did research on my RoadRunner connection to see if they implemented an accelerator of some sort. Disabled Add-ons one by one re-testing the issue along the way. Problem persisted.

    It's not your graphics card. It's not your OS. It's not your browser.
    It's your internet. I had a broadband card, and I figured out that my ISP (Internet Service Provider) was actually downgrading my image quality to make my internet faster. It's called Network Optimization. Look in the options menu of your broadband connection application (Like if you have T-Mobile or whatever, look in the part the application that connects you to the internet) and see if you can change your Optimization Settings. This should clear things up for you.
    Also, if your internet is really that slow, like mine was, I would suggest getting another provider. It's the best option. Hope that helps. :)

  • How to get crisp jpeg images for slideshow on a Mac with Final Cut?

    Hi, I imported a large number of jpegs into Final Cut Pro and when I export to Quicktime Movie (not modifying the sequence size or settings I notice the quality of the jpeg images looks rather washed out and a bit fuzzy. The image dimensions of the jpegs are actually 2848 x 4272 and I was originally using a sequence setting of 720 by 480 (which scaled the images to about 12%). I experimented with doubling the sequence setting to 1440 by 960 and scaled the images to about 25.5% - still a bit washed out look.
    Basically this will be a presentation on a computer and output via projection. Looking for best possible and clearest photos. I experimented with iPhoto and when you play a slideshow it looks very crisp - this is what I am aiming for. When I export using the Slideshow export at the largest size 640 by 480 in iPhoto to quicktime - the quality seriously deteriorates.
    What would be the best way to maintain the crispness of the photos in Final Cut for an export to Quicktime that would be show on a Mac via a projector? Thank you

    Hi Nick, I do see information on creating a slideshow with Quicktime at: http://www.apple.com/quicktime/tutorials/slideshow.html
    however it appears Quicktime X removed that capability. There is no 'open image sequence' option from the File menu in Quicktime X.
    If I do end up sticking with Final Cut - would you recommend any codec and/or dimension size that would result in the best quality or the most crisp image? I also need a few fade in's and out's on various parts - I don't believe I would have the control without Final Cut.
    Would resizing the image files in Photoshop to 1920 pixels by 1280 before importing them into Final Cut result in crisper images? Thanks.

  • Bridge CC / How to use all cores to generate JPEG images?

    Hi!
    Is there anyway to tell Bridge, that it should use all my cores to generate the JPEG images out of RAWs?
    Actually it uses less then 25% of my CPU performance. I've a Intel Core i7-2600 CPU @ 3,4 GHZ, with four cores and enabled hyperthreading, also eight virtual CPUs.
    At least it could be FOUR times faster, if it would use all available cores, but so I get one preview per second (12 MP RAWs). So I've to wait in case of 100 RAWs round 3:30 minutes. If would use all CPUs, which are available, it could increase speed less then 1 minutes.
    In my case, I've to create often up too 500 JPEGs in one go. So instead of 17-18 minutes it would take less then 5 minues. 12 minutes less!
    I just wonder, why I bought a good PC, if Adobe is not using the power of the CPUs and tries to work parellel instead of seriel.
    As there any chance, or does Adobe have no interest, like it has no interest to speed up LightRoom?
    If there is any chance, I would be very pleased.
    Thanks

    Sorry, I could not know, that issue is caused by the same flaw in the software:
    http://feedback.photoshop.com/photoshop_family/topics/bridge_cc_how_to_use_all_cores_to_ge nerate_preview_images
    http://forums.adobe.com/thread/1316239

  • Playing a series of jpeg images on Firefox (like a video)

    We are having a problem playing a series of jpeg images on Firefox (like a video). It works perfectly on IE, Chrome and Safari.
    Here you can see a demonstration of the problem: [http://www.youtube.com/watch?v=8tG0zuoMbLM http://www.youtube.com/watch?v=8tG0zuoMbLM]
    Our code just loads one Jpeg after another. For some reason this causes Flickering with FF.
    '''How to replicate the problem on our website'''
    You can observe the problem by actually visiting our website. Please follow the link below (use firefox):
    http://www.camba.tv/CameraView.aspx?c=fudraste
    On this page select “Recorded Images” tab and then click “Play” below the image. Please increase play speed by clicking button with”>>” symbol. Once the images are playing you will notice a flicker in Firefox but the same page will not show flickering in Safari or chrome.

    Export to QuickTime Conversion. In format set Image Sequence. In Options pick the format, TIFF would be better than JPEG, which a lossy format. Make folder. Save the images. Process in Photoshop or whatever. Import the images set to one frame or use QT Pro to convert it back to a movie.

  • Marydee-You asked me about resizing apps for jpeg images & how 2 get info

    Marydee- You asked me about resizing apps for jpeg images. And you also asked how to get photo info for each image in iphoto
    Here's what I found in the iPhoto6 Help Menu:
    Showing a photo's image and camera information
    iPhoto stores EXIF information with each photo in your library. This information includes the photo's image size, the date and time it was taken, and the type of camera it was taken on, as well as important exposure information, such as the shutter speed, aperture, and film ISO.
    To show image and camera information:
    Select the photo and choose Photos > Get Info.
    You can also see a photo's title, date taken, rating, format, and comments by clicking the Information button in the bottom-left corner of the iPhoto window.
    Also please take a look at these prior discussions in iPhoto Forum/s:
    http://discussions.apple.com/thread.jspa?messageID=3212997&#3212997
    http://discussions.apple.com/thread.jspa?messageID=4535542&#4535542
    http://kstudio.net/re.html
    Hope the above helps and good luck on this.
    (3) G4 PM's/(3) S-Drives/Sony TRV900/Nikons/6FWHD's/PS7/iLife06/FCPHD/DVDSP/etc.   Mac OS X (10.4.8)  

    Marydee- You asked me about resizing apps for jpeg images. And you also asked how to get photo info for each image in iphoto
    Here's what I found in the iPhoto6 Help Menu:
    Showing a photo's image and camera information
    iPhoto stores EXIF information with each photo in your library. This information includes the photo's image size, the date and time it was taken, and the type of camera it was taken on, as well as important exposure information, such as the shutter speed, aperture, and film ISO.
    To show image and camera information:
    Select the photo and choose Photos > Get Info.
    You can also see a photo's title, date taken, rating, format, and comments by clicking the Information button in the bottom-left corner of the iPhoto window.
    Also please take a look at these prior discussions in iPhoto Forum/s:
    http://discussions.apple.com/thread.jspa?messageID=3212997&#3212997
    http://discussions.apple.com/thread.jspa?messageID=4535542&#4535542
    http://kstudio.net/re.html
    Hope the above helps and good luck on this.
    (3) G4 PM's/(3) S-Drives/Sony TRV900/Nikons/6FWHD's/PS7/iLife06/FCPHD/DVDSP/etc.   Mac OS X (10.4.8)  

  • Image scaling changes

    Before I started here, the team was using FrameMaker 8 and migrating to FM 10. During the migration, we noticed that images in the documents we opened, converting them to FM10, had their image scaling data changed.
    Typically, we acquire screen shots using the highest resolution screen supported - mine is currently set at 1440 x 900. We scale the images to a width of 510 pixels (optimally) but no more than 600 pixels in our screen capture utility. We save the screen shots as Grayscale JPEGs. This process has, historically, provided images that fit our text column flow perfectly.
    In previous versions of FM, the images imported by reference appeared as 100% scaling in the FM image properties. Now, they appear as 75% scaling. We're wondering why and if there is any effects we need to be aware of in terms of PDF and HTML Help file sizes.
    While testing the import process, looking to see if the FM scaling data affected the image size, we saw that the pixel dimensions given by SnagIt varied wildly from the pixel dimensions given by FM. For example, the SnagIt dimensions for one image indicated it was 505x493 pixels whereas FM gave the dimensions of the source file as 507x315 pixels. Both are, as far as I know, giving me the source file dimensions but they are different.
    We might not have noticed this, the images looked okay, but we were carefully going through the transition to FM10 and looking at every detail.
    Question: why is FM10 auto-scaling the images to 75%?
    Question: does this scaling do anything to our output that we need to be aware of?
    Question: why do we get two different dimension data from the two software packages?
    Thanks,
    Wanda

    We  save the screen shots as Grayscale JPEGs.
    Are the screen images contone (e.g. real-world photos, CGI imagery),
    or flat (e.g. dialogs, line art)? JPEG uses curve-matching compression,
    which is great for tones that vary smoothly, but introduces nasty ringing
    edge artifacts on sharp edges of flat tones.
    TIF(zip), uses repeat-count compression, and is both non-destructive to flat
    tone images, and often compresses them more efficiently. We use EPS
    for the import format (no compression) and let Distiller or Acrobat post
    determine the compression to use.
    This process has,  historically, provided images that fit our text column
    flow perfectly.In  previous versions of FM, ...
    What is the target delivery format?
    ... the images imported by reference appeared as  100% scaling in
    the FM image properties. Now, they appear as 75%  scaling.
    In case you want to try it, I have never seen imported EPS objects
    change size when migrating a document to a later rev of FM.
    We import using 96 dpi.
    If the target is PC screen display at 100% page size, that's probably a
    decent target. PC screen resolutions today probably range from 80 to
    110 dpi, and I'd guess that 96 is very close to the sweet spot.
    We use (and I favor) bringing in all contone content at 200 dpi or
    higher. We bring bitmap (bi-level line art) in at 600. But then our
    target media is 600 dpi B&W bitmap on paper. However, we like
    to give web readers of the PDFs reasonable detail in images.
    Apple's "Retina" crusade is trying to move the industry to 300 dpi
    displays. I'd be happy with 200.

  • After rotate, display of large JPEG images very slow.

    I am loading and displaying images using JAI and Java2D.
    When I load a large grayscale JPEG image (300 dpi, letter size), it displays fine.
    After a rotate, the next display is incredibly slow.
    Source is a RenderedImage loaded from a JPEG file using:
         FileSeekableStream ss = new FileSeekableStream(file);
         ImageDecoder dec = ImageCodec.createImageDecoder("jpeg", ss, null);
         RenderedImage source = dec.decodeAsRenderedImage(curPage);
    I create a scaled image using:
         interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
         ParameterBlock params = new ParameterBlock();
         params.addSource(source);
         params.add(xZoom); // x scale factor
         params.add(yZoom); // y scale factor
         params.add(0.0F); // x translate
         params.add(0.0F); // y translate
         params.add(interp); // interpolation method
    RenderedOp image3 = JAI.create("scale", params);
    And display inside the paintComponent() method of my JPanel-derived class using:
         AffineTransform transform = new AffineTransform();
         transform.translate(shiftX, shiftY);
         Graphics2D G2d = (Graphics2D)g.create(); //copy g
         G2d.drawRenderedImage(image3, transform);
    If I add a rotate step after the scale:
         ParameterBlock paramsR = new ParameterBlock();
         paramsR.addSource(source);
         paramsR.add(TransposeDescriptor.ROTATE_90);
         // Create an operator to turn image.
         source = JAI.create("Transpose", paramsR, null);
    Then the next display for a 300 dpi 8 bit grayscale JPEG file can take up to 60 seconds.
    The bulk of the elapsed time is inside: Graphics2D.drawRenderedImage(image3, transform);
    Any ideas what I am doing wrong here?
    I am relatively new to using Java Advanced Imaging.
    Thanks,
    T.J. Brown

    Sorry, a correction.
    The file is actually JPEG-compressed data inside a TIFF file.
    So the decode step uses:
    ImageDecoder dec = ImageCodec.createImageDecoder("tiff", ss, null);
    JPEG inside a JFIF file is much faster.
    Thanks,
    T.J. Brown

  • Using the Camera RAW interface for JPEG images

    I realize JPEG's don't have the information level of RAW files, but does the convenience and speed of the RAW interface not make it worth using rather then going to the usual tools like Levels and Hue/Saturation? I discovered that you can open JPEG images in the RAW interface by choosing File > Open As...and selecting "Camera RAW" as the file format. Here you can not only use the RAW interface but also change the image to 16-bits. I also understand that upscaling an image from 8 to 16-bits doesn't add more information, but would working on it in the RAW interface at 16-bits not produce more subtle changes and give you more control over the outcome.
    Looking forward to some intelligent feedback.
    Deep Woods

    From a mathematical perspective, it would seem that using the extra information in the up-sampling interpolation calculations would be better. The question is whether or not the extra digits in the calculation would produce a difference in the image. I suspect that it would be quite image dependent. Easy enough to test, with the right kind of image, whatever that is?
    Don S.

  • I cannot erase alias JPeg images on a memory card so that it will not accept any more which I try to load onto it, yet there are no actual images available if I click on any of them. The error message states that one or more cannot

    Cannot delete aliases for JPeg images on a lumix camera memory card even selecting individual images anjd trying to move to trash -error35 one or more items cannot be found. No image available on clicking or if card put back into camera-"no images to disply" Yet if try to add more images, message that card is full! Any suggestions?

    Deleting from iPhoto or image capture after import should be fine and shouldn't cause any issues. Deleting from the folder view of finder, can cause issues as the camera can the image is still there. You can try emptying the trash on your mac if you deleted them via the finder, as although you've deleted it, it's only marked as trashed and not actually deleted until you empty the trash - ie it won't relieve the space taken by the files.
    If your still having issues after you try this, you may be best formating the memory card. This will wipe all data on it though, so make sure you do copy anything off that yo u want to keep! Format from the camera, so that choosing the format>erase all option from the menu of most cameras.

  • I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from

    I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from it.  It has worked in the past but I downloaded the update today and photomerge will not work correctly.  Any ideas?

    hedger,
    How do you expect anyone to help when we don't know a darned thing about the file, abut your setup, exact version of Photoshop and your OS, machine specs, etc.?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How to insert a pdf or jpeg image into a blob column of a table

    How to insert a pdf or jpeg image into a blob column of a table

    Hi,
    Try This
    Loading an image into a BLOB column and displaying it via OAS
    The steps are as follows:
    Step 1.
    Create a table to store the blobs:
    create table blobs
    ( id varchar2(255),
    blob_col blob
    Step 2.
    Create a logical directory in the database to the physical file system:
    create or replace directory MY_FILES as 'c:\images';
    Step 3.
    Create a procedure to load the blobs from the file system using the logical
    directory. The gif "aria.gif" must exist in c:\images.
    create or replace procedure insert_img as
    f_lob bfile;
    b_lob blob;
    begin
    insert into blobs values ( 'MyGif', empty_blob() )
    return blob_col into b_lob;
    f_lob := bfilename( 'MY_FILES', 'aria.gif' );
    dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
    dbms_lob.loadfromfile( b_lob, f_lob, dbms_lob.getlength(f_lob) );
    dbms_lob.fileclose(f_lob);
    commit;
    end;
    Step 4.
    Create a procedure that is called via Oracle Application Server to display the
    image.
    create or replace procedure get_img as
    vblob blob;
    buffer raw(32000);
    buffer_size integer := 32000;
    offset integer := 1;
    length number;
    begin
    owa_util.mime_header('image/gif');
    select blob_col into vblob from blobs where id = 'MyGif';
    length := dbms_lob.getlength(vblob);
    while offset < length loop
    dbms_lob.read(vblob, buffer_size, offset, buffer);
    htp.prn(utl_raw.cast_to_varchar2(buffer));
    offset := offset + buffer_size;
    end loop;
    exception
    when others then
    htp.p(sqlerrm);
    end;
    Step 5.
    Use the PL/SQL cartridge to call the get_img procedure
    OR
    Create that procedure as a function and invoke it within your PL/SQL code to
    place the images appropriately on your HTML page via the PL/SQL toolkit.
    from a html form
    1. Create an HTML form where the image field will be <input type="file">. You also
    need the file MIME type .
    2. Create a procedure receiving the form parameters. The file field will be a Varchar2
    parameter, because you receive the image path not the image itself.
    3. Insert the image file into table using "Create directory NAME as IMAGE_PATH" and
    then use "Insert into TABLE (consecutive, BLOB_OBJECT, MIME_OBJECT) values (sequence.nextval,
    EMPTY_BLOB(), 'GIF' or 'JPEG') returning BLOB_OBJECT, consecutive into variable_blob,
    variable_consecutive.
    4. Load the file into table using:
    dbms_lob.loadfromfile(variable_blob, variable_file_name, dbms_lob.getlength(variable_file_name));
    dbms_lob.fileclose(variable_file_name);
    commit.
    Regards,
    Simma........

  • How to load a jpeg image in to a database from a flex2 app

    Hi,
    how ouwld I browse the local fie system, select a jpeg image
    and then save
    it to a database using flex2?
    Anybody know of some sample code that I can look at?
    Thamls

    Hi Thamis,
    Take a look at the flash.net.FileReference class here:
    http://livedocs.macromedia.com/flex/2/langref/index.html
    This is the built in Flash support for file upload. You'd
    handle the upload with a servlet/jsp/etc. server-side component to
    save it to disk or as binary data in a database.
    Best,
    Seth

Maybe you are looking for