Using JAI to discover if a larger image contains a smaller image

Lets say I have an image that contains an icon somewhere in white space that is 500x500 pixels.
I also have an image of the icon itself, say its 50x50px.
What is the best way to make a function called:
public boolean containsImages( Image haystack, Image needle)
that returns true is the image needle is containd in the haystack....
The application is I want to take a printscreen using a Robot and discovering if an icon is turned on or not... I need to do it via print screen because the window containing the icon is a remote-desktop window
Thanks anyone =)
Omid S.

Lets say I have an image that contains an icon somewhere in white space that is 500x500 pixels.
I also have an image of the icon itself, say its 50x50px.
What is the best way to make a function called:
public boolean containsImages( Image haystack, Image needle)
that returns true is the image needle is containd in the haystack....
The application is I want to take a printscreen using a Robot and discovering if an icon is turned on or not... I need to do it via print screen because the window containing the icon is a remote-desktop window
Thanks anyone =)
Omid S.

Similar Messages

  • Dividing One large Image to many smaller images

    Dear Java developers,
    I have 1 Large Image, and I want to divide it
    into many smaller images, But I don't see
    any Java API to make it...
    Anybody can help me ?
    Thanks in Advance,

    I'd guess using BufferedImage and subimages thereof is faster than filtering it. Although it depends much on the implementation of the original image source, and its caching strategies. But it's pretty certain that when you are creating a BufferedImage which is appropriate for you current color model, you avoid most conversions which may be needed when rendering directly from an image source.
    Having said that, the image source and filtering way may even use more memory and cpu than the buffered image way. At least temporary. But the image source is allowed to release almost all memory associated with the image, down to retaining only the original URL.
    In simpler words:
    - With BufferedImage you can be quite sure how much memory it will need. Add up the space needed for the Raster and auxiliary data and there you are. It won't change much over time. But it's not present in JDK 1.1.
    -- Simple, predictable and modern.
    - ImageSource is pretty much opaque in how much memory it will use. However, it's interface allows dropping most resources and re-creating them on demand. Of course, you'll know what it does when you're implementing it yourself. Which I tend to do from time to time.
    -- Complex (flow control), opaque but present in JDK 1.1.
    Your mileage may vary. There would be no challenge in programming if there were no tough decisions to be made ;-)
    /kre

  • Divide images from single master image?

    I have many large images which contain several smaller images each. Is there a way to auto detect and crop these images into separate files? Aperture plug-in? I know it will work in Photoshop Elements, but I don't have that.
    Mike

    Thank you all for the suggestions. I got this pile of images from my father - he probably scanned them on his flat bed scanner years ago.
    Also, in the past I have been unhappy with the auto cropping tools embedded in scanners as they didn't include any rotation corrections (fine angle) - instead they would just crop more of the image.
    Finally, in exploring this issue some I have realized that I can use "preview" to select a part of an image then copy, new, paste and I have a new image. When all images are manually selected then I can import into Aperture, etc... Manual, but it appears to work fine. Not sure if I'm loosing information in the process though - ideas?
    I still am surprised that there isn't a stand along piece of software for doing this automatically...

  • How can I view a series of images in the same image frame?

    I'm an intermediate level user and recently saw a feature on a web site that I'd like to incorporate in my own designs. I'm looking for an instructional link to explain this process. On a published web site there is an image. To the right side and left side of this main image are two small images: a "forward triangle" and a "reverse triangle". When you click on the forward triangle the main image changes to image #2, then again to image #3. Clicking on the left-sided "reverse triangle" takes the user back to image #2, then image #1. All main images are located inside the same frame, it's just that you can click back and forth through a series of half a dozen images. It seems easy, but I just can't find the right instructions. Can anyone suggest a link or two? Thanks!

    From the code
    <script src="javascript/jquery-1.2.1.pack.js" type="text/javascript"></script>
    <script src="javascript/jquery-easing.1.2.pack.js" type="text/javascript"></script>
    <script src="javascript/jquery-easing-compatibility.1.2.pack.js" type="text/javascript"></script>
    <script src="javascript/coda-slider.1.1.1.js" type="text/javascript"></script>
    It's using this script
    http://www.ndoherty.biz/tag/coda-slider/
    See also
    http://jqueryfordesigners.com/coda-slider-effect/

  • Problem Printing Images Using JAI

    I'm using JAI in an application that prints images. My program works fine on my development machine (Windows XP), but when I put it on my Windows Server 2008 r2-64 bit, it crashes for certain images (these are large images of land plats) that go to a particular printer (OCE PlotWave 300) It prints my smaller images that are printing on a variety of printers just fine (images of Mortgages etc..) and it prints everything just fine on my development machine. What could possibly be causing this?
    Edited by: LongStranjeTrip on Feb 2, 2011 4:34 PM
    Edited by: LongStranjeTrip on Feb 4, 2011 8:11 AM

    I'm using JAI in an application that prints images. My program works fine on my development machine (Windows XP), but when I put it on my Windows Server 2008 r2-64 bit, it crashes for certain images (these are large images of land plats) that go to a particular printer (OCE PlotWave 300) It prints my smaller images that are printing on a variety of printers just fine (images of Mortgages etc..) and it prints everything just fine on my development machine. What could possibly be causing this?
    Edited by: LongStranjeTrip on Feb 2, 2011 4:34 PM
    Edited by: LongStranjeTrip on Feb 4, 2011 8:11 AM

  • Image border problem using JAI

    I've written some very simple code to scale an image down to a small
    thumbnail in JPG format but the quality is quite horrible. Is there a way of making it look nicer?
    src = JAI.create("fileload","filepath")
    ParameterBlock params = new ParameterBlock();
    params.addSource(src);
    params.add(xScale);//x scale factor
    params.add(yScale);//y scale factor
    params.add(0.0F);//x translate
    params.add(0.0F);//y translate
    params.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
    dest = JAI.create("scale", params,null);
    I switched to InterpolationBicubic, instead of Interpolationnearest the quality was much better but the resulting image contained borders.
    could some one tell me is there any other way to get better and nicer results.

    Yes you can fix the border problem by setting a render hint to change the way the borders are handled. Something like the following will do the trick.
    You can also use BORDER_WRAP instead of BORDER_COPY, both seem to have a similar result. Mind you I am still very dissapointed with the quality of the bicubic resampling in JAI, but at least this will fix the problem with the borders.
    RenderingHints rh = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
    dest = JAI.create("scale", params,rh);

  • How to resize image in JSP using JAI ??!!

    Please help me how to resize an JPEG image from my JSP, could I use JAI lib ? how ?

    Hello,
    I had the same problem few months ago ( in that case i used Jimi instead of JAI).
    The answer to your question is: use the java class called "Image".
    Infact you can use JAI just for load or save to disk your image that you have to resize and then use the following code to resize the image :
    Image imgResized = img.getScaledInstance(100,1,Image.SCALE_AREA_AVERAGING);
    The object "img" is the image to resize and the object "imgResized" is the image resized with width equals to 100 and with a right height.
    I used Jimi just to save my image and i think that with JAI there is a method to do this.
    You can use JAI to load in memory your image too so you can avoid problem with MediaTraker class.
    I hope that this can help you.
    Cheers.
    Stefano

  • Downgrading Image Resolution Using JAI

    I am interested in downgrading the resolution of TIFF images that I am inserting into a PDF to reduce the document's file size. The TIFF images are either CCITT G4 bitonal or JPEG RGB. What would be the best approach to doing this using JAI?
    I appreciate any suggestions.
    Youssef Eldakar
    Bibliotheca Alexandrina

    Youssef
    The following code will load a TIFF image (or JPEG or some other formats that I can't remember) into a PlanarImage object and then rescale it according to the scale factors and then save as a TIFF.
    For example if you wanted to change a 320 x 240 image to a 160 x 120 use xScaleFactor and yScaleFactor of 0.5.
      public static PlanarImage rescale(String inputFilename, String outputFilename, float xScaleFactor, float yScaleFactor)
            // load the image from the file
            PlanarImage image = JAI.create("fileload", inputFilename);
            ParameterBlock rescaleParameters = new ParameterBlock();
            rescaleParameters.addSource(image);
            rescaleParameters.add(xScaleFactor);
            rescaleParameters.add(yScaleFactor);
            // saving as TIFF is a little more complicated than loading
            try
                FileOutputStream out = new FileOutputStream(outputFilename);
                TIFFEncodeParam parameters = new TIFFEncodeParam();
                ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, parameters);
                try
                    encoder.encode(image);
                    out.close();
                catch (IOException e)
                    System.out.println("Failed to encode the image");
            catch (java.io.FileNotFoundException ioEx)
                System.out.println("Could not write to file " + filename);

  • Problem while loading a JApplet ( which uses JAI ) on Netscape across ssl

    Hi Folks...
    I m having some problem in applet.. can any1 of u guys help me???? My problem is as follows..
    I m having 2 JApplets (Swing applet) one of the applet is using JAI (Java Advance Imaging APIs). I m trying 2 load both the applets in IE as well as in Netscape across SSL (ie thru https protocol) .Both the applet can be loaded on IE across SSL. but when i m trying to load the applet on Netscape, one of the applet which is using JAI is not getting loaded across SSL. The other applet which is not using JAI is running fine across SSL on Netscape also.
    I m getting some exception.. Is this exception comming bcoz JAI is not compatible with Netscape r bcoz of somethinf else??? If it is bcoz of the fact that Netscape does'nt have any support for JAI across SSL. then watz the possible solution 4 that. How can i overcome by this problem. Its very urgent.. i need to do it any how... Plz plz help me out if u guys have any idea abt this.. any help is most welcome..
    My ids r
    [email protected]
    [email protected]
    tks...
    Jameel

    Exactly what exception are you getting? That will really help in determining the problem. Also, do you have the same problems when going over a regular connection (i.e. not over SSL)?
    Kate

  • How to i resize a larger 72ppi image to better quality smaller image but for correct size to paste into flyer

    Hi, I am trying to resize a larger 16cm wide image saved at 72dpi to a smaller better quality 5cm wide image for invites for an art exhibition I am having. I figure there must be lots of information in the pic given that it is large, I just want to condense it into a smaller image. If I adjust the size to 5 cm wide it changes the dpi to 230 which would be better for printing (the 72 dpi is way too grainy). However when I paste it into the flyer I am making in photoshop it pastes as a massive picture. I then tried to drag the corners in to make it the right size and it became even grainier than a 5cm wide 72dpi image. I hope that makes sense to someone. So basically I need a 5cm wide document size that I can put in my small flyer that is the best quality I can make it! Thanks in advance!

    Up-sampling from 72ppi to 300-600ppi can result in blurry images.  It's always best to start with a good quality, high resolution image if you can.  Go to Image > Image Size.  When up-sampling, use Bicubic Smoother setting.  When down-sampling, use Bicubic Sharper.  See screenshot.
    Nancy O.

  • Small iMage pop up larger image then close

    Hi All
    First off I am not a coder :)
    I am building a website and would like to take an image on
    the page, be able to click on image to create larger image (pop up
    on same page) and then be able to close larger image back to
    original image.
    I am using CS4
    Thanks in advance
    Jay
    pcb4u at verizon dot net

    Do I replace the
    seelarger.php?im=<?php echo urlencode($image); ?> code
    you gave me before
    with
    seelarger.php?im=<?php echo urlencode($image);
    ?>&amp;title=<?php echo
    urlencode($title); ?>
    and can you confirm what code I need on the seelarger.php
    page.
    as I replaced the seelarger.php?im=<?php echo
    urlencode($image); ?> code
    with the new one you gave and nothing happened.
    Thanks
    Matt
    "David Powers" <[email protected]> wrote in message
    news:ej84c4$283$[email protected]..
    > matt wrote:
    >> Excellent.... worked perfectly thankyou.... now how
    do I do the same with
    >> the title.... on the image page I have it as
    <?=$title?>
    >>
    >> And on the seelarger.php I have it as echo
    >> "<title>{$_GET[title]}</title>";
    >
    > You need to pass the variable from one page to the next.
    It doesn't just
    > appear by magic.
    >
    > seelarger.php?im=<?php echo urlencode($image);
    ?>&amp;title=<?php echo
    > urlencode($title); ?>
    >
    > --
    > David Powers
    > Adobe Community Expert
    > Author, "Foundation PHP for Dreamweaver 8" (friends of
    ED)
    >
    http://foundationphp.com/

  • Using Pages 5.2.2: When I drag an image into my document, I lose the related text.  I can crop the image, make it smaller, but it is surrounded by blankness that overrides the text.  Help?!

    Using Pages 5.2.2, MacBook Pro, OSX 10.9.5:  I cannot drag an image into my document without it obliterating the text.  Even after re-sizing,  the image just becomes small inside a larger blank area that appears to cover the saved text.  Help?

    Using Pages 5.2.2, MacBook Pro, OSX 10.9.5:  I cannot drag an image into my document without it obliterating the text.  Even after re-sizing,  the image just becomes small inside a larger blank area that appears to cover the saved text.  Help?

  • How to configure an image to specific parameters.  Needed: no more than 1200 pixels on long side   jpeg format   no less than 5 mb.  Image will be viewed on large standup screen.(original image is 22 mb)

    I often have requests for images to be sent within certain parameters:  such as "no longer than 1200 pixels on longest side + jpeg format + file size no less than 5 mb."  Images will be viewed on a large stand up screen.  My original image sizes are usually around 22 mb.  When I use Export and specify 1200 pixels (quality setting is all the way over to 12), Save the file to a folder on the desktop, and then open the image in Preview, Inspector shows that the file size is now 233 KB.  How do I meet all specifications without reducing the image size so drastically?
    Thank you.

    . Pardon, it reduced it down to 833 KB, not 233 (I mixed it up with another image) from the Original image of 22 MB, RAW.  Should it reduce it down that much??
    That will depend on the amount of of detail in your jpeg. Given a certain pixels size and level of quality, a jpeg with many details will require a larger filesize than a jpeg with large plain regions of constant color.
    Is 833 KB a big enough file size to view on a big screen?
    The file size is really unimportant for the quality. What will count is the pixel size and jpeg quality you set. What is the pixel size of the large screen? That should match the pixel size you are using in your export preset. 1200 longest dimension is extremely unlikely for a large screen. Even the 17" display of my MacBook Pro has a larger pixelsize of 1920x1200.
    I am sharing William Lloyd's doubts, that the specifications you were given are correct.  I'd try to export with a larger pixelsize and a high jpeg quality - perhaps 10.
    If you export with 10 Megapixel  and a good jpeg quality, you will probably get a 5MB file, not that the size should matter.

  • Image Mouse Overs = Small source pic to large mouse oevr

    Hi
    Just need to pick someones brains really ....mouse overs are
    fairly straight forward if you wanna swap the same size image but
    what if the mous eover image you want to display is larger ?
    I figured this out years ago and now cant remember for the
    life of me how to do it ...I think you edit the script dreamweaver
    puts in...
    So to recap ...small source image then mouse over to display
    a large one...also can you re do the positioning on where the mouse
    over displays ?

    You can do this many ways ways -
    1. Don't use swap image - use Show/Hide layer instead. Have
    the alternate
    image in a hidden layer that is shown when the trigger is
    'tickled'. Using
    this method you can have images that are any dimension.
    2. Use swap image, but remove the dimensions from the
    original image's tag,
    i.e., change this -
    <img name="original" width="150" height="220" ...
    to this -
    <img name="original" ...
    Now when you swap in your offsize image, there is no
    predefined size to
    change it to. Be aware that this method may well result in an
    unpleasant
    and undesirable 'rearrangement' of your page layout as it
    adjusts to your
    new image's dimensions.
    3. Pad the smaller image with canvas background color on all
    sides so that
    all the images *are the same size*.
    4. Use a SetText behavior to change the image reference in a
    container on
    the page so that it will show the desired larger image in the
    proper place.
    You can see an example here -
    http://dreamweaverresources.com/tutorials/settextoflayer.htm
    5. Use the PVII ShowPic extension -
    http://www.projectseven.com/
    Take your pick....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "crashpolo" <[email protected]> wrote in
    message
    news:fpjrlm$83a$[email protected]..
    > Hi
    >
    > Just need to pick someones brains really ....mouse overs
    are fairly
    > straight
    > forward if you wanna swap the same size image but what
    if the mous eover
    > image
    > you want to display is larger ?
    >
    > I figured this out years ago and now cant remember for
    the life of me how
    > to
    > do it ...I think you edit the script dreamweaver puts
    in...
    >
    > So to recap ...small source image then mouse over to
    display a large
    > one...also can you re do the positioning on where the
    mouse over displays
    > ?
    >

  • Filling shapes using JAI

    hi,
    how can I fill a shape using JAI ? Is it a kind of convolution operation ?
    I have binarized my image, and now I have a group of black pixels (we say, an hole) inside a face of white pixels.
    thank you

    My solution would be to work with the image in its raw format. Extract the image into a 2 dimensional array, loop throught the rows and columns and compare to your zero crossing window detector. after you have aquired the new image array, you set pixels that are next to an edge 0 and the rest #ffff. this will create a binary image (black and white) with the edges black and rest white. Be careful of your conventions used to determine what are edges. This may seem primitive, but thats just the way i think :P
    -fastrike

Maybe you are looking for