the expansion stop sign...

I recently wrote a script that samples 4 points the upper-left corner of an image, and then use their RGB color values select the entire background. The purpose of this is so that later in action (but not in the present text) selection can be reversed and transformed into a new layer.

Taken as a whole the process essentially removes this background of an image. But, it only works if the color in the upper left corner are representative of all the background and the background is quite uniform.

I write this for 3 reasons:

(1) in case someone finds it or parts of it useful

(2) in case anyone has any suggestions on how the script could be improved... specifically I want berries could be assembled more concise?

3) because every time I play the script slows down my info panel (normally closed) open as it creates the color swatches and it drives me crazy. Is there any type of option .dialogsNO can I put it somewhere here to prevent that from happening? Or if not is there something I can add at the end of the script to close?

#target photoshop 
var doc = app.activeDocument 
doc.colorSamplers.removeAll(); 

var samp1 = doc.colorSamplers.add([1,1]); 
var samp1R = samp1.color.rgb.red; 
var samp1G = samp1.color.rgb.green; 
var samp1B = samp1.color.rgb.blue;

var samp2 = doc.colorSamplers.add([15,1]); 
var samp2R = samp2.color.rgb.red; 
var samp2G = samp2.color.rgb.green; 
var samp2B = samp2.color.rgb.blue;

var samp3 = doc.colorSamplers.add([1,15]); 
var samp3R = samp3.color.rgb.red; 
var samp3G = samp3.color.rgb.green; 
var samp3B = samp3.color.rgb.blue;

var samp4 = doc.colorSamplers.add([15,15]); 
var samp4R = samp4.color.rgb.red; 
var samp4G = samp4.color.rgb.green; 
var samp4B = samp4.color.rgb.blue;

var reds = new Array;
var greens = new Array;
var blues = new Array;

reds.push([samp1R],[samp2R],[samp3R],[samp4R]);
greens.push([samp1G],[samp2G],[samp3B],[samp4G]);
blues.push([samp1B],[samp2B],[samp3B],[samp4B]);

redsMax = Math.max.apply(Math, reds);
greensMax = Math.max.apply(Math, greens);
bluesMax = Math.max.apply(Math, blues);

redsMin = Math.min.apply(Math, reds);
greensMin = Math.min.apply(Math, greens);
bluesMin = Math.min.apply(Math, blues);

//-----------KEY ADUSTMENTS----------//
tolerance = 25;
fuziness = 40;
//-----------KEY ADUSTMENTS----------//

redsMaxAdjusted = redsMax - (tolerance/5);
greensMaxAdjusted = greensMax- (tolerance/5);
bluesMaxAdjusted = bluesMax- (tolerance/5);

redsMinAdjusted = redsMin - tolerance;
greensMinAdjusted = greensMin - tolerance;
bluesMinAdjusted = bluesMin- tolerance;

app.activeDocument.suspendHistory ("autoSelect", "selectColorRange( redsMinAdjusted, greensMinAdjusted, bluesMinAdjusted, redsMaxAdjusted, greensMaxAdjusted, bluesMaxAdjusted, fuziness )");

function selectColorRange (minR, minG, minB, maxR, maxG, maxB, fuzz) {
var idClrR = charIDToTypeID( "ClrR" );
    var desc4 = new ActionDescriptor();
    var idFzns = charIDToTypeID( "Fzns" );
    desc4.putInteger( idFzns, fuzz );
    var idMnm = charIDToTypeID( "Mnm " );
        var desc5 = new ActionDescriptor();
        var idR = charIDToTypeID( "Rd  " );
        desc5.putDouble( idR, minR );
        var idG = charIDToTypeID( "Grn " );
        desc5.putDouble( idG, minG );
        var idB = charIDToTypeID( "Bl  " );
        desc5.putDouble( idB, minB );
    var idRGCl = charIDToTypeID( "RGBC" );
    desc4.putObject( idMnm, idRGCl, desc5 );
    var idMxm = charIDToTypeID( "Mxm " );
        var desc6 = new ActionDescriptor();
        var idR = charIDToTypeID( "Rd  " );
        desc6.putDouble( idR, maxR );
        var idG = charIDToTypeID( "Grn " );
        desc6.putDouble( idG, maxG );
        var idB = charIDToTypeID( "Bl  " );
        desc6.putDouble( idB, maxB );
    var idRGCl = charIDToTypeID( "RGBC" );
    desc4.putObject( idMxm, idRGCl, desc6 );
    var idcolorModel = stringIDToTypeID( "colorModel" );
    desc4.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc4, DialogModes.NO );
};

You could add...

app.runMenuItem (stringIDToTypeID ('closeInfoPanel'));

