【问题标题】:Object Selection with Photoshop scripting使用 Photoshop 脚本选择对象
【发布时间】:2021-04-12 19:53:06
【问题描述】:

我需要能够在大量图像中自动选择人物。我知道它们的坐标、宽度和高度,但理想情况下更喜欢有一个更人性化的选择,而且通过界面的普通对象选择似乎效果很好。现在我想知道我是否可以使用 Photoshop 脚本来做到这一点?任何线索表示赞赏!

澄清一下,我说的是最近推出的对象选择工具here

谢谢大家!

【问题讨论】:

  • 这将需要大量的后端代码,并且很可能需要一些机器学习/人工智能算法。做前端非常困难,但不是不可能。你最好的运气是搜索某种 API 来为你做这件事并返回一个结果。
  • 啊我的意思是触发对象选择工具?我已经选择了人类,尽管是在一个矩形边界框中。所以我想知道我是否可以使用相同的坐标触发对象选择工具?
  • 抱歉,我无法提供帮助 - 我在这里没有足够的经验。
  • 没问题!我仍然很感激你的cmets。非常感谢!

标签: javascript scripting photoshop


【解决方案1】:

我设法让这个工作。如果有人感兴趣:

假设边界框的坐标(上、左、下、右)都找到了。

var idset = stringIDToTypeID( "set" );
var desc4 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );

var ref3 = new ActionReference();
var idchannel = stringIDToTypeID( "channel" );
var idselection = stringIDToTypeID( "selection" );
ref3.putProperty( idchannel, idselection );
desc4.putReference( idnull, ref3 );

var idto = stringIDToTypeID( "to" );
    var desc5 = new ActionDescriptor();
    var idtop = stringIDToTypeID( "top" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idtop, idpixelsUnit, top );
    var idleft = stringIDToTypeID( "left" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idleft, idpixelsUnit, left );
    var idbottom = stringIDToTypeID( "bottom" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idbottom, idpixelsUnit, bottom );
    var idright = stringIDToTypeID( "right" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idright, idpixelsUnit, right );
    
var idrectangle = stringIDToTypeID( "rectangle" );
desc4.putObject( idto, idrectangle, desc5 );
var iddeepSelect = stringIDToTypeID( "deepSelect" );
desc4.putBoolean( iddeepSelect, true );
var idobjectSelectionMode = stringIDToTypeID( "objectSelectionMode" );
desc4.putInteger( idobjectSelectionMode, 0 );
var idmagicLassoAutoEnhance = stringIDToTypeID( "magicLassoAutoEnhance" );
desc4.putBoolean( idmagicLassoAutoEnhance, true );
var idsmartSubtract = stringIDToTypeID( "smartSubtract" );
desc4.putBoolean( idsmartSubtract, true );
executeAction( idset, desc4, DialogModes.NO );

这些代码可以通过ScriptingListener获取(here可用)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-05
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 2011-01-10
    • 1970-01-01
    • 2015-08-18
    相关资源
    最近更新 更多