Problem rotating a non-square image

I am getting very strange results trying to use an AffineTransform to rotate a rectangular but non-square image. If I pre-define a destination Image, then after using the AffineTransform to filter the source, most of the destination image is black (because the resultant image isn't positioned correctly). This is especially true when I try to rotate an image 90 degrees counter-clockwise, in which case I don't know what happens to the rotated image.
If I try to just let the filter method produce a new image to return to me, it returns a completely square image, which cuts off some of the image if it isn't square. I'm really lost as to what to try next. Here is my code...
at = new AffineTransform();
at.setToTranslation( roiImage.getWidth()/2, roiImage.getHeight()/2);
at.rotate( Math.toRadians( angle ) );
at.translate( -roiImage.getWidth()/2, -roiImage.getHeight()/2);
AffineTransformOp atOp = new AffineTransformOp( at, renderingHints );
/* construct the new destination image with the correct post-rotation bounds */
BufferedImage rotatedImage = new BufferedImage( roiImage.getHeight(), roiImage.getWidth(), roiImage.getType() );
atOp.filter( roiImage, rotatedImage );
roiImage.flush();
roiImage = rotatedImage;
Any ideas on why this might be acting so strange? Can I even use an AffineTransform to rotate a non-square image?

could you provide me a code sample? I've tried doing it that way as well, but I'm still having troubles. I think I'm just missing something small and simple :-(
thanks for the quick response.

Similar Messages

  • Fourier transform of non-square image

    Hello,
    I'm trying to compute the FFT of a greyscale image (1920x1200 pixels) but I cannot find a way to do this do an image that isn't perfectly square.
    Any help would be much appreciated thanks.
    Regards
    DJC

    I don't see any limitation with that respect when I do an image FFT.
    The IMAQ FFT function works fine with my image (2272x1704).  You do need a complex image type though.
    In addition the FFT function is orthogonal so if you wanted to, you can convert the image to an array and perform an FFT on each row of the image and then one on each column and get the 2D answer you are looking for.
    Message Edited by rpursley8 on 02-08-2008 10:30 AM
    Randall Pursley

  • How do I make a div tag trace a non-square image?

    Please look at the following screen shot:
    On the right, you are looking at the "Home" button of a navigation bar, and I want to see just the gray button without the triangular white parts to the left of the vertical line in the middle that are included with the div tag. I thought I would be able to make the background of the nav bar transparent and thus have the button overlap the glow / shadow surrounding the container without seeing the white parts by adding "background-color:transparent;" to the nav bar style sheet, but that didn't work.
    What is the easiest way to accomplish what I am trying to do? If I am on the right track with making the background transparent, what could have gone wrong? Any help would be much appreciated.

    In Photoshop...
    1. Make sure any background is turned off in the layers palette so you can see the checkerboard background
    2. Choose File > Save For Web
    3. Select .gif from the dropdown menu
    4. Make sure Transparency is checked.
    5. Save

  • Using non-square template images

    Is there any possibility of using non-square templates in IMAQ Match Color Pattern? For example, I need to find predefined circle in the image, but in case of using it as a template, it will be surrounded with zero pixels. Would it influence on searching results?

    To do color pattern matching, you will always have a rectangular template image.  Depending on your application you may want to try doing geometric matching to limit your image to only that portion that you are wanting to search through.
    Regards,
    Jasper S

  • Problem rotating a large image

    Application description:
    A JFrame with a control panel at the bottom, which contains a couple of JSlider's which controls the scaling, translation and rotation of a BufferedImage using an AffineTransform.
    JDK used:
    1.5.0_04
    Problem description:
    The application works fine when using a "normal" sized image. But when I use a large image (1600x1200) the application seems to freeze. The GUI isn't drawn, just the infamous grey rectangle. I've narrowed it down to the rotation. If I comment out the AffineTransform.rotate call, the application works fine and the very large image is displayed in all it's glory, with translate and scale still applied.
    Is this due to some limitation of AffineTransform?

    Scale and translate would be less intensive than
    rotate.possibly, but my guess is probably not.
    If you have a world matrix that everything gets multiplied through, rotate, tranlate and scale all should be pretty fast.
    To rotate such a large image would be very cpu
    intensive and probably require a substantial amount
    of memory. You may want to check your computerAgain maybe, but IMO very unlikely. If Java uses a world matrix (and I've got no idea how else it could do things like scale or rotate) then there should be no or almost no penalty for transformations. And you certainly wouldn't need any more memory.
    performance during the operation to determine if your
    computer is being bogged down.Would be difficult to test for individual graphics operations, but you could check as to whether the CPU gets pinned while painting.

  • Problems to add a background-image to the widget Spry MenuBar!

    With DreamweaverCS4 version 10.0 Build 4117, (italian language) I have tried to add a Spry MenuBar to the one website page.
    But the problem is that I haven't understood where add my property "background-image": url(../immagini/Menu_Button_01.gif).
    In the Application Page of Dreamweaver I have this screenshot:
    But in the Preview Window of InternetExplorer 7 I have this strange behavior:
    The "Menu_Button_01.gif" are a rounded square button made with PhotoshopCS4 and have a transparent background.
    In the IE7 MenuBar doesn't appears as expected, without the transparent background!
    1) How can I do to show my "Menu_Button_01.gif" image as transparent background in the MenuBar?
    2) What is the correct CSS Style Rule to apply the "background-image" property?
    (Example: "ul.MenuBarHorizontal li"? Or "ul.MenuBarHorizontal a"? )
    3) Should I also apply the property: "background-color:transparent"? Where? What is the specific CSS Style Rule?
    I have uploaded my little local WebSite to Rapidshare (100KB):
    http://rapidshare.com/files/370735082/Test_Spry.zip.html
    Please download it to inspect my problem.
    Please response me!
    Horsepower0171.

    For a starter, you should not put your background style rules in the following. The accompanying descriptions will tell you this.
    /* Menu item containers, position children relative to this container and are a fixed width */
    ul.MenuBarHorizontal li
        margin: 0;
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        position: relative;
        text-align: left;
        cursor: pointer;
        width: 116px;
        float: left;
        background-image: url(../immagini/Menu_Button_01.gif);
        background-color: transparent;
    /* Submenus should appear below their parent (top: 0) with a higher z-index, but they are initially off the left side of the screen (-1000em) */
    ul.MenuBarHorizontal ul
        margin: 0;
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        z-index: 1020;
        cursor: default;
        width: 116px;
        position: absolute;
        left: -1000em;
        background-image: url(../immagini/Menu_Button_01.gif);
        background-color: transparent;
    Then when you apply style rules to
    /* Menu items are a light gray block with padding and no text decoration */
    ul.MenuBarHorizontal a
        display: block;
        cursor: pointer;
        padding: 0.5em 0.75em;
        color: #333;
        text-decoration: none;
        background-image: url(../immagini/Menu_Button_01.gif);
        background-color: transparent;
    this will be overridden by the following rules. They replace your image with an arrow image.
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenu
        background-image: url(SpryMenuBarDown.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenu
        background-image: url(SpryMenuBarRight.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover
        background-image: url(SpryMenuBarDownHover.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenuHover
        background-image: url(SpryMenuBarRightHover.gif);
        background-repeat: no-repeat;
        background-position: 95% 50%;
    There are one of two solutions
    If you do not want and arrow, simply set background to none in the above four instances.
    If you do want an arrow, include a down arrow image in a second Menu_Button_01.gif image called Menu_Button_01_DownArrow.gif or similar as well as a third one for your right arrow image.
    I hope this helps.
    Ben

  • Dealing with non-square pixels from video capture (CS3)

    Hi all,
    This is the problem I have : I watch a video on my PC using any utility such as, for example, CyberLink's PowerDVD. I pause the movie to capture a frame to the Clipboard, then I paste it into PS CS3 via a newly created document.
    Because the movie was shot and recorded on the DVD in widescreen format, therefore using non-square pixels (wider than they are tall), the still image in PS appears "shrunk" horizontally. I then go to Image|Pixel Aspect Ratio and set the ratio to, say, "D1/DV PAL Widescreen (1.42)", as I am in PAL-land. The still image now looks fine, and I can save it, for example in TIFF format ; it will retain its "non-square pixel" attribute, with the black bands on top and at the bottom.
    However, what I utimately want to do is use that still image on the Web, so I need to save it as a JPEG image, and this is where the problem happens : the JPEG conversion reverts those pixels to square ones, whether I use the "Save for Web and Devices..." option, or just the "Save As..." one.
    How can I turn my very heavy TIFF into a much leaner JPEG, while retaining the non-square pixels that give the image its correct proportions ? Is there a way around this problem ?
    I'm not used to dealing with non-square pixel images, so any help and tip will be greatly appreciated. Many thaks in advance.
    Dominic.

    As Zeno said, you can simply copy&paste. Also, there is always an equivalent square pixel format for each anamorphic format that can fully accommodate the image, which would be 1024x576 for PAL widescreen. For more info on PAR conversions, I recomemnd you do some reading in the online help files for After Effects or Premiere Pro.
    Mylenium

  • Scanning stills in PShop (square vs non-square pixels)

    Hello,
    We need to scan hundreds of still photos for a documentary. We've done this before and are familiar with the whole square pixels (PhotoShop) and non-square pixels (FCP). By the way, we're using PhotoShop 7 and FCP 5.
    In the past we've adjusted our images in PShop (reducing the height) before importing into FCP, and things have turned out nicely.
    But before we tackled this new project, we ran a test and were surprised by the results.
    I don't get the following:
    1. If I make a test image (a red circle) in PShop 7 with an image size of 720x540 pixels, the image looks correctly proportioned in PShop.
    2. If I then make a second test image (the same red circle) -- or duplicate the file from step one -- and then adjust the image size to 720x480, the image looks squished in PShop -- it's an ellipse. But this second version SHOULD be just right for FCP 5.
    3. But when I import both files into FCP 5, they BOTH look just fine. They look exactly the same on the monitor (well, the second one seems to have slightly cleaner edges).
    4. When I analyze each clip's Motion tab, FCP has automatically Distorted the 720x480 PShop file by -12.5 -- and it looks fine: a nice round ball. Meanwhile the 720x480 PShop file (the one adjusted in PShop for FCP) has NO Distortion, looks exactly the same. Both versions are perfectly round in FCP. You can toggle from last frame to first frame across the edit and nothing changes.
    Hmmm, is FCP recognizing a sq pixel image and automatically adjusting? And if so, how does it know to distort one file but not the other?
    Then it gets more interesting when I scan a test photo and:
    5. I scan an image at 300 dpi (overscanned so we can move on the image in FCP) and the image is 2084x1488. When I bring this image into FCP 5 (or in FCP 4 for that matter) ... anyway, when I bring this image into FCP 5 if looks great even though it has square pixels and has NOT been prepped in PShop for FCP. It has NOT been squished by FCP. When I check the motion tab, it has been scaled down to 34.55% (that's fine) and distorted by -12.5. It's behaving like the round ball test in No. 1 above.
    6. Meanwhile if I take this same image and adjust it for FCP (2084x1324) and bring it into FCP, it looks just right, too. The motion tab shows that FCP has scaled it 38.83% (that's fine) but now it has ALSO distorted it by -12.5. So it is NOT behaving like the ellipse in No. 2 above (which had ZERO distortion)?
    Regardless, I wonder if any one can tackle this so we understand what's gong on. And the big question is: Why are we taking that step to prep the PShop files for FCP, if FCP seems to handle either version properly? We'd save a lot of time if we didn' take this step in PShop for hundreds of photos ...
    Thanks in advance for taking time to comment. This is a wonderful forum and we're always amazed at how kind and sharing contributors are.
    Brad

    "FCP has automatically Distorted the 720x480 PShop file by -12.5"
    That should probably read 720x540.
    Yes, FCP does the distortion automatically. It's done this since v3. The problem is, as you've noticed, it doesn't do it nearly so well as Photoshop. Yes, you could let FCP do it for you, but it will soften the image more than you might like. There is also one caveat. This only works for flattened images, images imported as graphics files. Other PSD files with layers or transparency that import as sequences will not be automatically resized when they are placed inside another sequence.

  • Book Non-Pick Images confusion

    I am totally confused and frustrated. I am trying to create a photo book for the first time and am working on one within a particular project. I have an edited color and black and white versions created from every master shot.
    When I try to place an image on the photo book I get a bizarre message that tells me I can tried to use a "Non-Pick Image." What difference should it make?
    If I select the image I want and make it the pick in the stack, it moves to the top of the stack, but the little check mark icon doesn't change and it STILL won't let me use the image I specified as "the pick" on the book.
    Why do I need to use strictly "the pick" image from a stack? Makes it impossible to use the same image from a stack more than once. Nothing I seem to do allows me to use anything but the master image.
    This shouldn't be this hard. I see the image I want, I drag and drop it where I want and I'm done. How do I get around this bug/feature?
    Thanks.

    I experienced another side effect to this 'feature', and in figuring it out, I think I have the answer to your question. The quick answer is to unstack everything, or create new versions. If you want to understand what's going on, and learn the third way, read on...
    There is a tiny mention in the manual that Stacks contain a series of related images, and one pick. This 'one pick' fact is very important. Stacks allow you to group images, but you can only designate ONE IMAAGE from the stack as the one to use. (The 'Pick'.) All the others in the stack are preserved in case you want to use one of them later instead, but they are basically hidden and can't be used in albums or books (I think). So, one pick per stack, and that is the left-most image (the one that stays on top when the stack is closed).
    There is one confusing exception to this. You can designate another image in the stack as the 'Album Pick'. This tells Aperture that for this album only (or book), use the image in the stack with the check mark instead of the stack pick. You can set an Album Pick by selecting the image and choosing Stack > Set Album Pick (or something -- don't have Aperture open right now).
    I haven't tried this yet, but I think if you make one image in the stack the Album Pick, then you can use two images from the same stack: the Stack Pick, and the Album Pick.
    I still don't really get why.
    Here is the scary side effect with books. BEWARE! So, I spent hours and hours building a 40 page book. I wanted two versions of the book -- both mostly identical, but a few pages were to be different in the second one. So, I got the first book perfect, adjusted all the images, proofed it, etc. Once I was satisfied, I duplicated that book and intended on making the few minor changes to the duplicate. Well, after I while, I noticed in shock that some images in the duplicate book did not have adjustments applied to them. After more investigation, I discovered that these 'non-adjusted' images were actually DIFFERENT IMAGES! Whereever I had used images from stacks in the first book, the duplicate book used some other images from the same stack!! This was disturbing!!! Such a major change, and NO NOTIFICATION.
    I don't fully understand this, but basically, if you unstack the images, or use the Stack Pick and Album Pick, or create new versions of the images, you will avoid this problem.
    So, Stacks are powerful and can be confusing. They are more than neat little organizers as I found out -- not at all like iPhoto's Events.
    Does anyone have anything to add? What am I missing here?
    Thanks

  • Is it possible to load a non-standard image using some Java API?

    Hi,
    My "problem" is:
    1. I have an image called "mediterranean_sea.IMG" (non-standard image format)
    2. I need to process it (histogram, palette, etc).
    3. I'm wondering if it is possible to load this image an process it using some Java API.
    4. I've tried to do this using JAI but I think that this API only works with TIFF, PNG, JPEG, etc.
    Any idea?
    Thanks in advance,
    Roger

    [url http://forum.java.sun.com/thread.jsp?thread=468188&forum=31]Cross-post

  • Non photo images into photo book

    Can I drop a non photo image from the internet into a photo book (a cartoon picture for example)?  I have tried saving the image to iPhoto but then can not seem to drag it into the frame in the book.

    It depends on the format of that the image is saved in. Jpegs no problem, other formats there may or may not be.
    That said, Apple may baulk at printing images that you do not have copyright on.

  • Urgent!Java Frame Cutting according to non-rectangular image (Transparency

    Urgent-Java Frame Cutting according to non-rectangular image (CrossPlatform - Transparency)
    hi, i want to make the frame transparent in order to make a skin like Windows Media Player . skin is non-rectangular how should i make the frame transparent i am using the JWindow as the container. Plz guide me any idea. as an example i have a JWindow i put a non-rectangular image on it via Jlabel . now i want to make the edges of JWindow outside the boundery of the image transparent ... so that my frame seems like a non-rectanguar image . How i do that? But i need a cross platform kinna thing in java especially for windows/mac/linux
    PaulFMendler :: thanks for ur help i looked at the code but it seems to be windows dependent. i need cross-platform way of producing abt effects. please contact me even on my email >> [email protected]
    Waiting ......

    Check out the link shown below:
    http://forum.java.sun.com/thread.jsp?forum=4&thread=391403
    The posted code has slight problem when moving the JWindow around but you can get a pretty good idea on what has to be done.
    ;o)
    V.V.

  • ITunes distorting non-square cover art

    I have some non-square album art that displays in the now playing/selected window with black bars at the top and bottom as expected.  However, the album art is stretched to a square in grid view.  This happens only to some non-square artwork.  For example, Jimmy Eat World's Stay On My Side Tonight is stretched to a square, but Mutemath's self-titled remains a rectangle.  I understand that iTunes resamples album artwork, but how/why is it changing the shape?

    3. Use Media Monkey to remove the embedded artwork in the individual tracks *directly off the iPod* -- not iTunes.
    I've posted elsewhere that artwork seems to take up about 0.5% of the average music file. Removing all artwork on a 160Gb iPod (or 148Gb when 1Gb = 2^9) would save about 0.75Gb - hardly worth all the effort I'd have thought.
    4. Non-square artwork gets resized/cropped as viewed on the iPod.
    While the artwork is resized to fill the display area as far as I can tell it isn't cropped and will retain the original aspect ratio. Generally images that are wider than they are tall break up the smooth line of albums in cover flow and are quite easy to spot.
    tt2

  • Save jpg with non square pixels

    How do I save as jpg and retain the non square pixels?
    Thank You,
    Tom

    t_Mc wrote:
    You are never going to actually see a non-square pixel JPG image on your square pixel computer monitor.
    Well, I just showed you one.
    No you did not. Our displays only show square pixels.
    t_Mc wrote:
    WHY?
    Are you yelling?
    Where will this image appear? Why do you need PAR if it looks "perfect" on the web without it? What is your output intent? 800x533 is not a video dimension.
    That is not important.
    I asked WHY because you started this discussion with extreme ambiguity. Others have typed many words to try to help you but you have helped no one in return by explaining yourself and what you are trying to do.
    t_Mc wrote:
    Eh... you (and every other photographer with javascript gimmicks) may want to re-evaluate how you post and "protect" images. PAR is not much of a step up from what you have.
    You making RUDE assumptions that are ridiculous This is only the second question I have asked. Thanks for the help lady!
    If I wanted to be rude, I would let you continue to waste your time on pointless techniques that really do not protect your images.
    You can prevent others from making assumptions by...
    fully explaining what you are trying to do!
    EDIT: oy, kids!

  • AME - Windows Media export, default templates and non-square pixels

    In Adobe Media Encoder the default Windows Media export templates have non-square Pixel Aspect Ratio.  In Windows Media Player 9, if you play AME's wmvs with non-square pixels all you get is a vertical line a few pixels wide (though they play fine in WMP10 & 11).
    There is definitely a problem with non-square pixels.
    Using AME, if you create a PAL wmv (720x576 with DV PAL P.A.R.) you get the display problem in WMP9, whereas a D-1 PAL wmv (768x576 with square P.A.R.) will display fine.  If you encode the same content with exact the same settings (codec, resolution, etc) with Microsoft's Windows Media 9 Encoder, the resultant output plays fine regardless of the P.A.R!
    One for you chaps at Adobe I think:
    If Windows Media Encoder can create WMP9 compatible wmvs, why can't Adobe Media Encoder?
    or if there is a problem with non-square PARs, then why is it an option on export - remove it until it is fixed?
    Any support would be greatly appreciated.
    Edmund Barton
    I'm using Prem 4.1 with AME 4.1 against Windows ME 9.  WMP9 is the base player we have to support, so upgrading all the players isn't a option.

    If you can't upgrade the players, then using Windoes Media Enoder may be your only option.  Adobe just came out with a 4.1 patch, so it's unlikely you'll see any more 'fixes' in the very near future.

Maybe you are looking for