Image Interpolation - Need different approach

I'm having problems with built in Java image interpolation methods and haven't had any success finding a way to create my own, or using a different existing one. Basically I'd like to interpolate using a peak-picking method, similar to nearest neighbor except that it will consider all neighbors and take the value that has the highest alpha value. The overall goal is to never throw away the highest value when scaling down. An example would be an image that is 2x4:
[120][50][75][150]
[100][80][100][10]
If I scaled the image down to 2x2 the resulting image would look like:
[120][150]
[100][100]
The values above represent the alpha values in each pixel. Not sure if this "peak picking" method has a mathematical name so I'm not sure what to search for. Any help would be greatly appreciated.

That's not really similar to nearest neighbor at all, but here's a start
    public static BufferedImage customResize(BufferedImage src,
                                            int targetWidth,
                                            int targetHeight) {
        BufferedImage scaled = new BufferedImage(targetWidth,
                                                 targetHeight,
                                                 BufferedImage.TYPE_INT_ARGB);
        int srcWidth = src.getWidth();
        int srcHeight = src.getHeight();
        float ratioX = ((float) srcWidth) / targetWidth;
        float ratioY = ((float) srcHeight) / targetHeight;
        for (int x = 0; x < srcWidth; x++) {
            for (int y = 0; y < srcHeight; y++) {
                int beginNearestX = (int) Math.floor((x - .5f) * ratioX);
                int endNearestX = (int) Math.ceil((x + .5f) * ratioX);
                int beginNearestY = (int) Math.floor((y - .5f) * ratioY);
                int endNearestY = (int) Math.ceil((y + .5f) * ratioY);
                int peakPickARGB = 0;
                int peakAlpha = -1;
                /*traverse the area of pixels in the source image that are
                 *mapped to the pixel in the scaled image*/
                for (int x2 = beginNearestX; x2 <= endNearestX; x2++) {
                    for (int y2 = beginNearestY; y2 <= endNearestY; y2++) {
                        if (x2 < 0 || x2 > srcWidth ||
                                y2 < 0 || y2 > srcHeight)
                            continue;
                        int srcRGB = src.getRGB(x2, y2);
                        int alpha = (srcRGB << 24) & 0xff;
                        if (alpha > peakAlpha) {
                            peakAlpha = alpha;
                            peakPickARGB = srcRGB;
                //set the the "peak-pick"
                scaled.setRGB(x, y, peakPickARGB);
        return scaled;
    }I tried to keep the code simple so you can see how it might be done, but there are certainly some good optimizations that can be made. And this "peak-pick" interpolation won't really work well when scalling up an image.

Similar Messages

  • Need help with Different approaches to setting variables in a Flash movie in Adobe Flash CS3 Professional Version

    Hi,
    I'm using Adobe Flash CS3 Professional version of Flash
    software,
    I need help and guidance on
    Different approaches to setting variables in a Flash movie,
    what I should do in the fla file, and in the html file.
    Thanks, Gil

    Hi petro_jemes,
    Just a little claritification, you need to add the value to the variable "[string]$ou", and also change the language in the variable "$emailbody" in the function "Get-ADUserPasswordExpirationDate".
    I hope this helps.

  • Image processor script and image interpolation setting (cs3)

    Hi all,
    I'm using Bridge & Photoshop CS3 (mac) to process batches of photographs. I've discovered that the script "Image Processor" does not take into account the "image interpolation" setting of my General Preferences in Photoshop.
    It's very painful, because I cannot use "Image Processor" any longer, as it produces soft images where I need sharp ones (my default for "image interpolation" is "bicubic sharper".
    Any idea/workaround?
    thanks
    Patrick

    This is the change I made in CS5 fit image
        // resize the image using a good conversion method while keeping the pixel resolution
        // and the aspect ratio the same
        //app.activeDocument.resizeImage(newWidth, newHeight, resolution, ResampleMethod.BICUBIC); Commented out JJMACK
        if ( newWidth > app.activeDocument.width || newHeight > app.activeDocument.height ) {
            if (!limit) {app.activeDocument.resizeImage(newWidth, newHeight, resolution, ResampleMethod.BICUBICSMOOTHER);}
        else { app.activeDocument.resizeImage(newWidth, newHeight, resolution, ResampleMethod.BICUBICSHARPER); }
    Note: Adobe choice to use BICUBIC is probally the best choice for users in general. For I find an images has been sharpened before its downsizes, downsizimg it using BICUBICSHARPER  is not the best choice then.

  • How can i create a .mov file from image sequence with different durations

    how do u create an image sequence with different durations? image one stays for 10 seconds and image two may stay for 30 and so on. each one has a custom duration. can this be done with an apple script or a text file saved as an mov file?

    Hello Omar,
    The example code Programmatic Printing of TestStand Reports - Modular contains a sequence that will convert an XML file to an HTML file given the XML file's path and the path to the stylesheet.  It may need to be altered to fit with the modifications you have already made to the report generation routines, but I think it should definitely get you off on the right foot.  Let me know if you have any questions!
    NickB
    National Intruments

  • Retrieve nested LDAP groups independent from the network env. (five different approaches)

    Hi all,
    I want to retrieve a list of nested LDAP groups per user from the Active Directory. I have been searching google for half a day now, but I'm still not sure what approach to use. I have the following requirements:
    * The script/program must run in different network environments (I can't be sure if there is a global catelog or AD DS or AD LDS, etc). I will write my own program.
    * The membership info will be used in combination with directory ACL's and must be as complete as possible (global groups, universal groups, local groups, perhaps different domains). Distribution groups are not really necessary, because they are not used in
    the directory ACL's.
    * It would be nice to support other LDAP implementations than Active Directory using the same code, but that not a hard requirement. I could use another approach to support a different LDAP.
    Now I have figured out five possible approaches (info comes from different sites, please correct me if I'm wrong):
    1) tokengroups attribute:
    - The attribute contains Univeral groups of the forest, global groups from the local domain, domain local groups from the local domain (assuming native mode) and local groups from the local machine.
    - Returns a list of SIDs which will have to be translated to group names
    - The tokenGroups attribute exists on both AD DS and AD LDS
    - For AD DS, the tokenGroups attribute is not present if no GC server is available to evaluate the transitive reverse memberships.
    - quote from site "Now that I have had a chance to test it though I can definitely say that tokenGroups WILL get the Universal groups from the other domains even if is NOT a GC. I just did it in my test lab."
    - Token Groups cannot be retrieved if no Global Catalog is present to retrieve the transitive reverse memberships.
    2) tokenGroupsGlobalAndUniversal
    - A subset of the tokenGroups attribute. Only the global and universal group SIDs are included.
    - If you want consistent results, read tokenGroupsGlobalAndUniversal that will return the same result no matter which DC you are connected to. However, it will not include local groups.
    - other source says "tokenGroups will give you all the security groups this user belongs to, including nested groups and domain users, users, etc tokenGroupsGlobalAndUniversal will include everything from tokenGroups AND distribution groups". Not
    sure if this is correct, I think it doesn't contain local groups.
    - The tokenGroupsGlobalAndUniversal attribute exists on AD DS but not on AD LDS.
    3) LDAP_MATCHING_RULE_IN_CHAIN / 1.2.840.113556.1.4.1941
    - Use a recursive search query which returns all nested groups for user at once.
    - Returns all groups except for the primary group
    - It's a fast approach, see performance test from Richard Mueller:
    http://social.technet.microsoft.com/Forums/fr-FR/f238d2b0-a1d7-48e8-8a60-542e7ccfa2e8/recursive-retrieval-of-all-ad-group-memberships-of-a-user?forum=ITCG
    - It only works on Active Directory, not for other LDAP implementations
    4) Recursive retrieval of the memberOf attribute
    - Retrieves all groups except the primary group. (also local groups from other domains??)
    - works for all LDAP implementations
    - executes a lot of queries to the LDAP, especially if you want to scan all users/groups (perhaps limited on OU, but still)
    5) Store memberOf attribute in local database and calculate the nested groups using recursive queries to the local database
    - No heavy load to the LDAP
    - Needs space to store the user/group info locally (embedded Derby database perhaps)
    - Performs fast since the queries are executed locally
    - Works for all LDAP implementations
    My thoughts on these different approaches:
    * appreach 1) I understand that the tokengroups attribute is not present if no GC server is available. In how many network environments is this the case? This option won't work because I want to support different network environments.
    * approach 2) The tokenGroupsGlobalAndUniversal attribute exists on AD DS but not on AD LDS. Same here, in how many network environments is this the case? I don't think I can rely on this approach.
    * approach 3) Seems to be a good option. How will it perform compared to approach 5 (local recursive queries)? Won't work for other LDAP implementations
    * approach 4) I don't think I want to execute that many queries to the LDAP. I can limit the scan on OU, but still companies can have thousands of users and groups.
    * approach 5) Perhaps the best approach. I want to store user/group info locally for fast filtering / reporting (only group DNs, user names, databse id's and membership info as id-id pairs). I only need the memberOf attribute of users and groups, recursive
    loops are done locally. It will work for all LDAP implementations.
    What do you guys think? I'm not a network admin, but a programmer, so I'm no expert in network setups and when to use AD DS or AD LDS. The thing is I want to use this code at different customers without knowing their network setup (except for the domain name(s),
    LDAP host/port and bind user to connect to LDAP).
    Thanks a lot!
    Paul

    I want to write a tool that can answer questions like "what users from group ABC have delete permission in all the (sub)directories of server MyDataServer?". This results in a list of directories and users and includes nested group membership. So it's about
    effective permissions. That's why I want all information in a SQL database so I can answer these questions with a single query in milliseconds. Otherwise, in order to answer these questions, I would have to get all members from group ABC and determine the
    nested groups for all these members (which can be thousands) for every report. Using a SQL database I can retrieve this information once a night for all the members.
    But I guess I will use the LDAP_MATCHING_RULE_IN_CHAIN syntax which gives me all nested groups for a member and should work for all AD installations from W2K3 SP2 and higher. When I want to support other LDAPs I will use another method for that specific
    LDAP.
    Again - note that this question has nothing to do with LDAP or AD.  It just asks what group has permissions on what resources.
    I really think you would do well to spend time understanding the NTFS and its security along with how we sue security in Windows.  By assuming this has something to do with AD you are making it a bigger issue than needed.  AD is a repository for
    accounts and trusts and manages authentication and security group membership.  All file security is managed by the OS that hosts the files and not by AD.  Users are not normally granted access to resources through direct inclusion in the DACL but
    are given access through membership in one or more groups.  Loading AD into a SQLL database will not help you.
    ¯\_(ツ)_/¯

  • Lightroom not merging and sorting images from two different cameras - help please !!

    Hi guys,
    I need some help here. I've just imported a few thousands of images form two different cameras, however Lightroom simply sorts them by camera only. (i.e.. images from the first camera, all sorted by capture time, then come images form the second camera.)
    The cameras are the same brand and model, times are synchronised, but the images refuse to merge and sort. I've tried putting them in the same folder and importing, but that doesn't do it either. I've been doing this for years and it all worked fine, till today. Does anyone know whats causing this, and how I can fix it?
    Thanks in anticipation.
    Latch

    Hi John,
    View > Sort > Capture Time is checked, The cameras are in sync down to the second, and images from both have been merging and sorting fine for over two years, till today. Sort order is all set to capture time in all modes and views, but its still sorting first by camera.

  • Need an approach to this UI issue

    Hello,
    In one of my sharepoint site pages, i have an image similar to an image given below. Now my task it to make each side, clickable. I need an approach to this please. 
    Anyone having some UI experience in SP2013, please help . 
    Many thanks !

    You could try using HTML Image Map.
    This functionality allows you to make certain areas clickable.
    Try these references
    http://www.w3schools.com/tags/tag_map.asp
    You could also try this approach using CSS3 and build the diagram using plain HTML and CSS3. You can update the fiddle to add anchors and reshape the diagram but this should give you an idea.
    http://jsfiddle.net/Nu2wt/1/
    Artificial intelligence can never beat natural stupidity.

  • Video iPods, USB2, Firewire and older macs - a different approach

    I've been trolling the discussion boards here because I find myself with the same problem many others have noted here: I just bought a family member a Video iPod (5G) for Christmas, I realize they no longer support firewire, only USB2 and I only own an older eMac that has firewire but NOT USB2 and no PCI slots for USB2 cards. I await Christmas with dread when, after opening their gift, they'll want to put content on their new 5G iPod and we'll sit around all day while that happens.
    I'll not get into why Apple dropped firewire from the 5G iPods.
    My different approach is that what is needed is a bridge connector or hub that will bridge a USB2 cable to a firewire port.
    There are a number of combo hubs but these are just 2 hubs in one with each bus (USB2 and firewire) having it's own separate connection back to the host computer. And if you connect the USB cacle back to a host with USB1, System Profiler will tell you rthat your USB2 ports areoperating at "Up to 12 Mb/sec"
    Even the Universal Dock will will not get USB2 speeds out of a mac with USB1 ports. It clearly states, :...allows you to connect your iPod with the cable that came with it."
    I've done a lot of searching and the closest I've come up with is this:
    http://www.gizmodo.com/archives/pixela-pixuvcdu1w-firewire-to-usb-20-bridge-cabl e-016285.php
    but that goes the wrong way. Plus it's expensive ($80 - $90).
    It's designed to connect a firewire equiped DV camcorder to a PC that only has USB2 ports.
    To me this sounds like an opportunity for some of the 3rd party vendors playing in the Apple world (Griffin Technology, Belkin, XtremeMac etc) to fill what is obviously a a major need here. Reading these forums there seem to be many many people that have older Macs without USB2 and 5G iPods.
    We need a USB2 to Firewire bridge connector for all of people with older macs and 5G iPods.
    Someone please help us.
    Bob Jakuc

    Thank you for your response. I mention this in my original post. In fact, I bought one of these thinking it might solve my problem. It doesn't. In effect the D-Link DFB-H7 is 2 hubs in one enclosure. To use the firewire ports you have to attach the D-Link to your computer via a firewire cable. To use the USB2 ports, you have to attach the D-Link to your computer via a USB cable. You can't have a single, unified host connection AND use all the ports on the D-Link. The USB ports on the D-Link aren't even active if you don't connect to your computer via USB.
    I'm upset for two reasons: 1) the D-Link hub advertising isn't explicit about the need to have separate hub to host connections for each bus you want to use and 2) since my eMac only has USB 1.1 ports, the USB2 ports in the D-Link are 'stepped down' to USB 1.1 speeds (12 Mbps).
    I'm also frustrated because I'd add a USB2 cardbus card to my eMac but it looks like the slot over the CD-ROM drive is only for Airport/Airport Extreme cards.
    Does anyone have any info on that? Is the slot over the CD-ROM drive in a 1 GHz eMac a general purpose cardbus/PCMCIA type II slot or is it just for Airport cards?
    Maybe I'll ask over on the discussions for the eMac.
    Thanks again.
    Bob
    Powerbook G4 (Titanium)   Mac OS X (10.4.3)   eMac 1GHz

  • Image interpolation & plastic banner design 6x8 feet

    Hi,
    I'm interested if anyone could give me some tips on setting up a photoshop file for a plastic banner that will be approx 6ft x 8 ft.  I have have photos that are original size of 11 x 14 inches - is it protocol to start with this size of a photo and interpolate up to a larger size ie: 6ft x 8 ft?
    How small of an image can you start with (at 300 dpi) to interpolate - and how high can you go? What is typical / standard working practice?
    What's the typical resolution needed for a plastic banner?
    Thank you in advance!

    >  is it protocol to start with this size of a photo and interpolate up to a larger size ie: 6ft x 8 ft?
    Yes. I've done billboards with smaller files. Once you get into it there is no "protocol" per se. Trust your eyes, if you blow it up and it stinks then you might need to rethink the design.
    >How small of an image can you start with (at 300 dpi) to interpolate - and how high can you go?
    You are not going to need that much resolution for the project you are working on and different images res up differently. If you start with something that's soft to begin with and/or contains jpeg artifacts then it doesn't blow up as well as a really sharp uncompressed image.
    >What is typical / standard working practice?
    What I would do is create the canvas and then just drag the photo onto it - then transform it until you are satisfied but don't press return, take note of what percentage you are enlarging it and then just press escape. You can delete that layer. Go back to the original image and image size it up that percentage and make sure you use bicubic smoother as the algorithm. Then copy that to the canvas. That's about as good as it gets unless you get into plug-ins that are written specifically to up res. Although for me I don't see a big improvement over bicubic smoother.
    >What's the typical resolution needed for a plastic banner?
    Communication with the printer is key in doing large format. Ask them what resolution they are looking for, it will vary depending on how close people are going to be to the piece. My guess is around 75ppi, but talk to them before you begin.
    Good Luck!
    pbc

  • How can I create a high res image gallery, need to have print res photos for a pressroom section.

    How can I create a high res image gallery, need to have print res photos for a pressroom section.

    If you want Muse to "pass through" your images and not adjust, compress, crop etc - you need to place your images in the lightbox EXACTLY at the right size, pre-cropped and prepped in Photoshop.
    So if your light box is 800x600 the image you're dropping into that must be 800x600 exactly with no effects, rotation etc added to the lightbox frame. This stop Muse fiddling with your images, if they are perfect when inserted and you're not asking Muse to crop, expand, add effects etc. If it's perfect when inserted, Muse SHOULD also leave the resolution alone too, but I have not tried that one, but in theory, it should work.

  • I have an I pad2, an iMac desktop and an I phone 5, how do I get them all to be bale to face time with each other, do I need different email addresses, use the phone number, or the sim number in the iPad ? Ay help gratefully received !!

    I have an I pad2, an iMac desktop(2012) and an I phone 5, how do I get them all to be able to face time with each other, do I need different email addresses, use the phone number, or the sim number in the iPad ? Any help gratefully received !!

    Graham,
    For the iPad, iMac you need to create verifyible e-mail addresses created with one of the providers such as Yahoo, Gmail,etc.  For the iphone you should use it's phone number, but an e-mail could be used for it too.  If you want to associate these e-mail addresses with a single ID, I'm including a link to give you info about how you can do that. Read it carefully, as it can be a bit confusing.
    http://support.apple.com/kb/HE68

  • My battery life at a full 100% charge is about 2 hours 22 minutes (backlight and key lights at lowest level). Should I go complaining to Apple or do I just need different software?

    My battery life at a full 100% charge is about 2 hours 22 minutes (backlight and key lights at lowest level). Should I go complaining to Apple or do I just need different software? I've only had my mac book since August 2011. The battery dies in 2 to 3 hours with some web surfing (little video play) and photo editing etc. I really don't feel like taking my computer all the way to the apple store to wait there for 5 hours to hear that I need to call someone blah blah blah. Any advice? (BTW Safari hasn't been working since I last updated my mac, WHYYYY?)

    emsavage1127 wrote:
    Should I go complaining to Apple or do I just need different software?
    emsavage1127 wrote:
    I really don't feel like taking my computer all the way to the apple store to wait there for 5 hours to hear that I need to call someone blah blah blah.
    Make an appointment at the genius bar, that way, you wont have to wait. http://www.apple.com/retail/geniusbar/

  • What are the different approaches to do Fault Handling?

    What are the different approaches to do Fault Handling?

    for uplodig data to non sap we have 2 methodes
    i) if u know bapi u will use lasm
    2) bdc
    but u mentioned so many records isthere
    best thing is u will uplode all record sto al11 using XI interface
    then u have to write bdc / lsmw  program
    beter to go for lsmw before that u will find bapi
    if u will unable to find bapi
    u have to create bapi and use it in lasmw
    ofter that u have schedule the lsmw program as a bockground
    then u have to create a job for it
    and release from sm 37
    then u have to moniter through bd87
    if u want to go through i will help u.
    if it is usefull to u pls give points
    Saimedha

  • Images page in different language

    The language on my images pages is different, Czech, I think.
    How do I reset to English. Only page effected and is not an issue when using IE.

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Tools > Options > Privacy > Cookies: "Show Cookies"

  • Need different sidebar lengths CS4

    Need different sidebar lengths
    Creating a website in CS4 with many pages. Some pages have a lot of content and some have a little content.
    When I change the length of the sidebar on the page with a lot of content using CSS it changes the length of the pages with a little content.
    I need to know how to independently change the length of the sidebar for the pages that have a lot of content, while not changing the length of the pages with little content.
    Most pages have a small amount of content.
    Thank you in advance.

    Height should be determined by content, but sometimes that just doesn't look right in containers with a tiny amount of content. In those situations, I generally use min-height in my css.
    A min-height setting will force open a container to whatever it's set to as that container's minimum. Anytime the content is longer than that min-height setting, it will automatically adjust to whatever the content dictates where a simple height setting would allow text to overflow its container.

Maybe you are looking for