This should then close the Info Panel.

Tags: Photoshop

Similar Questions

  • Stop sign gray to start on Macbook

    Hello

    I have an old early 2008 Macbook (13-inch, 2.1 GHz Intel Core Duo processor) which had a defective hard drive, a couple of years. I finally had the time to try to correct what I can use it again as a second laptop.

    I bought a new SATA III 7200 RPM hard drive and replaced the old hard drive with it. Then I tried to turn on the computer with a USB superdrive plugged with OSX Snow Leopard top. I tried the safe mode, recovery mode, boot to a CD, Netboot... no matter what I tried I got back to the gray prohibitive stop sign.

    I tried the PRAM reset, reset SMC and another SATA (external) to start the hard drive cable. None of them seemed to work. I have read through many different answers on this problem but now it seems back to the same solutions that have not worked for me so far, so I thought I'd try to post a question myself. Any help would be appreciated.

    Tristan

    Apple Superdrive USB? Who does not work on a Mac that has built in player works or not. Ironic huh? You must partition and format the new drive for use with a Mac and there are several ways to do it, but you either need another Mac or a compatible third-party external disk since I assume that your player internal doesn't?

  • How can I remove the Windows Live Sign In requirement for my windows live mail?

    Something changed in my installation of Windows Vista HP and I am now faced with a sign to connect to Windows Live 'request' every time I try to access my windows live mail.  (From the desktop icon).  I can click on through that connection and I will be headed to my live mail account (without entering any information of personal password) so I have no idea what use this sign is actually - but it's PRETTY! boring.  All he seems to do is add more clicks for me to be able to do what I had previously been able to.   BING was not very helpful to help me find a way to turn off this annoying 'feature'.   I tried to use the program on Windows Essentials items removal (all except the direct mail) but this did not help.  Where can I fo to disable this pop-up window?  (And of course, I don't want to lose my current e-mail settings or messages!)

    The sign is in Windows Live (contacts, calendar, photo upload) services.
    Contacts and calendar will be synchronized with the calendar and the active contacts.  When
    do not sign, stored locally, calendar and contacts not synchronized will be
    used.
    In 2009 WLMail, Alt + T, Options, connection tab, stop signing in.
    WLMail 2011, Alt + F, Options, e-mail, connection tab, stop signing in.
     
    -Ron Sommer
    MS MVP Windows Live Mail
     
    "gvteckie" wrote in message
    News: * e-mail address is removed from the privacy... *
    Something changed in my installation of Windows Vista HP and am now
    faced with a sign to connect to Windows Live 'demand' whenever I try
    access my windows live mail.  (From the desktop icon).  I can click on
    With this connection will be directed to my direct (without mail account
    Enter the personal password information) so I have no idea what use this sign in
    sure- but it's PRETTY! boring.  All he seems to do is add
    more clicks for me to be able to do what I had previously been able to.
    BING was not very helpful to help me find a way to turn this
    annoying "feature".   I tried to use the removal program on the
    Elements of Windows Essentials (all except the direct mail), but this did not help.
    Where can I fo to disable this pop-up window?  (And of course, I don't want to lose
    my settings current e-mail or messages!)
     
     
  • I receive the "could not sign in you [access denied: 530]." Check your user name and password ' problem on Adobe Muse CC 2014 and I can not access the xml file that is supposed to solve this problem?

    I am a PC user and I have Adobe Creative Cloud Muse 2014. I received the "could not sign in you [access denied: 530]." Check your username and password "error. trying to download my muse to my ftp, GoDaddy host site I did it successfully in the past and that recently it has stopped working. I looked online at the Adobe Muse Help FAQ | Download a Site from Muse Adobe on a third-party hosting service and he said to download the ftpprefs.xml file but this file simply leads to a blank page that says / * not found * / / * not found * /.

    Can you direct me to a page to work with this file, or provide an alternative? Thank you!

    Hello

    As you have found the error [access denied: 530] This means that the problem is with access. The user name and password that you enter is incorrect or you don't have the appropriate permissions.

    I suggest you to contact Godaddy to reset the password or reset the permissions.


    Concerning

    Vivek

  • The music stops when messaging on viber

    so until I have updated to iOS 10, I can listen to my music and message on viber.

    somehow after the update to iOS 10 whenever I try to post on viber while listening to music, the music stops playing. And when I slide up to listen to the music it shows this. PS I upgraded viber last night their last 10 updated ios as well.

    I tried turning off the sounds in viber notifications, but that didn't work either.

    Just turn off "Sounds In - App" "Notifications" on your Viber settings.

  • inadvertently omitted the box "stay signed in on" checked. Now, my user name always appears automatically. Don't want him! Also want to leave that box unchecked unavailability

    Using FF; Windows 7:
    (1) I'm NOT tech-oriented and I indavertently left the box "stay signed in on" checked. Now my user name always appears automatically and I don't want him, but I can't find how to fix it ANYWHERE.
    (2) how can I keep that box "stay signed in on" disabled permanently.
    (3) before coming to this page, there is a page that asked me my e-mail address, etc.. He said that the email was already in use. No kidding; This is me. He was trying to create a new account, so I finally just used another email address & implemented a new.

    A detail as a website to remember you (automatically log you) is stored in a cookie.

    You can use these steps to make a Web site recognize and remember you:

    • Create a cookie 'allow' except to keep these cookies, in particular in the case of secure websites and when the cookies expire when Firefox is closed.
    • Tools > Options > privacy > "Use the custom settings for history" > Cookies: Exceptions

    You can delete cookies for a Web site to make the site forget about you.
    'Delete Cookies' sites causing problems:

    • Firefox/tools > Options > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".
  • TBird causes the computer stops responding.

    TBird 38.1.0 (automatic update on), Lenovo T61, Win 7 Pro (auto update on), Microsoft Security essentials (automatic update on).

    Problem started a couple of days after, add a calendar on (lightning?) had installed without authorization or request. TB started, but then PC unresponsive shortly after. A message or two can download before the full stop. PC must be turned off using the power switch.

    From TB in SafeMode with shift seems to restore normal operation. By using the safe mode start, all the addons have been deactivated and deleted. Or at least I think.


  • The new App Store for El Capitan update has locked up my macbook pro.  Reboot got about 3/4 fact and the machine stops. Turned off the power and turn it on again for nothing doesn't.  How in my machine to begin troubleshooting?

    The new App Store for El Capitan update has locked up my macbook pro.  Reboot got about 3/4 fact and the machine stops. Turned off the power and turn it on again for nothing doesn't.  How in my machine to begin troubleshooting?

    The problem is most likely an attempt to update a system malfunction prior it is probably a problem with your computer, not the El Capitan.

    Start by:

    Reset the PRAM and NVRAM on your Mac.

    MacIntel: Reset of the controller (SMC) system management

    Start in Safe Mode , and then re - start normally. It's slower that a normal start, so be patient.

    If you are unable to start;

    Reinstall El Capitan without erasing the drive

    Please make sure that you back up.

    1. Restart the computer. Immediately after that the chime hold down the command and R until the Utility Menu appears.
    2. Select disk utility, then click on the continue button.
    3. Select the withdrawal (usually Macintosh HD) entry of the volume in the list aside.
    4. Click first aid icon in the toolbar. Wait until the button is active, then click it.
    5. Quit disk utility and re-enter the Utility Menu.
    6. Select Reinstall OS X and click on the continue button.

    Also, see this tip for user: basic steps for the OS X upgrade.

    If this doesn't get you;

    Install Yosemite or El Capitan, from scratch

    Backup if possible before proceeding.

    Restart the computer. Immediately after the chime hold down the command and R buttons until the Apple logo appears. When the Utility Menu appears:

    Select utility disc in the Menu Utility, then click the continue button.

    When loading disk utility, select the volume (entered into withdrawal, usually Macintosh HD) from the list of devices.

    Click Delete in the main window of disk utility. A panel will fall.

    Define the type of Format Mac OS extended (journaled).

    Click on the apply button, then wait for the done button to activate and click on it.

    Quit disk utility and re-enter the Utility Menu.

    Select reinstall OS X and click on the continue button.

  • Use the certificate self-signed on TS 2008R2

    Hello reader,.

    We use Firefox on a Terminal server with about 20 servers server farm environment.
    We use a lot of intranet sites for which we have the certificate self-signed by our domain controller.

    In Firefox users get prompt security sec_error_unknown_issuer. As much as I red that Firefox does not check for local free self-signed certificates.
    Is there a way we could set up for all users, they do not see the above error-> specific <-websites (intranet)?

    We do not want the users to add the Security (certificate) as exception 20 times for EACH intranet website on 20 servers dispute.
    It is something that I can edit in mozilla.cfg on each server or is there another solution?

    Thanks in advance,
    Kind regards
    Martijn

    I solved the problem with manual below:

    http://community.Spiceworks.com/how_to/15158-Firefox-trust-a-local-certificate-authority-for-all-users-and-computers

  • How to restore the refresh/stop button?

    I have my perfectly configured browser buttons I would like it. I don't need someone to another deletion or moving them where they feel they are in a better place.

    How to restore the refresh/stop button? Yes, I update it in the address bar. I want it on the left, next to the button at home where he has been for 10 years.

    Chrome allows me to set the button where I want. The latest version of Firefox did too.

    Thank you. It works almost, installation of two plugins to restore my settings to normal. Unfortunately, my understanding of button is:

    Back/Forward. Home page | Refresh/Stop

    and has been for a long time. I can't move the previous/next buttons. If my muscle memory is defined, and every time I hit the back button, I have to stop and think that it is now.

    It's the same thing that I don't like IE.

    Consider me a convert to Chrome, guys. Now I have to remember to click on the eye of the Rainbow and not the orange Fox - but at least I only will once per day.

  • The keep me signed in box on my e-mail login page Yahoo disappeared.

    Now, I have to sign in each time. I tried everything, clear cookies and cache and nothing brings this option. This is the only site I seem to have issues. However, the keep me signed in box is there when I use an older Firefox and IE.

    Some information about this were available, but nothing seems to work.

    I added the clearing form & Search History, Site preferences and data from the Web site offline in addition to Cache and browsing & download history and that seems to fix the problem. I don't know well about who did it.

  • Why has my Automatic rotation of the ipad stopped when I pass the vertical horizontal screen remains in the vertical position?

    Why has my Automatic rotation of the ipad stopped when I pass the vertical horizontal screen remains in the vertical position?

    Not all applications are supported both orientations. If you experience of this with an app that should work, you know, you most likely locked up the switch of direction. Drag your finger from the bottom of the screen bezel to display Control Center. Tap on the lock with a circular arrow icon.

  • 16.0.2 Firefox when browsing Facebook, the browser stops reponding. (Script: chrome://wrc/content/overlay.js:1677))

    When you use Firefox 16.0.2 and browsing Facebook, the browser stops responding and an error message appears saying that the script has stopped working. (Script: chrome://wrc/content/overlay.js:1677))
    This only happens on Firefox and Facebook work well when you use Google Chrome. As firefox is my favorite browser that I would get this fixed default problem.

    See this recent thread on a similar question:

  • The file is signed with a digital signature that is broken, published by: Mozilla Corporation.

    My anti-virus gives me the following message is displayed:
    "C:\Users\MArendas\Downloads\Firefox Setup 13.0.exe"; "The file is signed with a digital signature that is broken, published by: Mozilla Corporation. « ; » »
    Why and what do I do about it?

    Go to your download folder (click Start, click the account name above 'documents' then click on 'Downloads'. Remove it from there.

  • If my software update of the Appstore stops to say 1.3 GB of 6.4 GB due to network etc problem it back once again to 1.3 GB rear or all the way from scratch

    If my software update of the Appstore stops to say 1.3 GB of 6.4 GB due to network etc problem it back once again to 1.3 GB rear or all the way from scratch.

    Hello Anshul230499,

    Thank you for using communities of Apple Support.

    If a download was interrupted in the Mac App Store, then whenever you have new Internet download should then restart.

    If a download application is interrupted

    Once an Internet connection is restored, your purchased downloads should restart automatically. The Mac App Store may warn you that there is a problem with the download and ask if you want to restart downloads. Confirming will restart all pending downloads.

    Download time may vary according to the size of the file and the speed of your Internet connection. See this article on purchases made on iTunes Store for more information on the time to download large files.

    Troubleshooting the Mac App Store

    Take care.

Maybe you are looking for

  • Qosmio G40 - graphics card keeps overheating and crashing all at stake

    My nVidia 8600GT card in my laptop Qosmio G40 overheating guard and crashing when I m gaming. It works all the games that I put on it fine, but overheating then crashes and me kicks off the games I play m.Is it just because it s a laptop and it s inc

  • Accident of mail!

    Hi, on my MacPro early 2009 running OS 10.10.5 opening mail I see no message and my mailboxes, but research in Library\mail\ in this directory that they are present in steel. This problem remains also after controls and repair disk. That's happened?

  • External thumb drive operation

    It has been long since I used a USB on my OS X 10.9.5 with 2 Ghz Intel Core 2 Duo, iMac. I have plugged and found symbol of the external drive in the Finder on the side of the menu, pressed to save the document that I had finished, and the symbol pur

  • Add the WNAP210 v2 to the Business Centre

    Hi all A few months ago, I bought 3 WNAP210 and 2 days ago, I created a central Busines 90 days free trial account. I want to add access points to "the cloud". So far, no luck. Everything I try, after completing the series number, the unit will in 'p

  • iPhone 4 is not recognized in itunes or devices. (essentially to have windows 7) Drivers must be installed/updated

    Hello! This seems to be a fairly common problem, but after extensive research on the web and endless trials and errors I can still fix my problem! It makes me crazy! No pun intended. I have re-installed... restarted... reset... and I'm tired. I have